Skip to content

Conversation

@justgruba
Copy link
Contributor

No description provided.



# Uruchamiamy aplikację
CMD ["uv", "run", "manage.py", "runserver", "localhost:8000"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Czy ten Dockerfile jest takim do developmentu, czy produkcyjnym? Jeśli produkcyjny, to brakuje mu kilku rzeczy, m.in. multi stage build.

Tak wygląda produkcyjny Dockerfile dla dermawet-edu, wzorowany na oficjalnym dockerfile uv:

# First, build the application in the `/app` directory.
FROM ghcr.io/astral-sh/uv:0.5.18-python3.12-bookworm-slim AS builder
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy UV_SYSTEM_PYTHON=true
WORKDIR /app
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 \
    uv sync --frozen --no-install-project --no-group dev --group prod
COPY . /app

# Then, use a final image without uv
FROM python:3.12-slim-bookworm

# Copy the application from the builder
COPY --from=builder --chown=app:app /app /app

# Place executables in the environment at the front of the path
ENV PATH="/app/.venv/bin:$PATH"
WORKDIR /app
# Run the Django application by default
CMD ["gunicorn", "config.wsgi:application", "--bind", "0.0.0.0:8000"]

Jeśli coś nie będzie tu jasne, to większość odpowiedzi znajdziesz pewnie po hasłem "multi stage build" oraz w dokumentacji UV 🙂 a gdyby nadal coś Cię nurtowało, to służę pomocą.

Dodatkowo, w zadaniu jest też info o docker compose - może być w oddzielnym PR, ale nie zapomnij o nim 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants