-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
64 lines (48 loc) · 2.16 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
FROM ubuntu:24.04 AS base-all
LABEL maintainer='Camptocamp "[email protected]"'
SHELL ["/bin/bash", "-o", "pipefail", "-cux"]
RUN --mount=type=cache,target=/var/lib/apt/lists \
--mount=type=cache,target=/var/cache,sharing=locked \
apt-get update \
&& apt-get upgrade --yes \
&& apt-get install --yes --no-install-recommends apt-utils \
&& DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install --yes tzdata \
&& apt-get install --yes --no-install-recommends binutils git python3-pip python3-venv \
&& python3 -m venv /venv
ENV PATH=/venv/bin:$PATH
# Used to convert the locked packages by poetry to pip requirements format
# We don't directly use `poetry install` because it force to use a virtual environment.
FROM base-all AS poetry
# Install Poetry
WORKDIR /tmp
COPY requirements.txt ./
RUN --mount=type=cache,target=/root/.cache \
python3 -m pip install --disable-pip-version-check --requirement=requirements.txt
# Do the conversion
COPY poetry.lock pyproject.toml ./
ENV POETRY_DYNAMIC_VERSIONING_BYPASS=0.0.0
RUN poetry export --output=requirements.txt \
&& poetry export --with=dev --output=requirements-dev.txt
# Base, the biggest thing is to install the Python packages
FROM base-all AS base
WORKDIR /app
RUN --mount=type=cache,target=/root/.cache \
--mount=type=bind,from=poetry,source=/tmp,target=/poetry \
python3 -m pip install --disable-pip-version-check --no-deps --requirement=/poetry/requirements.txt
FROM base AS checker
RUN --mount=type=cache,target=/root/.cache \
--mount=type=bind,from=poetry,source=/tmp,target=/poetry \
python3 -m pip install --disable-pip-version-check --no-deps --requirement=/poetry/requirements-dev.txt
FROM base AS run
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN python3 -m compileall -q -- *
COPY . ./
ARG VERSION=dev
RUN --mount=type=cache,target=/root/.cache \
POETRY_DYNAMIC_VERSIONING_BYPASS=${VERSION} python3 -m pip install --disable-pip-version-check --no-deps --editable=. \
&& python3 -m pip freeze > /requirements.txt \
&& python3 -m compileall -q /app/c2cciutils
ENV PATH=/root/.local/bin:$PATH
RUN git config --global --add safe.directory /src
WORKDIR /src
VOLUME /src