Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
201 lines (152 loc) · 6.32 KB
/
Copy pathDockerfile
File metadata and controls
201 lines (152 loc) · 6.32 KB
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#syntax=docker/dockerfile:1.12.1
# #############################################################################
# #############################################################################
# Base image
# https://hub.docker.com/_/ubuntu
ARG VERSION="24.04"
# -----------------------------------------------------------------------------
# Options
# 0 builds the normal image, 1 the slim one. Slim leaves out wine entirely:
# no winehq, no prefix, ~2.9G smaller.
ARG SLIM_BUILD="0"
# Where the Wine prefix lives. Empty means /home/${USERNAME}/.wine
ARG WINEPREFIX=""
# Name of the unprivileged user the image runs as.
ARG USERNAME="tedi"
FROM ubuntu:${VERSION} AS base
# #############################################################################
# #############################################################################
# arm-none-eabi
FROM base AS arm-none-eabi_builder
# https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads
ARG ARM_NANO_EABI_VERSION=14.2.rel1
WORKDIR /workdir
RUN \
apt-get update && \
apt-get install --yes --no-install-recommends wget ca-certificates xz-utils && \
rm -rf /var/lib/apt/lists/*
ARG TARGETARCH
RUN set -eux; \
case "${TARGETARCH}" in \
amd64) ARCH="x86_64" ;; \
arm64) ARCH="aarch64" ;; \
*) echo "Unsupported architecture: ${TARGETARCH}" >&2; exit 1 ;; \
esac; \
wget -qO- "https://developer.arm.com/-/media/Files/downloads/gnu/${ARM_NANO_EABI_VERSION}/binrel/arm-gnu-toolchain-${ARM_NANO_EABI_VERSION}-${ARCH}-arm-none-eabi.tar.xz" \
| tar -xJ --strip-components=1; \
rm -rf share/man share/info; \
find share/doc -type f ! -iname '*license*' ! -iname '*copying*' -delete; \
find share/doc -type d -empty -delete
# #############################################################################
# #############################################################################
# Production image, slim: everything except wine
FROM base AS slim
# -----------------------------------------------------------------------------
# Packages to install
ARG PACKAGES="sudo bash wget curl git ca-certificates \
build-essential bc file \
cmake clang \
cpputest pahole ccache valgrind dos2unix \
gdb-multiarch bear lcov gcovr \
astyle \
python3 python3-pip python3-venv \
clang-format clang-tidy \
shellcheck cppcheck cflow pmccabe \
doxygen graphviz \
clangd \
ripgrep fd-find nano pandoc \
iproute2 iputils-ping dnsutils net-tools \
unzip"
RUN \
apt-get update && \
apt-get install --yes --no-install-recommends ${PACKAGES} && \
rm -rf /var/lib/apt/lists/*
# -----------------------------------------------------------------------------
# cpputest
ENV CPPUTEST_HOME="/usr/"
# -----------------------------------------------------------------------------
# arm-none-eabi
COPY --from=arm-none-eabi_builder /workdir /arm-none-eabi
ENV PATH=/arm-none-eabi/bin/:${PATH}
# -----------------------------------------------------------------------------
# USER
ARG USERNAME
# Rename default user
RUN usermod -l ${USERNAME} ubuntu && \
groupmod -n ${USERNAME} ubuntu && \
usermod -d /home/${USERNAME} -m ${USERNAME}
RUN echo "${USERNAME} ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/${USERNAME}
USER ${USERNAME}
ENV TERM=linux
# -----------------------------------------------------------------------------
# uv
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ENV PATH=/home/${USERNAME}/.local/bin:${PATH}
# Python linter/formatter
RUN uv tool install ruff
# -----------------------------------------------------------------------------
# rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --no-modify-path --profile minimal -c clippy,rustfmt,rust-analyzer,rust-src
ENV PATH=/home/${USERNAME}/.cargo/bin:${PATH}
# -----------------------------------------------------------------------------
# bun
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH=/home/${USERNAME}/.bun/bin:${PATH}
# -----------------------------------------------------------------------------
# Startup
WORKDIR /workspace
ENTRYPOINT ["/bin/bash", "-l", "-c"]
CMD ["/bin/bash", "-i"]
# #############################################################################
# #############################################################################
# Production image, normal: slim plus wine
FROM slim AS normal
ARG USERNAME
USER root
RUN \
. /etc/os-release && \
dpkg --add-architecture i386 && \
mkdir -p /etc/apt/keyrings && \
wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key && \
echo "deb [signed-by=/etc/apt/keyrings/winehq-archive.key] https://dl.winehq.org/wine-builds/ubuntu/ ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/winehq.list && \
apt-get update && \
apt-get install --yes --no-install-recommends winehq-stable && \
rm -rf /var/lib/apt/lists/*
ENV PATH=/opt/wine-stable/bin/:${PATH}
USER ${USERNAME}
# Wine environment variables for headless operation
ENV WINEDEBUG=-all
ENV DISPLAY=:0
ENV XDG_RUNTIME_DIR=/tmp
ARG WINEPREFIX
ENV WINEPREFIX="${WINEPREFIX:-/home/${USERNAME}/.wine}"
# Create the Wine prefix (virtual Windows environment)
RUN wineboot --init
# #############################################################################
# #############################################################################
# Pick the one SLIM_BUILD asks for. Only the selected stage gets built.
FROM normal AS devtools-0
FROM slim AS devtools-1
FROM devtools-${SLIM_BUILD} AS devtools
# #############################################################################
# #############################################################################
# Smoke test: every tool must answer. Last stage, so it always runs.
FROM devtools AS smoke
ARG SLIM_BUILD
RUN set -eux; \
for tool in \
gcc g++ cmake clang clang-format clang-tidy clangd \
arm-none-eabi-gcc gdb-multiarch \
shellcheck cppcheck cflow valgrind ccache astyle \
bear lcov gcovr doxygen pandoc \
rg fdfind git \
python3 uv ruff \
rustc cargo rustfmt rust-analyzer \
bun \
; do "$tool" --version > /dev/null; done; \
cargo clippy --version > /dev/null; \
pmccabe -V < /dev/null > /dev/null; \
dot -V; \
test -f /usr/include/CppUTest/TestHarness.h; \
[ "${SLIM_BUILD}" = "1" ] || wine --version > /dev/null