membersystem/Dockerfile

48 lines
1.4 KiB
Text
Raw Normal View History

2025-03-21 21:52:08 +01:00
# syntax=docker/dockerfile:1.3-labs
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 \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml <<EOF
mkdir -p /app/src/staticfiles
apk update
apk add --no-cache \
binutils \
libpq-dev \
gettext \
netcat-openbsd \
postgresql-client
# 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
EOF
2024-12-26 00:03:26 +01:00
COPY . .
ENV PATH="/venv/bin:$PATH"
RUN <<EOF
./src/manage.py compilemessages
./src/manage.py collectstatic --noinput
EOF
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"]