Skip to content

Commit 1773e7c

Browse files
committed
help me
1 parent 18ad917 commit 1773e7c

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

apps/backend/Dockerfile

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,44 @@
1-
FROM ghcr.io/astral-sh/uv:latest
1+
# Use a Python image with uv pre-installed
2+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
23

4+
# Install the project into `/app`
35
WORKDIR /app
46

5-
# Копируем все файлы проекта сразу
6-
COPY . .
7+
# Enable bytecode compilation
8+
ENV UV_COMPILE_BYTECODE=1
79

8-
# Устанавливаем зависимости
9-
RUN uv sync --no-dev
10+
# Copy from the cache instead of linking since it's a mounted volume
11+
ENV UV_LINK_MODE=copy
1012

13+
# Ensure installed tools can be executed out of the box
14+
ENV UV_TOOL_BIN_DIR=/usr/local/bin
15+
16+
# Install the project's dependencies using the lockfile and settings
17+
RUN --mount=type=cache,target=/root/.cache/uv \
18+
--mount=type=bind,source=uv.lock,target=uv.lock \
19+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
20+
uv sync --locked --no-install-project --no-dev
21+
22+
# Then, add the rest of the project source code and install it
23+
# Installing separately from its dependencies allows optimal layer caching
24+
COPY . /app
25+
RUN --mount=type=cache,target=/root/.cache/uv \
26+
uv sync --locked --no-dev
27+
28+
# Place executables in the environment at the front of the path
1129
ENV PATH="/app/.venv/bin:$PATH"
1230

13-
EXPOSE 8000
31+
# Reset the entrypoint, don't invoke `uv`
32+
ENTRYPOINT []
1433

15-
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
34+
# Run the FastAPI application by default
35+
# Uses `fastapi dev` to enable hot-reloading when the `watch` sync occurs
36+
# Uses `--host 0.0.0.0` to allow access from outside the container
37+
CMD ["uvicorn", "main:app", \
38+
"--host", "0.0.0.0", \
39+
"--port", "8000", \
40+
"--workers", "1", \
41+
"--limit-concurrency", "100", \
42+
"--limit-max-requests", "1000", \
43+
"--timeout-keep-alive", "5", \
44+
"--access-log"]

0 commit comments

Comments
 (0)