Open
Conversation
lchojnacki
requested changes
Mar 4, 2025
|
|
||
|
|
||
| # Uruchamiamy aplikację | ||
| CMD ["uv", "run", "manage.py", "runserver", "localhost:8000"] |
Contributor
There was a problem hiding this comment.
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 😄
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.