Docker: use a entrypoint script (#1227)

In favor of `/etc/bash.bashrc`, which is only read for interactive
shells.
This commit is contained in:
Kleis Auke Wolthuizen
2023-07-06 16:44:01 +02:00
committed by GitHub
parent 3bde060365
commit e28e47659c
5 changed files with 18 additions and 10 deletions

View File

@@ -1,7 +1,8 @@
# Ignore everything # Ignore everything
* *
# Allow to run the test script inside the Docker container # Allow the entrypoint/test script inside the Docker container
!/docker/entrypoint.sh
!/docker/test_dockerimage.sh !/docker/test_dockerimage.sh
# Allow license file # Allow license file

View File

@@ -58,11 +58,12 @@ FROM ubuntu:jammy AS stage_deploy
COPY --from=stage_build /emsdk /emsdk COPY --from=stage_build /emsdk /emsdk
# Fallback in case Emscripten isn't activated. # These fallback environment variables are intended for situations where the
# This will let use tools offered by this image inside other Docker images # entrypoint is not utilized (as in a derived image) or overridden (e.g. when
# (sub-stages) or with custom / no entrypoint # using `--entrypoint /bin/bash` in CLI).
# This corresponds to the env variables set during: `source ./emsdk_env.sh`
ENV EMSDK=/emsdk \ ENV EMSDK=/emsdk \
PATH="/emsdk:/emsdk/upstream/emscripten:/emsdk/upstream/bin:/emsdk/node/16.20.0_64bit/bin:${PATH}" PATH="/emsdk:/emsdk/upstream/emscripten:/emsdk/node/16.20.0_64bit/bin:${PATH}"
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Create a 'standard` 1000:1000 user # Create a 'standard` 1000:1000 user
@@ -75,8 +76,6 @@ ENV EMSDK=/emsdk \
RUN echo "## Create emscripten user (1000:1000)" \ RUN echo "## Create emscripten user (1000:1000)" \
&& groupadd --gid 1000 emscripten \ && groupadd --gid 1000 emscripten \
&& useradd --uid 1000 --gid emscripten --shell /bin/bash --create-home emscripten \ && useradd --uid 1000 --gid emscripten --shell /bin/bash --create-home emscripten \
&& echo "umask 0000" >> /etc/bash.bashrc \
&& echo ". /emsdk/emsdk_env.sh" >> /etc/bash.bashrc \
&& echo "## Done" && echo "## Done"
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -120,6 +119,8 @@ RUN echo "## Update and install packages" \
# Use commonly used /src as working directory # Use commonly used /src as working directory
WORKDIR /src WORKDIR /src
ENTRYPOINT ["/emsdk/docker/entrypoint.sh"]
LABEL maintainer="kontakt@trzeci.eu" \ LABEL maintainer="kontakt@trzeci.eu" \
org.label-schema.name="emscripten" \ org.label-schema.name="emscripten" \
org.label-schema.description="The official container with Emscripten SDK" \ org.label-schema.description="The official container with Emscripten SDK" \

View File

@@ -17,8 +17,8 @@ build: Dockerfile .TEST
test: test_dockerimage.sh .TEST test: test_dockerimage.sh .TEST
# test as non-root # test as non-root
docker run --rm -u `id -u`:`id -g` -w /emsdk/docker --net=host ${image_name}:${version} \ # test fallback env variables by overriding the entrypoint
bash $< docker run --rm -u `id -u`:`id -g` -w /emsdk/docker --net=host --entrypoint /bin/bash ${image_name}:${version} $<
push: .TEST push: .TEST
docker push ${image_name}:${version} docker push ${image_name}:${version}

7
docker/entrypoint.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
set -e
# Set-up PATH and other environment variables
EMSDK_QUIET=1 source /emsdk/emsdk_env.sh
exec "$@"

View File

@@ -5,7 +5,6 @@ if [ $EUID -eq 0 ]; then
sudo -u nobody `which emcc` --version sudo -u nobody `which emcc` --version
fi fi
which llvm-ar
which emsdk which emsdk
node --version node --version
npm --version npm --version