Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.12-slim-bookworm

COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

COPY . /app

#install the app dependencies (??)
WORKDIR /app


RUN uv sync --frozen --no-cache


# 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 😄