-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
68 lines (49 loc) · 1.19 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
63
64
65
66
67
68
# syntax=docker/dockerfile:1.9
ARG python_version=3.12.6
FROM python:$python_version AS build
ENV UV_LINK_MODE=copy
ENV UV_PROJECT_ENVIRONMENT=/app
COPY --from=ghcr.io/astral-sh/uv:0.4.18 /uv /bin/uv
COPY pyproject.toml /_lock/
COPY uv.lock /_lock/
RUN --mount=type=cache,target=/root/.cache <<EOT
cd /_lock
uv sync \
--frozen \
--no-dev \
--no-install-project
EOT
COPY pyproject.toml uv.lock /src/
COPY src /src/src
COPY tests /src/tests
RUN --mount=type=cache,target=/root/.cache \
uv pip install \
--python=$UV_PROJECT_ENVIRONMENT \
--no-deps \
/src
FROM build AS test
ENV UV_LINK_MODE=copy
ENV UV_PROJECT_ENVIRONMENT=/app
RUN --mount=type=cache,target=/root/.cache <<EOT
cd /_lock
uv sync \
--frozen \
--no-install-project \
--extra test
EOT
RUN --mount=type=cache,target=/root/.cache <<EOT
cd /src
uv pip install \
--python=$UV_PROJECT_ENVIRONMENT \
--no-deps \
.[test]
EOT
ENV PYTHONUNBUFFERED=1
WORKDIR /src
CMD ["/app/bin/python", "-m", "pytest"]
FROM python:$python_version AS bot
COPY --from=build /app /app
ENV PATH=/app/bin:$PATH
ENV PYTHONUNBUFFERED=1
RUN umask 111 && touch apod.log
CMD ["ananas", "/config/ananas.cfg"]