From fa9e86e188f0a70b84f8b688e83a32a65b7bea10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Mon, 13 Mar 2023 18:07:26 +0100 Subject: [PATCH] improvement: COPY dockerize for faster build Dockerize now ships with multi-arch Docker images, so we can just COPY the binary from these images. This allows us to skip an image layer. --- changelog.d/20230313_180716_regis_docker_optimize.md | 1 + tutor/templates/build/openedx/Dockerfile | 12 ++---------- 2 files changed, 3 insertions(+), 10 deletions(-) create mode 100644 changelog.d/20230313_180716_regis_docker_optimize.md diff --git a/changelog.d/20230313_180716_regis_docker_optimize.md b/changelog.d/20230313_180716_regis_docker_optimize.md new file mode 100644 index 0000000..98bac1a --- /dev/null +++ b/changelog.d/20230313_180716_regis_docker_optimize.md @@ -0,0 +1 @@ +- [Improvement] During openedx image build, copy `dockerize` utility from Docker registry for better efficiency. (by @regisb) diff --git a/tutor/templates/build/openedx/Dockerfile b/tutor/templates/build/openedx/Dockerfile index 0140383..e3d1633 100644 --- a/tutor/templates/build/openedx/Dockerfile +++ b/tutor/templates/build/openedx/Dockerfile @@ -21,15 +21,6 @@ RUN git clone https://github.com/pyenv/pyenv $PYENV_ROOT --branch v2.2.2 --depth RUN $PYENV_ROOT/bin/pyenv install $PYTHON_VERSION RUN $PYENV_ROOT/versions/$PYTHON_VERSION/bin/python -m venv /openedx/venv -###### Install Dockerize to wait for mysql DB availability -FROM minimal as dockerize -# https://github.com/powerman/dockerize/releases -ARG DOCKERIZE_VERSION=v0.16.0 -RUN dockerize_url="https://github.com/powerman/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-$(uname -m | sed 's@aarch@arm@')" \ - && echo "Downloading dockerize from $dockerize_url" \ - && curl --fail --location --output /usr/local/bin/dockerize $dockerize_url \ - && chmod a+x /usr/local/bin/dockerize - ###### Checkout edx-platform code FROM minimal as code ARG EDX_PLATFORM_REPOSITORY={{ EDX_PLATFORM_REPOSITORY }} @@ -136,7 +127,8 @@ RUN if [ "$APP_USER_ID" = 0 ]; then echo "app user may not be root" && false; fi RUN useradd --home-dir /openedx --create-home --shell /bin/bash --uid ${APP_USER_ID} app USER ${APP_USER_ID} -COPY --from=dockerize /usr/local/bin/dockerize /usr/local/bin/dockerize +# https://hub.docker.com/r/powerman/dockerize/tags +COPY --from=docker.io/powerman/dockerize:0.19.0 /usr/local/bin/dockerize /usr/local/bin/dockerize COPY --chown=app:app --from=code /openedx/edx-platform /openedx/edx-platform COPY --chown=app:app --from=locales /openedx/locale /openedx/locale COPY --chown=app:app --from=python /opt/pyenv /opt/pyenv