website/Dockerfile

37 lines
1.3 KiB
Text
Raw Normal View History

2025-01-30 15:12:50 +01:00
FROM python:3.13-slim
EXPOSE 8000
WORKDIR /app
ENV PATH="/app/.venv/bin:$PATH"
ENV STATIC_ROOT=/app/staticfiles
ENV MEDIA_ROOT=/app/mediafiles
2025-01-30 17:55:43 +01:00
# Install system dependencies including Caddy
RUN apt-get update && apt-get install -y \
debian-keyring \
debian-archive-keyring \
apt-transport-https \
curl \
&& curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg \
&& curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list \
&& apt-get update \
2025-01-30 18:06:18 +01:00
&& apt-get install -y caddy procps \
2025-01-30 17:55:43 +01:00
&& rm -rf /var/lib/apt/lists/*
2025-01-30 17:43:15 +01:00
# Install binaries with correct permissions
COPY --from=ghcr.io/astral-sh/uv:latest --chown=root:root --chmod=755 /uv /usr/local/bin/uv
COPY --chmod=755 docker/run.sh /usr/local/bin/runhub.sh
2025-01-30 15:12:50 +01:00
2025-01-30 17:15:36 +01:00
COPY docker/Caddyfile /app/config/caddy/Caddyfile
2025-01-30 15:12:50 +01:00
ADD . /app
RUN uv sync --frozen \
&& uv pip install gunicorn --no-cache-dir \
2025-01-30 17:43:15 +01:00
&& mkdir -p /app/config/caddy /app/run/caddy /app/run/gunicorn \
&& chgrp -R 0 /app \
&& chmod -R g=u /app \
&& chmod g+w /app/config/caddy/Caddyfile \
2025-01-30 15:12:50 +01:00
&& SECRET_KEY= python -m hub collectstatic --noinput
2025-01-30 17:43:15 +01:00
CMD ["/usr/local/bin/runhub.sh"]