-
Notifications
You must be signed in to change notification settings - Fork 25
/
Dockerfile
182 lines (152 loc) · 5.23 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# ARGUMENTS --------------------------------------------------------------------
##
# Board architecture
##
ARG IMAGE_ARCH=
##
# Base container version
##
ARG BASE_VERSION=3.3.1
##
# Directory of the application inside container
##
ARG APP_ROOT=
##
# Board GPU vendor prefix
##
ARG GPU=
# ARGUMENTS --------------------------------------------------------------------
# BUILD ------------------------------------------------------------------------
FROM --platform=linux/${IMAGE_ARCH} \
commontorizon/wayland-base${GPU}:${BASE_VERSION} AS build
ARG IMAGE_ARCH
ARG GPU
ARG APP_ROOT
# stick to bookworm on /etc/apt/sources.list.d
RUN sed -i 's/sid/bookworm/g' /etc/apt/sources.list.d/debian.sources
# for vivante GPU we need some "special" sauce
RUN apt-get -q -y update && \
if [ "${GPU}" = "-vivante" ] || [ "${GPU}" = "-imx8" ]; then \
apt-get -q -y install \
imx-gpu-viv-wayland-dev \
; else \
apt-get -q -y install \
libgl1 \
; fi \
&& \
apt-get clean && apt-get autoremove && \
rm -rf /var/lib/apt/lists/*
# Install required packages
RUN apt-get -q -y update && \
apt-get -q -y install \
gcc \
g++ \
make \
git \
libatspi2.0-0 \
libgconf-2-4 \
libglib2.0-bin \
libgtk2.0-0 \
libgtk-3-0 \
libnotify4 \
libnss3 \
libuuid1 \
libxcb-dri3-0 \
xdg-utils \
libxss1 \
libxtst6 \
libasound2 \
curl \
# DO NOT REMOVE THIS LABEL: this is used for VS Code automation
# __torizon_packages_build_start__
# __torizon_packages_build_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/*
# install the latest node js
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs
RUN npm config set registry https://registry.npmjs.org/
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}/out
RUN npm install
# build the application
RUN if [ "${IMAGE_ARCH}" = "arm64" ]; then \
npx electron-forge package -a arm64 -p linux; \
elif [ "${IMAGE_ARCH}" = "arm" ]; then \
npx electron-forge package -a armv7l -p linux; \
else \
npx electron-forge package -a x86 -p linux; \
fi;
# Copy the EGL lib inside the project's directory for vivante GPU
RUN if [ "${GPU}" = "-vivante" ] || [ "${GPU}" = "-imx8" ]; then \
cp /usr/lib/aarch64-linux-gnu/libEGL.so ${APP_ROOT}/out/__change__-linux-${IMAGE_ARCH} && \
cp /usr/lib/aarch64-linux-gnu/libGLESv2.so ${APP_ROOT}/out/__change__-linux-${IMAGE_ARCH}; \
# If it is a armv7l, this renames the output directory with the name expected by the Deploy fase
elif [ "${IMAGE_ARCH}" = "arm" ]; then \
mv ${APP_ROOT}/out/__change__-linux-armv7l ${APP_ROOT}/out/__change__-linux-${IMAGE_ARCH}; \
fi;
# BUILD ------------------------------------------------------------------------
# DEPLOY -----------------------------------------------------------------------
FROM --platform=linux/${IMAGE_ARCH} \
commontorizon/wayland-base${GPU}:${BASE_VERSION} AS deploy
ARG IMAGE_ARCH
ARG GPU
ARG APP_ROOT
# stick to bookworm on /etc/apt/sources.list.d
RUN sed -i 's/sid/bookworm/g' /etc/apt/sources.list.d/debian.sources
# for vivante GPU we need some "special" sauce
RUN apt-get -q -y update && \
if [ "${GPU}" = "-vivante" ] || [ "${GPU}" = "-imx8" ]; then \
apt-get -q -y install \
imx-gpu-viv-wayland-dev \
; else \
apt-get -q -y install \
libgl1 \
; fi \
&& \
apt-get clean && apt-get autoremove && \
rm -rf /var/lib/apt/lists/*
# your regular RUN statements here
# Install required packages
RUN apt-get -q -y update && \
apt-get -q -y install \
libatspi2.0-0 \
libgconf-2-4 \
libglib2.0-bin \
libgtk2.0-0 \
libgtk-3-0 \
libnotify4 \
libnss3 \
libuuid1 \
libxcb-dri3-0 \
xdg-utils \
libxss1 \
libxtst6 \
libasound2 \
curl \
# 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/*
# install the latest node js
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs
# 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}/out/__change__-linux-${IMAGE_ARCH} ${APP_ROOT}
# "cd" (enter) into the APP_ROOT directory
WORKDIR ${APP_ROOT}
# Command executed in runtime when the container starts
# FIX: In this template arm32 is not working properly with egl, so if you are
# using an arm32 remove the "--use-gl=egl" and "--in-process-gpu" arguments.
CMD [ "./__change__", "--no-sandbox", "--ozone-platform=wayland", "--use-gl=egl", "--in-process-gpu" ]
# DEPLOY -----------------------------------------------------------------------