Cleanup Dockerfile. NFC. (#569)

- Remove unnecessary dependencies from build stage.
- Move binutils installation to first layer.
- Adjust indents and spacing.
- Merge ENV declarations into a single line.
- Split apt-get commands over multiple lines
This commit is contained in:
Kleis Auke Wolthuizen
2020-07-25 20:04:20 +02:00
committed by GitHub
parent b5077e4642
commit de08462b17

View File

@@ -6,27 +6,26 @@ ENV EMSDK /emsdk
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
RUN echo "## Start building" \ RUN echo "## Start building" \
\ && echo "## Update and install packages" \
&& echo "## Update and install packages" \
&& apt-get -qq -y update \ && apt-get -qq -y update \
&& apt-get -qq install -y --no-install-recommends \ && apt-get -qq install -y --no-install-recommends \
libxml2 \ binutils \
wget \
git-core \
ca-certificates \
build-essential \ build-essential \
ca-certificates \
file \ file \
python3 python3-pip \ git \
&& echo "## Done" python3 \
python3-pip \
&& echo "## Done"
RUN echo "## Get EMSDK" \ RUN echo "## Get EMSDK" \
&& git clone https://github.com/emscripten-core/emsdk.git ${EMSDK} \ && git clone https://github.com/emscripten-core/emsdk.git ${EMSDK} \
&& echo "## Done" && echo "## Done"
RUN echo "## Install Emscripten" \ RUN echo "## Install Emscripten" \
&& cd ${EMSDK} \ && cd ${EMSDK} \
&& ./emsdk install ${EMSCRIPTEN_VERSION} \ && ./emsdk install ${EMSCRIPTEN_VERSION} \
&& echo "## Done" && echo "## Done"
# This generates configuration that contains all valid paths according to installed SDK # This generates configuration that contains all valid paths according to installed SDK
RUN cd ${EMSDK} \ RUN cd ${EMSDK} \
@@ -34,12 +33,10 @@ RUN cd ${EMSDK} \
&& ./emsdk activate ${EMSCRIPTEN_VERSION} \ && ./emsdk activate ${EMSCRIPTEN_VERSION} \
&& chmod -R 777 ${EMSDK}/upstream/emscripten/cache \ && chmod -R 777 ${EMSDK}/upstream/emscripten/cache \
&& cat ${EMSDK}/upstream/emscripten/cache/sanity.txt \ && cat ${EMSDK}/upstream/emscripten/cache/sanity.txt \
&& echo "## Done" && echo "## Done"
# Clean up emscripten installation and strip some symbols # Cleanup Emscripten installation and strip some symbols
RUN echo "## Aggresive optimization: Remove debug symbols" \ RUN echo "## Aggressive optimization: Remove debug symbols" \
&& apt-get -qq -y update && apt-get -qq install -y --no-install-recommends \
binutils \
&& cd ${EMSDK} && . ./emsdk_env.sh \ && cd ${EMSDK} && . ./emsdk_env.sh \
# Remove debugging symbols from embedded node (extra 7MB) # Remove debugging symbols from embedded node (extra 7MB)
&& strip -s `which node` \ && strip -s `which node` \
@@ -49,7 +46,7 @@ RUN echo "## Aggresive optimization: Remove debug symbols" \
&& rm -fr ${EMSDK}/upstream/fastcomp \ && rm -fr ${EMSDK}/upstream/fastcomp \
# strip out symbols from clang (~extra 50MB disc space) # strip out symbols from clang (~extra 50MB disc space)
&& find ${EMSDK}/upstream/bin -type f -exec strip -s {} + || true \ && find ${EMSDK}/upstream/bin -type f -exec strip -s {} + || true \
&& echo "## Done" && echo "## Done"
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# -------------------------------- STAGE DEPLOY -------------------------------- # -------------------------------- STAGE DEPLOY --------------------------------
@@ -62,10 +59,10 @@ COPY --from=stage_build /emsdk /emsdk
# Fallback in case Emscripten isn't activated. # Fallback in case Emscripten isn't activated.
# This will let use tools offered by this image inside other Docker images # This will let use tools offered by this image inside other Docker images
# (sub-stages) or with custom / no entrypoint # (sub-stages) or with custom / no entrypoint
ENV EMSDK_NODE=/emsdk/node/12.18.1_64bit/bin/node ENV EMSDK=/emsdk \
ENV EMSDK=/emsdk EM_CONFIG=/emsdk/.emscripten \
ENV EM_CONFIG=/emsdk/.emscripten EMSDK_NODE=/emsdk/node/12.18.1_64bit/bin/node \
ENV PATH="${EMSDK}:${EMSDK}/upstream/emscripten:${EMSDK}/upstream/bin:emsdk/node/12.18.1_64bit/bin:${PATH}" PATH="/emsdk:/emsdk/upstream/emscripten:/emsdk/upstream/bin:/emsdk/node/12.18.1_64bit/bin:${PATH}"
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Create a 'standard` 1000:1000 user # Create a 'standard` 1000:1000 user
@@ -80,15 +77,15 @@ RUN echo "## Create emscripten user (1000:1000)" \
&& 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 "umask 0000" >> /etc/bash.bashrc \
&& echo ". /emsdk/emsdk_env.sh" >> /etc/bash.bashrc \ && echo ". /emsdk/emsdk_env.sh" >> /etc/bash.bashrc \
&& echo "## Done" && echo "## Done"
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
RUN echo "## Update and install packages" \ RUN echo "## Update and install packages" \
# mitigate problem with create symlink to man for base debian image # mitigate problem with create symlink to man for base debian image
&& mkdir -p /usr/share/man/man1/ \ && mkdir -p /usr/share/man/man1/ \
\ && apt-get -qq -y update \
&& apt-get -qq -y update && apt-get -qq install -y --no-install-recommends \ && apt-get -qq install -y --no-install-recommends \
libxml2 \ libxml2 \
ca-certificates \ ca-certificates \
python3 \ python3 \
@@ -105,7 +102,6 @@ RUN echo "## Update and install packages" \
libidn11 \ libidn11 \
cmake \ cmake \
openjdk-11-jre-headless \ openjdk-11-jre-headless \
\
# Standard Cleanup on Debian images # Standard Cleanup on Debian images
&& apt-get -y clean \ && apt-get -y clean \
&& apt-get -y autoclean \ && apt-get -y autoclean \
@@ -115,7 +111,7 @@ RUN echo "## Update and install packages" \
&& rm -rf /usr/share/doc/* \ && rm -rf /usr/share/doc/* \
&& rm -rf /usr/share/man/?? \ && rm -rf /usr/share/man/?? \
&& rm -rf /usr/share/man/??_* \ && rm -rf /usr/share/man/??_* \
&& echo "## Done" && echo "## Done"
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Internal test suite of tools that this image provides # Internal test suite of tools that this image provides
@@ -123,7 +119,7 @@ COPY test_dockerimage.sh /emsdk/
RUN echo "## Internal Testing of image" \ RUN echo "## Internal Testing of image" \
&& /emsdk/test_dockerimage.sh \ && /emsdk/test_dockerimage.sh \
&& echo "## Done" && echo "## Done"
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Copy this Dockerimage into image, so that it will be possible to recreate it later # Copy this Dockerimage into image, so that it will be possible to recreate it later