-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.template
69 lines (49 loc) · 1.66 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
67
68
69
# --- build stage
FROM balenalib/%%BALENA_ARCH%%-python:3.11-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-dev \
python3-venv
ENV HOME=/root
# https://forge.rust-lang.org/infra/other-installation-methods.html#rustup
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="$HOME/.cargo/bin:$PATH"
RUN rustc --version
WORKDIR $HOME
ENV VIRTUAL_ENV=$HOME/venv3
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
WORKDIR $HOME/build
# see .dockerignore
COPY . ./
# https://www.balena.io/docs/learn/more/masterclasses/cli-masterclass/#81-build-time-secrets
RUN set -a \
&& . /run/secrets/env \
&& src/tests/run src/tests \
&& rm -rf src/tests
RUN pip3 install --upgrade pip setuptools wheel \
&& pip3 install --upgrade -r requirements.txt
WORKDIR $HOME/build/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 application.py \
&& rm -rf *.py; fi
# --- runtime
FROM balenalib/%%BALENA_ARCH%%-python:3.11
LABEL [email protected]
ENV HOME=/root
ENV VIRTUAL_ENV $HOME/venv3
ENV PATH "$VIRTUAL_ENV/bin:$PATH"
COPY --from=build $HOME/venv3/ $HOME/venv3/
COPY --from=build $HOME/build/ $HOME/build/
WORKDIR $HOME/build/src
CMD ["sh", "-c", "$(uname -m)/application.dist/application || python3 application.py"]