-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.template
66 lines (44 loc) · 1.34 KB
/
Dockerfile.template
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
# --- build stage
FROM balenalib/%%BALENA_ARCH%%-python:3.10-build AS build
LABEL [email protected]
# https://www.balena.io/docs/learn/more/masterclasses/cli-masterclass/#82-build-time-variables
ARG COMPILE_CODE
RUN install_packages \
cmake \
python3-venv
WORKDIR /root
ENV VIRTUAL_ENV=/root/venv3
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
COPY requirements.txt .
RUN pip3 install --upgrade pip setuptools wheel \
&& pip3 install --upgrade -r requirements.txt
WORKDIR /root/build/src
COPY src .
RUN if [ "$COMPILE_CODE" = '1' ]; then \
install_packages ccache \
&& pip3 install --upgrade \
nuitka \
ordered-set \
patchelf \
&& nuitka3 \
--remove-output \
--assume-yes-for-downloads \
--output-dir=$(uname -m) \
--plugin-enable=pylint-warnings \
--standalone dnsserver.py; fi
# --- runtime
FROM balenalib/%%BALENA_ARCH%%-python:3.10
LABEL [email protected]
ENV VIRTUAL_ENV /root/venv3
ENV PATH "$VIRTUAL_ENV/bin:$PATH"
COPY --from=build /root/venv3/ /root/venv3/
COPY --from=build /root/build/ /root/build/
RUN install_packages \
curl \
dnsutils \
jq \
net-tools
WORKDIR /root/build/src
RUN if [ "$COMPILE_CODE" = '1' ]; then rm -f *.{py,txt}; fi
CMD ["sh", "-c", "$(uname -m)/dnsserver.dist/dnsserver || python3 dnsserver.py"]