-
Notifications
You must be signed in to change notification settings - Fork 9
/
Dockerfile
55 lines (36 loc) · 1.48 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
ARG deps="python3 libpq procps-ng diffutils"
ARG devDeps="python3-devel postgresql-devel gcc"
FROM registry.access.redhat.com/ubi9/ubi-minimal AS build
# Add application sources to a directory that the assemble script expects them
# and set permissions so that the container runs without root access
USER 0
ARG devDeps
RUN microdnf install -y $devDeps && \
pip3 install virtualenv && \
mkdir -p /opt/app-root && \
chown 1001:0 /opt/app-root
WORKDIR /opt/app-root
COPY app.py pyproject.toml setup.cfg requirements.txt ./
COPY src ./src
RUN virtualenv . && \
bin/pip install --upgrade pip && \
bin/pip install -r requirements.txt . && \
rm -rf \~
FROM registry.access.redhat.com/ubi9/ubi-minimal AS base
USER 0
ARG deps
ENV deps=${deps}
WORKDIR /opt/app-root
COPY --chown=1001:0 --from=build /opt/app-root /opt/app-root
RUN rpm -qa --qf '%{NAME}\n' | sort > /opt/basepackages && \
microdnf install -y $deps && \
rpm -qa --qf '%{NAME}\n' | sort | diff /opt/basepackages - | grep -Po '(?<=> )(.*)' > /opt/installedpackages && \
rm /opt/basepackages && \
chown 1001:0 /opt/app-root
USER 1001
ENV PATH="/opt/app-root/bin:$PATH"
# Set the default command for the resulting image
CMD python ./app.py
FROM base AS test
ADD tests/test_* tests/floorplan_* tests/requirements.txt ./tests/
RUN pip install --no-cache-dir -r tests/requirements.txt