Skip to content

Commit

Permalink
feat: ubuntu upgrade in dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Faraz Maqsood authored and Muhammad Faraz Maqsood committed Sep 3, 2024
1 parent 83ed38e commit 6154a31
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions tutorcredentials/templates/credentials/build/credentials/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
###### Minimal image with base system requirements for most stages
FROM docker.io/ubuntu:20.04 AS minimal
FROM docker.io/ubuntu:24.04 AS minimal

ENV DEBIAN_FRONTEND=noninteractive
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
Expand All @@ -11,15 +11,14 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
ENV LC_ALL=en_US.UTF-8
{{ patch("credentials-dockerfile-minimal") }}


###### Install python with pyenv in /opt/pyenv and create virtualenv in /openedx/venv
FROM minimal AS python
# https://github.com/pyenv/pyenv/wiki/Common-build-problems#prerequisites
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked apt update && \
apt install -y libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
xz-utils tk-dev libffi-dev liblzma-dev python3-openssl git

# Install pyenv
# https://www.python.org/downloads/
Expand Down Expand Up @@ -102,15 +101,15 @@ FROM minimal AS production
# Install system requirements
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked apt update \
&& apt install -y libxml2 libmysqlclient-dev mime-support
&& apt install -y libxml2 libmysqlclient-dev media-types mailcap

# From then on, run as unprivileged "app" user
ARG APP_USER_ID=1000
ARG APP_USER_ID=1001
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}

# change file ownership to the new app user
# Change file ownership to the new app user
COPY --chown=app:app --from=code /openedx/credentials /openedx/credentials
COPY --chown=app:app --from=python /opt/pyenv /opt/pyenv
COPY --chown=app:app --from=python-requirements /openedx/venv /openedx/venv
Expand Down Expand Up @@ -152,13 +151,13 @@ EXPOSE 8000
###### Final image with production cmd
FROM production AS final

CMD uwsgi \
--static-map /static=/openedx/credentials/credentials/assets \
--static-map /media=/openedx/credentials/credentials/media \
--http 0.0.0.0:8000 \
--thunder-lock \
--single-interpreter \
--enable-threads \
--processes=${UWSGI_WORKERS:-2} \
--buffer-size=8192 \
--wsgi-file credentials/wsgi.py
CMD ["uwsgi", \
"--static-map", "/static=/openedx/credentials/credentials/assets", \
"--static-map", "/media=/openedx/credentials/credentials/media", \
"--http", "0.0.0.0:8000", \
"--thunder-lock", \
"--single-interpreter", \
"--enable-threads", \
"--processes=${UWSGI_WORKERS:-2}", \
"--buffer-size=8192", \
"--wsgi-file", "credentials/wsgi.py"]

0 comments on commit 6154a31

Please sign in to comment.