Skip to content

Commit

Permalink
fix: docker build deprecation warnings
Browse files Browse the repository at this point in the history
With the latest Docker upgrade, we got the following warnings during
build:

	FromAsCasing: 'as' and 'FROM' keywords' casing do not match
	LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format
  • Loading branch information
regisb committed Jun 21, 2024
1 parent de58c6d commit 6777742
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions changelog.d/20240621_170044_regis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- [Bugfix] Fix legacy warnings during Docker build. (by @regisb)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1.4
###### Minimal image with base system requirements for most stages
FROM docker.io/ubuntu:20.04 as minimal
FROM docker.io/ubuntu:20.04 AS minimal

RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
Expand All @@ -20,7 +20,7 @@ WORKDIR /openedx/ecommerce_worker
# https://www.python.org/downloads/
# https://github.com/pyenv/pyenv/releases
ARG PYTHON_VERSION=3.12.2
ENV PYENV_ROOT /opt/pyenv
ENV PYENV_ROOT=/opt/pyenv
# root user is required for below 2 steps, as app user gets permission denied.
USER root
RUN git clone https://github.com/pyenv/pyenv $PYENV_ROOT --branch v2.3.36 --depth 1
Expand All @@ -30,13 +30,13 @@ USER app

# Create virtualenv
RUN $PYENV_ROOT/versions/$PYTHON_VERSION/bin/python -m venv ../venv/
ENV PATH "/openedx/venv/bin:$PATH"
ENV PATH=/openedx/venv/bin:$PATH
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared pip install \
# https://pypi.org/project/setuptools/
# https://pypi.org/project/pip/
# https://pypi.org/project/wheel/
setuptools==69.1.1 pip==24.0 wheel==0.43.0
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared pip install -r requirements/production.txt

ENV WORKER_CONFIGURATION_MODULE ecommerce_worker.settings.production
ENV WORKER_CONFIGURATION_MODULE=ecommerce_worker.settings.production
CMD celery --app=ecommerce_worker.celery_app:app worker --loglevel=info --max-tasks-per-child=100 --queues=fulfillment,email_marketing
18 changes: 9 additions & 9 deletions tutorecommerce/templates/ecommerce/build/ecommerce/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1.4
###### Minimal image with base system requirements for most stages
FROM docker.io/ubuntu:20.04 as minimal
FROM docker.io/ubuntu:20.04 AS minimal

ENV DEBIAN_FRONTEND=noninteractive
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
Expand All @@ -9,7 +9,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
apt install -y curl gettext git-core language-pack-en

###### Checkout code
FROM minimal as checkout
FROM minimal AS checkout

ARG ECOMMERCE_REPOSITORY=https://github.com/openedx/ecommerce.git
ARG ECOMMERCE_VERSION='{{ OPENEDX_COMMON_VERSION }}'
Expand All @@ -23,11 +23,11 @@ RUN git config --global user.email "tutor@overhang.io" \
##### Empty layer with just the repo at the root.
# This is useful when overriding the build context with a host repo:
# docker build --build-context /path/to/ecommerce
FROM scratch as ecommerce-src
FROM scratch AS ecommerce-src
COPY --from=checkout /openedx/ecommerce /

###### Install python and virtual environment
FROM minimal as python
FROM minimal AS python

RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
Expand All @@ -47,7 +47,7 @@ RUN mkdir /openedx/.cache
# https://www.python.org/downloads/
# https://github.com/pyenv/pyenv/releases
ARG PYTHON_VERSION=3.12.2
ENV PYENV_ROOT /opt/pyenv
ENV PYENV_ROOT=/opt/pyenv
# root user is required for below 2 steps, as app user gets permission denied.
USER root
RUN git clone https://github.com/pyenv/pyenv $PYENV_ROOT --branch v2.3.36 --depth 1
Expand All @@ -57,7 +57,7 @@ USER app

# Create virtualenv
RUN $PYENV_ROOT/versions/$PYTHON_VERSION/bin/python -m venv /openedx/venv
ENV PATH "/openedx/venv/bin:$PATH"
ENV PATH=/openedx/venv/bin:$PATH
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared,uid=${APP_USER_ID} pip install \
# https://pypi.org/project/setuptools/
# https://pypi.org/project/pip/
Expand All @@ -68,7 +68,7 @@ RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared,uid=${APP_USER_
# https://pypi.org/project/nodeenv
RUN pip install nodeenv==1.8.0
RUN nodeenv /openedx/nodeenv --node=16.20.0 --prebuilt
ENV PATH /openedx/nodeenv/bin:${PATH}
ENV PATH=/openedx/nodeenv/bin:${PATH}

# Copy ecommerce source code
COPY --from=ecommerce-src --chown=app:app / /openedx/ecommerce
Expand Down Expand Up @@ -100,15 +100,15 @@ RUN python manage.py compilemessages

# Collect static assets (aka: "make static")
COPY --chown=app:app assets.py ./ecommerce/settings/assets.py
ENV DJANGO_SETTINGS_MODULE ecommerce.settings.assets
ENV DJANGO_SETTINGS_MODULE=ecommerce.settings.assets
RUN python3 manage.py update_assets --skip-collect
RUN ./node_modules/.bin/r.js -o build.js
RUN python3 manage.py collectstatic --noinput
RUN python3 manage.py compress --force

# Setup minimal yml config file, which is required by production settings
RUN echo "{}" > /openedx/config.yml
ENV ECOMMERCE_CFG /openedx/config.yml
ENV ECOMMERCE_CFG=/openedx/config.yml

EXPOSE 8000
CMD uwsgi \
Expand Down

0 comments on commit 6777742

Please sign in to comment.