55 lines
1.7 KiB
Docker
55 lines
1.7 KiB
Docker
FROM python:3.14-slim
|
|
|
|
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV UV_LINK_MODE=copy
|
|
|
|
ARG APT_MIRROR=
|
|
ARG PIP_INDEX_URL=
|
|
ARG PIP_TRUSTED_HOST=
|
|
|
|
# Optional Debian apt mirror (host only, e.g. mirror.example.com)
|
|
RUN if [ -n "$APT_MIRROR" ]; then \
|
|
if [ -f /etc/apt/sources.list.d/debian.sources ]; then \
|
|
sed -i "s|deb.debian.org|${APT_MIRROR}|g; s|security.debian.org|${APT_MIRROR}|g" \
|
|
/etc/apt/sources.list.d/debian.sources; \
|
|
fi; \
|
|
if [ -f /etc/apt/sources.list ]; then \
|
|
sed -i "s|deb.debian.org|${APT_MIRROR}|g; s|security.debian.org|${APT_MIRROR}|g" \
|
|
/etc/apt/sources.list; \
|
|
fi; \
|
|
fi
|
|
|
|
# Git is required to fetch the VCS requirement in requirements.txt.
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends git \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Optional PyPI mirror (PIP_* kept for .env compat; mapped to uv only when set)
|
|
ENV PIP_INDEX_URL=${PIP_INDEX_URL}
|
|
ENV PIP_TRUSTED_HOST=${PIP_TRUSTED_HOST}
|
|
|
|
WORKDIR /app
|
|
|
|
# Install dependencies (BuildKit uv cache survives rebuilds)
|
|
COPY requirements.txt .
|
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
if [ -n "$PIP_INDEX_URL" ]; then export UV_DEFAULT_INDEX="$PIP_INDEX_URL"; fi; \
|
|
if [ -n "$PIP_TRUSTED_HOST" ]; then export UV_INSECURE_HOST="$PIP_TRUSTED_HOST"; fi; \
|
|
uv pip install --system -r requirements.txt
|
|
|
|
# Copy project
|
|
COPY . .
|
|
|
|
# Collect static files
|
|
RUN python manage.py collectstatic --noinput
|
|
|
|
# Create data directory for SQLite
|
|
RUN mkdir -p /app/data
|
|
|
|
EXPOSE 8000
|
|
|
|
CMD ["sh", "-c", "python manage.py migrate --noinput && python manage.py seed_products --skip-existing && gunicorn config.wsgi:application --bind 0.0.0.0:8000 --workers 2 --timeout 120"]
|