2024-12-25 23:03:26 +00: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 19:51:09 +00:00
|
|
|
ARG BUILD
|
2024-07-31 21:48:39 +00:00
|
|
|
ENV BUILD=${BUILD}
|
2024-12-25 23:03:26 +00:00
|
|
|
ARG DJANGO_ENV=production
|
2021-02-09 21:04:02 +00:00
|
|
|
|
2024-03-03 10:05:08 +00:00
|
|
|
WORKDIR /app
|
|
|
|
|
2024-12-25 23:03:26 +00: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-07-31 21:48:39 +00:00
|
|
|
|
2024-12-25 23:03:26 +00:00
|
|
|
COPY . .
|
|
|
|
ENV PATH="/venv/bin:$PATH"
|
|
|
|
RUN <<EOF
|
|
|
|
./src/manage.py compilemessages
|
|
|
|
./src/manage.py collectstatic --noinput
|
|
|
|
EOF
|
2021-02-09 21:04:02 +00:00
|
|
|
|
2024-12-25 23:03:26 +00:00
|
|
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
2021-03-01 16:49:37 +00:00
|
|
|
|
2021-03-01 20:44:57 +00:00
|
|
|
EXPOSE 8000
|
|
|
|
|
2021-03-01 16:49:37 +00:00
|
|
|
CMD ["uvicorn", "project.asgi:application", "--host", "0.0.0.0", "--port", "8000", "--workers", "3", "--lifespan", "off", "--app-dir", "/app/src"]
|