-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
45 lines (30 loc) · 1.07 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
ARG BUILDPLATFORM=linux/amd64
ARG BUILDTAG=3-alpine
FROM --platform=$BUILDPLATFORM python:$BUILDTAG as test
WORKDIR /home/user/app
ENV PATH=$PATH:/home/user/.local/bin
RUN pip install --no-cache poetry poethepoet
RUN poetry config --no-cache
COPY pyproject.toml .
COPY poetry.lock .
RUN poetry install --no-root
COPY ./ ./
RUN poetry install
ARG TESTBUILD=True
ENV TESTBUILD=$TESTBUILD
RUN if [ "$TESTBUILD" = 'True' ]; then poe lint; fi
RUN if [ "$TESTBUILD" = 'True' ]; then poe test; fi
RUN poetry build --format=wheel
RUN poetry export --only main -f requirements.txt --without-hashes --output requirements.txt
ENTRYPOINT ["poe", "-q"]
CMD ["test"]
FROM --platform=$BUILDPLATFORM python:$BUILDTAG as prod
RUN addgroup --system user && adduser --system user --ingroup user
USER user
WORKDIR /home/user/app
COPY --chown=user:user --from=test /home/user/app/requirements.txt requirements.txt
COPY --chown=user:user --from=test /home/user/app/dist dist
USER root
RUN pip install --no-cache -r requirements.txt dist/*.whl
USER user
ENTRYPOINT ["python", "-m", "pkgtst.pkgtst"]