Skip to content

Commit d6c989b

Browse files
committed
🔧 Update Dockerfile and docker-compose.yml
1 parent d58806d commit d6c989b

2 files changed

Lines changed: 19 additions & 16 deletions

File tree

backend/Dockerfile

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@ FROM python:3.10
22

33
ENV PYTHONUNBUFFERED=1
44

5-
WORKDIR /app/
6-
75
# Install uv
86
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#installing-uv
97
COPY --from=ghcr.io/astral-sh/uv:0.5.11 /uv /uvx /bin/
108

11-
# Place executables in the environment at the front of the path
12-
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#using-the-environment
13-
ENV PATH="/app/.venv/bin:$PATH"
14-
159
# Compile bytecode
1610
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#compiling-bytecode
1711
ENV UV_COMPILE_BYTECODE=1
@@ -20,25 +14,32 @@ ENV UV_COMPILE_BYTECODE=1
2014
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#caching
2115
ENV UV_LINK_MODE=copy
2216

17+
WORKDIR /app/
18+
19+
# Place executables in the environment at the front of the path
20+
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#using-the-environment
21+
ENV PATH="/app/.venv/bin:$PATH"
22+
2323
# Install dependencies
2424
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
2525
RUN --mount=type=cache,target=/root/.cache/uv \
2626
--mount=type=bind,source=uv.lock,target=uv.lock \
2727
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
28-
uv sync --frozen --no-install-project
28+
uv sync --frozen --no-install-workspace --package app
2929

30-
ENV PYTHONPATH=/app
30+
COPY ./backend/scripts /app/backend/scripts
3131

32-
COPY ./scripts /app/scripts
32+
COPY ./backend/pyproject.toml ./backend/alembic.ini /app/backend/
3333

34-
COPY ./pyproject.toml ./uv.lock ./alembic.ini /app/
35-
36-
COPY ./app /app/app
37-
COPY ./tests /app/tests
34+
COPY ./backend/app /app/backend/app
3835

3936
# Sync the project
4037
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
4138
RUN --mount=type=cache,target=/root/.cache/uv \
42-
uv sync
39+
--mount=type=bind,source=uv.lock,target=uv.lock \
40+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
41+
uv sync --frozen --package app
42+
43+
WORKDIR /app/backend/
4344

4445
CMD ["fastapi", "run", "--workers", "4", "app/main.py"]

docker-compose.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ services:
4545
prestart:
4646
image: '${DOCKER_IMAGE_BACKEND?Variable not set}:${TAG-latest}'
4747
build:
48-
context: ./backend
48+
context: .
49+
dockerfile: backend/Dockerfile
4950
networks:
5051
- traefik-public
5152
- default
@@ -115,7 +116,8 @@ services:
115116
retries: 5
116117

117118
build:
118-
context: ./backend
119+
context: .
120+
dockerfile: backend/Dockerfile
119121
labels:
120122
- traefik.enable=true
121123
- traefik.docker.network=traefik-public

0 commit comments

Comments
 (0)