forked from torizon/vscode-torizon-templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
84 lines (66 loc) · 2.74 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
ARG CROSS_SDK_BASE_TAG=3.3.0-bookworm
ARG BASE_VERSION=3.3.0-bookworm
##
# Board architecture
# arm or arm64
##
ARG IMAGE_ARCH=
##
# Directory of the application inside container
##
ARG APP_ROOT=
# BUILD ------------------------------------------------------------------------
FROM torizon/debian-cross-toolchain-${IMAGE_ARCH}:${CROSS_SDK_BASE_TAG} As Build
ARG APP_ROOT
ARG IMAGE_ARCH
# __deps__
RUN apt-get -q -y update && \
apt-get -q -y install \
cmake \
# DO NOT REMOVE THIS LABEL: this is used for VS Code automation
# __torizon_packages_dev_start__
# __torizon_packages_dev_end__
# DO NOT REMOVE THIS LABEL: this is used for VS Code automation
&& \
apt-get clean && apt-get autoremove && \
rm -rf /var/lib/apt/lists/*
# __deps__
COPY . ${APP_ROOT}
WORKDIR ${APP_ROOT}
# Remove the code from the debug builds, inside this container, to build the
# release version from a clean build
RUN rm -rf ${APP_ROOT}/build-${IMAGE_ARCH}
RUN if [ "$IMAGE_ARCH" = "arm64" ] ; then \
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -Bbuild-${IMAGE_ARCH} ; \
elif [ "$IMAGE_ARCH" = "arm" ] ; then \
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc -Bbuild-${IMAGE_ARCH} ; \
fi
RUN cmake --build build-${IMAGE_ARCH}
# BUILD ------------------------------------------------------------------------
##
# Deploy Step
#
# This is using commontorizon/debian only by the ease of the use of the
# same image tags for x86_64 architectures:
# - AMD64 -> torizon/debian-upstream:3 == commontorizon/debian:3.3.0-bookworm
# - ARM64 -> torizon/debian:3 == commontorizon/debian:3.3.0-bookworm
# - ARM -> torizon/debian:3 == commontorizon/debian:3.3.0-bookworm
##
FROM --platform=linux/${IMAGE_ARCH} commontorizon/debian:${BASE_VERSION} AS Deploy
ARG IMAGE_ARCH
ARG APP_ROOT
RUN apt-get -y update && apt-get install -y --no-install-recommends \
# DO NOT REMOVE THIS LABEL: this is used for VS Code automation
# __torizon_packages_prod_start__
# __torizon_packages_prod_end__
# DO NOT REMOVE THIS LABEL: this is used for VS Code automation
&& apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/*
# Copy the application compiled in the build step to the $APP_ROOT directory
# path inside the container, where $APP_ROOT is the torizon_app_root
# configuration defined in settings.json
COPY --from=Build ${APP_ROOT}/build-${IMAGE_ARCH}/bin ${APP_ROOT}
# "cd" (enter) into the APP_ROOT directory
WORKDIR ${APP_ROOT}
# Command executed in runtime when the container starts
CMD ["./__change__"]
# DEPLOY -----------------------------------------------------------------------