Skip to content

Commit

Permalink
Merge branch 'main' into huniafatima/consolidate-image-publish-workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
huniafatima-arbi committed Nov 7, 2024
2 parents 8ce622d + 727ea99 commit 3284f24
Showing 1 changed file with 36 additions and 21 deletions.
57 changes: 36 additions & 21 deletions dockerfiles/edx-notes-api.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ FROM ubuntu:focal AS app
# language-pack-en locales; ubuntu locale support so that system utilities have a consistent
# language and time zone.

# python3.8-dev; to install python 3.8
# python3.12-dev; to install python 3.12
# python3-venv; installs venv module required to create virtual environments

# libssl-dev; # mysqlclient wont install without this.
Expand All @@ -17,46 +17,63 @@ FROM ubuntu:focal AS app

# If you add a package here please include a comment above describing what it is used for

# ENV variables for Python 3.12 support
ARG PYTHON_VERSION=3.12
ENV TZ=UTC
ENV TERM=xterm-256color
ENV DEBIAN_FRONTEND=noninteractive

# software-properties-common is needed to setup Python 3.12 env
RUN apt-get update && \
apt-get install -y software-properties-common && \
apt-add-repository -y ppa:deadsnakes/ppa && \
apt-get update && apt-get upgrade -qy && \
apt-get install \
apt-get install -y software-properties-common && \
apt-add-repository -y ppa:deadsnakes/ppa

RUN apt-get update && apt-get -qy install --no-install-recommends \
build-essential \
language-pack-en \
locales \
git \
libmysqlclient-dev \
pkg-config \
libssl-dev \
build-essential \
python3.8-dev \
python3.8-distutils \
python3-virtualenv -qy && \
libffi-dev \
libsqlite3-dev \
libmysqlclient-dev \
git \
curl \
python3-pip \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-dev \
python${PYTHON_VERSION}-distutils && \
rm -rf /var/lib/apt/lists/*

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN ln -s /usr/bin/python3 /usr/bin/python

RUN locale-gen en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8

# need to use virtualenv pypi package with Python 3.12
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION}
RUN pip install virtualenv

# ENV variables lifetime is bound to the container whereas ARGS variables lifetime is bound to the image building process only
# Also ARGS provide us an option of compatibility of Path structure for Tutor and other OpenedX installations
ARG COMMON_CFG_DIR "/edx/etc"
ARG COMMON_CFG_DIR="/edx/etc"
ARG COMMON_APP_DIR="/edx/app"
ARG NOTES_APP_DIR="${COMMON_APP_DIR}/notes"
ARG NOTES_VENV_DIR="${COMMON_APP_DIR}/venvs/notes"

ENV NOTES_APP_DIR=${NOTES_APP_DIR}
ENV PATH="$NOTES_VENV_DIR/bin:$PATH"

RUN useradd -m --shell /bin/false app
WORKDIR ${NOTES_APP_DIR}

# Install curl
RUN apt-get update && apt-get install -y curl
RUN useradd -m --shell /bin/false app

RUN mkdir -p requirements

RUN virtualenv -p python3.8 --always-copy ${NOTES_VENV_DIR}
RUN virtualenv -p python${PYTHON_VERSION} --always-copy ${NOTES_VENV_DIR}

RUN pip install --upgrade pip setuptools

Expand All @@ -66,6 +83,8 @@ RUN curl -L -o requirements/pip.txt https://raw.githubusercontent.com/openedx/ed
RUN pip install --no-cache-dir -r requirements/base.txt
RUN pip install --no-cache-dir -r requirements/pip.txt

RUN curl -L https://github.com/openedx/edx-notes-api/archive/refs/heads/master.tar.gz | tar -xz --strip-components=1

RUN mkdir -p /edx/var/log

EXPOSE 8120
Expand All @@ -77,17 +96,13 @@ ENV DJANGO_SETTINGS_MODULE="notesserver.settings.devstack"
# Backwards compatibility with devstack
RUN touch "${COMMON_APP_DIR}/edx_notes_api_env"

RUN curl -L https://github.com/openedx/edx-notes-api/archive/refs/heads/master.tar.gz | tar -xz --strip-components=1

CMD while true; do python ./manage.py runserver 0.0.0.0:8120; sleep 2; done

Check warning on line 99 in dockerfiles/edx-notes-api.Dockerfile

View workflow job for this annotation

GitHub Actions / push (edx-notes-api, edx notes api, linux/arm64, dev)

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/

FROM app AS production

ENV EDXNOTES_CONFIG_ROOT=/edx/etc
ENV EDXNOTES_CONFIG_ROOT="/edx/etc"
ENV DJANGO_SETTINGS_MODULE="notesserver.settings.yaml_config"

RUN curl -L https://github.com/openedx/edx-notes-api/archive/refs/heads/master.tar.gz | tar -xz --strip-components=1

USER app

# Gunicorn 19 does not log to stdout or stderr by default. Once we are past gunicorn 19, the logging to STDOUT need not be specified.
Expand Down

0 comments on commit 3284f24

Please sign in to comment.