Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add codejail service #85

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/push-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ on:
- xqueue
- portal designer
- license manager
- codejail
branch:
description: "Target branch from which the source dockerfile from image will be sourced"
default: "main"
Expand Down
91 changes: 91 additions & 0 deletions dockerfiles/codejail.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Usage:
#
# - Listens on port 8080 internally
# - Set environment variable `DJANGO_SETTINGS_MODULE`, e.g. to
# `codejail_service.settings.production` or `codejail_service.settings.devstack`
# - Override arg `VERSION` to a commit hash or a branch

FROM ubuntu:noble AS app

ARG GITHUB_REPO=openedx/codejail-service

# This should be overridden with a commit hash to ensure we always get
# a coherent result, even if things are changing on a branch as the
# image is being built.
#
# Must use the full 40-character hash when specifying a commit hash.
ARG VERSION=main

# Python version
ARG PYVER=3.12

# Packages installed:
#
# - language-pack-en, locales: Ubuntu locale support so that system utilities
# have a consistent language and time zone.
# - python*: A specific version of Python
# - python*-dev: Header files for python extensions, required by many source wheels
# - python*-venv: Allow creation of virtualenvs
RUN <<EOF
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install \
--quiet --yes --no-install-recommends \
language-pack-en locales \
python${PYVER} python${PYVER}-dev python${PYVER}-venv
# If you add a package, please add a comment above explaining why it is needed!
rm -rf /var/lib/apt/lists/*
EOF

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

WORKDIR /app

# We'll build the virtualenv and pre-compile Python as root, but switch to user
# `app` for actually running the application.
RUN useradd -m --shell /bin/false app

# Unpack the repo directly from GitHub, since this image is not built
# from inside the application repo.
#
# Start with getting just the requirements files so that code changes
# do not bust the image cache and require rebuilding the virtualenv.
ADD https://github.com/${GITHUB_REPO}.git#${VERSION}:requirements requirements

RUN <<EOF
python${PYVER} -m venv /venv
/venv/bin/pip install -r /app/requirements/pip.txt
/venv/bin/pip install -r /app/requirements/pip-tools.txt
EOF

EXPOSE 8080


FROM app AS dev

RUN /venv/bin/pip-sync requirements/dev.txt
RUN python${PYVER} -m compileall /venv

# After the requirements so changes to the code will not bust the image cache
timmc-edx marked this conversation as resolved.
Show resolved Hide resolved
ADD https://github.com/${GITHUB_REPO}.git#${VERSION} .
RUN python${PYVER} -m compileall /app

USER app
CMD echo $PATH; while true; do /venv/bin/python ./manage.py runserver 0.0.0.0:8080; sleep 2; done


FROM app AS prod

RUN /venv/bin/pip-sync requirements/base.txt
RUN python${PYVER} -m compileall /venv

# After the requirements so changes to the code will not bust the image cache
timmc-edx marked this conversation as resolved.
Show resolved Hide resolved
ADD https://github.com/${GITHUB_REPO}.git#${VERSION} .
RUN python${PYVER} -m compileall /app

USER app
CMD /venv/bin/gunicorn -c /app/codejail_service/docker_gunicorn_configuration.py \
--bind '0.0.0.0:8080' --workers=2 --max-requests=1000 --name codejail \
codejail_service.wsgi:application
6 changes: 6 additions & 0 deletions images-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,11 @@
"name": "license manager",
"os_platform": "linux/amd64,linux/arm64",
"target": "dev"
},
{
"image_name": "codejail",
"name": "codejail",
"os_platform": "linux/amd64,linux/arm64",
"target": "dev"
}
]