Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/node_modules
**/.venv
**/.tox
**/.coverage
**/*.egg-info
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install tox
run: pip install tox
run: uv tool install tox

- name: Run tests
run: tox
run: uv run --extra=dev tox
env:
TOXENV: py312

Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ server/logs/
src/WebCompatManager.egg-info/
build/
dist/
uv.lock

# Code coverage
.coverage*
Expand Down
37 changes: 5 additions & 32 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,56 +8,29 @@ WORKDIR /src
RUN npm install
RUN npm run production

FROM python:3.12-alpine AS backend
FROM ghcr.io/astral-sh/uv:python3.12-alpine AS backend

RUN apk add --no-cache build-base git mariadb-dev && pip install tomli

# Install dependencies before copying src, so pip is only run when needed
# Also install build dependencies that are otherwise missed in wheel cache
# (from pyproject.toml [build-system].requires)
COPY ./requirements.txt ./pyproject.toml /src/
RUN cd /src && \
python -c "import tomli; from itertools import chain; pyp=tomli.load(open('pyproject.toml','rb')); deps=pyp['project']['dependencies']; extras=pyp['project']['optional-dependencies']; print('\0'.join(chain(deps, extras['docker'], extras['server'])))" | xargs -0 pip wheel -q -c requirements.txt --wheel-dir /var/cache/wheels && \
pip wheel -q --wheel-dir /var/cache/wheels wheel setuptools_scm[toml]

FROM python:3.12-alpine
RUN apk add --no-cache build-base git mariadb-dev

RUN adduser -D worker && \
apk add --no-cache bash git mariadb-client mariadb-connector-c openssh-client-default && \
pip install tomli && \
rm -rf /var/log/*

COPY --from=backend /var/cache/wheels /var/cache/wheels

COPY ./requirements.txt ./pyproject.toml /src/
USER worker
RUN cd /src && \
python -c "import tomli; from itertools import chain; pyp=tomli.load(open('pyproject.toml','rb')); deps=pyp['project']['dependencies']; extras=pyp['project']['optional-dependencies']; print('\0'.join(chain(deps, extras['docker'], extras['server'])))" | xargs -0 pip install --no-cache-dir --no-index --find-links /var/cache/wheels -q -c requirements.txt

# Embed full source code
USER root
COPY . /src/
RUN cd /src && uv sync --locked --extra=server --extra=docker

# Retrieve previous Javascript build
COPY --from=frontend /src/dist/ /src/server/frontend/dist/
RUN mkdir -p /data/fuzzing-tc-config && chown -R worker:worker /src /data/fuzzing-tc-config

# Install FM
# Note: the extras must be duplicated above in the Python
# script to pre-install dependencies.
USER worker
ENV PATH="${PATH}:/home/worker/.local/bin"
RUN pip install --no-cache-dir --no-index --find-links /var/cache/wheels --no-deps -q /src[docker,server]

# Use a custom settings file that can be overwritten
ENV DJANGO_SETTINGS_MODULE="server.settings_docker"

WORKDIR /src/server

# Collect staticfiles, including Vue.js build
RUN python manage.py collectstatic --no-input
RUN uv run --extra=server --extra=docker manage.py collectstatic --no-input

# Run with gunicorn, using container's port 80
ENV PORT=80
EXPOSE 80
CMD ["gunicorn", "--bind", "0.0.0.0:80", "--error-logfile", "-", "--access-logfile", "-", "--capture-output", "server.wsgi"]
CMD ["uv", "run", "--extra", "server", "--extra", "docker", "gunicorn", "--bind", "0.0.0.0:80", "--error-logfile", "-", "--access-logfile", "-", "--capture-output", "server.wsgi"]
176 changes: 0 additions & 176 deletions requirements.txt

This file was deleted.

Loading