-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
62 lines (41 loc) · 1.67 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Ideas from https://docs.astral.sh/uv/guides/integration/docker/
FROM python:3.12-bullseye AS builder-base
ARG PROJECT_VERSION
# Install dependencies for the `psql` command.
# Must match the version of the postgres service in the compose file!
RUN apt-get update \
&& apt-get install --no-install-recommends -y postgresql-common \
&& /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y \
&& apt-get install --no-install-recommends -y \
postgresql-client-17 \
&& rm -rf /var/lib/apt/lists/*
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
COPY --from=ghcr.io/astral-sh/uv:0.6.3 /uv /uvx /bin/
ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy
# There is no git during image build so we need to provide a fake version
ENV UV_DYNAMIC_VERSIONING_BYPASS=0.0.0
ENV PATH="/app/.venv/bin:$PATH"
WORKDIR /app
# development image
FROM builder-base AS development
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 client
RUN playwright install --with-deps chromium
ADD . /app
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen
ENV PROJECT_VERSION=${PROJECT_VERSION}
# production image
FROM builder-base AS production
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-dev --no-group client
ADD . /app
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev --no-group client
ENV PROJECT_VERSION=${PROJECT_VERSION}