-
Notifications
You must be signed in to change notification settings - Fork 24
/
Dockerfile-runtime
54 lines (44 loc) · 1.72 KB
/
Dockerfile-runtime
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
##### Build stage
FROM --platform=linux/amd64 python:3.11.4-slim-bullseye as base
ENV TIMEOUT=900
# Copy relevant files
COPY ./runtime/pipt_locks.env /app/pipt_locks.env
COPY ./runtime/pipt_config.env /app/pipt_config.env
COPY ./runtime/requirements-base.txt /app/requirements-base.txt
COPY ./runtime/requirements.txt /app/requirements.txt
COPY ./runtime/requirements-dev.txt /app/requirements-dev.txt
COPY ./runtime/pipt /app/pipt
COPY ./hdctl /hdctl
RUN apt-get -y update && apt-get -y install libpq-dev gcc libsnappy-dev && apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /app
ENV PIPT_PIP_INSTALL_ARGS "--no-cache-dir"
ENV PIPT_PIP_SYNC_PIP_ARGS "--no-cache-dir --no-deps"
RUN ./pipt sync-system --prod
##### Intermediate stage with actual application content
FROM base AS application_base
COPY ./runtime /app
COPY ./VERSION /app/VERSION
RUN chmod +x /app/start.sh
RUN mkdir -p /mnt/obj_repo
RUN chmod -R a+rw /mnt/obj_repo
RUN mkdir -p /mnt/autoimport
RUN chmod -R a+rw /mnt/autoimport
##### Production stage
# making prod stage available early allows to build it without building test stage
# since test stage is only necessary on build system
FROM application_base AS prod
RUN useradd -m hd_app
USER hd_app
ENV PORT 8090
EXPOSE 8090
CMD ["/app/start.sh"]
##### Test stage
FROM application_base AS test
RUN ./pipt sync-system --dev
RUN python3 -m pytest --cov=hetdesrun --cov-report xml --junitxml test_results.xml tests
RUN bash /app/scripts/gen_ruff_report.sh
# prod should still be the default build, this is why we close with FROM prod
# Note that in order to really skip building the test stage you need to explicitly specify
# the prod stage via
# docker build --target prod -f Dockerfile-runtime . -t hetdesrun_webservice
FROM prod