Files
voyage/backend/Dockerfile
alex wiesner 7a53cc2cc7
Some checks failed
Upload latest backend image to GHCR / upload (push) Failing after 2m45s
Test Backend / Build and Test Backend (push) Failing after 2m3s
Upload latest frontend image to GHCR / upload (push) Failing after 13s
Test Frontend / Build and Test Frontend (push) Successful in 10m51s
Trivy Security Scans / Trivy Filesystem Scan (Source Code) (push) Failing after 1m43s
Trivy Security Scans / Trivy Docker Image Scan (Backend & Frontend) (push) Failing after 27s
reduce production image size without runtime drift
2026-03-16 15:07:36 +00:00

68 lines
2.2 KiB
Docker

ARG PYTHON_IMAGE=python:3.13-slim
FROM ${PYTHON_IMAGE} AS builder
LABEL maintainer="Voyage contributors" \
version="0.10.0" \
description="Voyage — the ultimate self-hosted travel companion." \
org.opencontainers.image.title="Voyage" \
org.opencontainers.image.description="Voyage helps you plan, track, and share your adventures." \
org.opencontainers.image.version="0.10.0" \
org.opencontainers.image.authors="Voyage contributors" \
org.opencontainers.image.source="https://github.com/Alex-Wiesner/voyage" \
org.opencontainers.image.vendor="Voyage contributors" \
org.opencontainers.image.licenses="GPL-3.0"
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
DEBIAN_FRONTEND=noninteractive \
VIRTUAL_ENV=/opt/venv
WORKDIR /code
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libgdal-dev \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
COPY ./server/requirements.txt /tmp/requirements.txt
RUN python -m venv "$VIRTUAL_ENV" \
&& "$VIRTUAL_ENV/bin/pip" install --upgrade pip \
&& "$VIRTUAL_ENV/bin/pip" install --no-cache-dir --no-compile --prefer-binary -r /tmp/requirements.txt \
&& find "$VIRTUAL_ENV" \( -type d -name '__pycache__' -o -type d -name 'tests' \) -prune -exec rm -rf '{}' + \
&& find "$VIRTUAL_ENV" -type f \( -name '*.pyc' -o -name '*.pyo' \) -delete
FROM ${PYTHON_IMAGE}
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
DEBIAN_FRONTEND=noninteractive \
VIRTUAL_ENV=/opt/venv
WORKDIR /code
RUN apt-get update && apt-get install -y --no-install-recommends \
libgdal36 \
nginx \
memcached \
supervisor \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /opt/venv /opt/venv
COPY ./server /code/
COPY ./nginx.conf /etc/nginx/nginx.conf
COPY ./supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY ./entrypoint.sh /code/entrypoint.sh
RUN chmod +x /code/entrypoint.sh \
&& mkdir -p /code/static /code/media
RUN "$VIRTUAL_ENV/bin/python" manage.py collectstatic --noinput --verbosity 2
EXPOSE 80 8000
ENTRYPOINT ["/code/entrypoint.sh"]
CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]