membersystem/Dockerfile

45 lines
1.4 KiB
Text
Raw Permalink Normal View History

2025-03-21 21:53:22 +01:00
# syntax=docker/dockerfile:1
2024-12-26 00:03:26 +01:00
FROM ghcr.io/astral-sh/uv:python3.12-alpine
# - Silence uv complaining about not being able to use hard links,
# - tell uv to byte-compile packages for faster application startups,
# - prevent uv from accidentally downloading isolated Python builds,
# - pick a Python,
# - and finally declare `/app` as the target for `uv sync`.
ENV UV_LINK_MODE=copy \
UV_COMPILE_BYTECODE=1 \
UV_PYTHON_DOWNLOADS=never \
UV_PYTHON=python3.12 \
UV_PROJECT_ENVIRONMENT=/venv
2022-11-21 20:51:09 +01:00
ARG BUILD
ENV BUILD=${BUILD}
2024-12-26 00:03:26 +01:00
ARG DJANGO_ENV=production
2024-03-03 11:05:08 +01:00
WORKDIR /app
2024-12-26 00:03:26 +01:00
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
2025-03-21 21:56:09 +01:00
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
mkdir -p /app/src/staticfiles & \
apk update & \
2024-12-26 00:03:26 +01:00
apk add --no-cache \
binutils \
libpq-dev \
gettext \
netcat-openbsd \
2025-03-21 21:56:09 +01:00
postgresql-client & \
2024-12-26 00:03:26 +01:00
# run uv sync --no-dev if $DJANGO_ENV is production, otherwise run uv sync
if [ "$DJANGO_ENV" = "production" ]; then uv sync --frozen --no-install-project --no-dev; else uv sync --frozen --no-install-project; fi
2024-12-26 00:03:26 +01:00
COPY . .
ENV PATH="/venv/bin:$PATH"
2025-03-21 21:56:09 +01:00
RUN ./src/manage.py compilemessages & \
./src/manage.py collectstatic --noinput
2024-12-26 00:03:26 +01:00
ENTRYPOINT ["/app/entrypoint.sh"]
2021-03-01 21:44:57 +01:00
EXPOSE 8000
CMD ["uvicorn", "project.asgi:application", "--host", "0.0.0.0", "--port", "8000", "--workers", "3", "--lifespan", "off", "--app-dir", "/app/src"]