-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDockerfile
66 lines (49 loc) · 1.83 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
FROM python:3.9-slim as builder
# install dependencies required to build python packages
RUN apt-get update
# setup venv
ENV VENV="/venv"
ENV PATH="${VENV}/bin:${PATH}"
# copy build dependencies
COPY opnsense_cli/__init__.py /app/opnsense_cli/__init__.py
COPY MANIFEST.in /app/MANIFEST.in
COPY README.md /app/README.md
COPY setup.py /app/setup.py
COPY requirements.txt /app/requirements.txt
COPY test_requirements.txt /app/test_requirements.txt
WORKDIR /app
# install dependencies into builder venv
RUN python -m venv ${VENV} && ${VENV}/bin/pip3 install --upgrade pip setuptools wheel
RUN ${VENV}/bin/pip3 install --no-cache-dir -r requirements.txt
RUN ${VENV}/bin/pip3 install --no-cache-dir -r test_requirements.txt
FROM python:3.9-slim as app
RUN apt-get update \
# some comfort...
&& apt-get install -y procps net-tools vim htop \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get autoremove -y \
&& apt-get clean -y
# copy dependencies from the builder stage
ENV VENV="/venv"
ENV PATH="${VENV}/bin:$PATH"
COPY --from=builder ${VENV} ${VENV}
# copy app files
COPY opnsense_cli /app/opnsense_cli
COPY ./acceptance_tests /app/acceptance_tests
COPY ./scripts /app/scripts
COPY MANIFEST.in /app/MANIFEST.in
COPY README.md /app/README.md
COPY .coveragerc /app/.coveragerc
COPY setup.py /app/setup.py
# Creates a non-root user and adds permission to access the /app folder
RUN addgroup --system appgroup && useradd appuser -g appgroup -m && chown -R appuser:appgroup /app
COPY docker/.opn-cli/conf.yaml /home/appuser/.opn-cli/conf.yaml
COPY docker/.opn-cli/ca.pem /home/appuser/.opn-cli/ca.pem
WORKDIR /app
# install app
RUN python -m venv ${VENV} && ${VENV}/bin/pip3 install --upgrade --no-cache-dir .
COPY requirements.txt /app/requirements.txt
COPY test_requirements.txt /app/test_requirements.txt
# run app
USER appuser
ENTRYPOINT ["opn-cli"]