Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
198 lines (170 loc) · 8.55 KB
/
Copy pathDockerfile
File metadata and controls
198 lines (170 loc) · 8.55 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
FROM alpine:3.23 AS builder
ARG LIBUECC_VERSION=v7
ARG FASTD_VERSION=v23
ARG FIRMWARE_REPO=https://github.com/Freifunk-Dresden/firmware-freifunk-dresden.git
ARG FIRMWARE_TAG=T_FIRMWARE_8.2.0
RUN apk add --no-cache \
bison \
build-base \
cmake \
git \
json-c-dev \
libcap-dev \
libsodium-dev \
linux-headers \
meson \
ninja \
nodejs \
npm \
openssl-dev \
pkgconf
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
WORKDIR /build
RUN git clone --branch "$LIBUECC_VERSION" --depth 1 https://github.com/neocturne/libuecc.git
RUN cmake -S /build/libuecc -B /build/libuecc-build \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local \
&& cmake --build /build/libuecc-build \
&& cmake --install /build/libuecc-build
RUN git clone --branch "$FASTD_VERSION" --depth 1 https://github.com/neocturne/fastd.git
COPY patches/fastd-urandom.patch /tmp/fastd-urandom.patch
COPY patches/fastd-log-format.patch /tmp/fastd-log-format.patch
COPY patches/fastd-close-fds.patch /tmp/fastd-close-fds.patch
RUN patch -d /build/fastd -p1 < /tmp/fastd-urandom.patch
RUN patch -d /build/fastd -p1 < /tmp/fastd-log-format.patch
RUN patch -d /build/fastd -p1 < /tmp/fastd-close-fds.patch
RUN meson setup /build/fastd-build /build/fastd \
-Dbuildtype=release \
-Dbuild_tests=false \
-Doffload_l2tp=disabled \
&& meson compile -C /build/fastd-build \
&& meson install -C /build/fastd-build
RUN git clone --branch "$FIRMWARE_TAG" --depth 1 "$FIRMWARE_REPO" /build/firmware
RUN test -f /build/firmware/feeds/pool/bmxd/sources/Makefile
COPY patches/bmxd-msghdr-init.patch /tmp/bmxd-msghdr-init.patch
RUN patch -d /build/firmware/feeds/pool/bmxd/sources -p1 < /tmp/bmxd-msghdr-init.patch
COPY patches/bmxd-interface-debug-buffer.patch /tmp/bmxd-interface-debug-buffer.patch
RUN patch -d /build/firmware/feeds/pool/bmxd/sources -p1 < /tmp/bmxd-interface-debug-buffer.patch
RUN make -C /build/firmware/feeds/pool/bmxd/sources clean all
WORKDIR /build/ui
COPY ui/package.json /build/ui/package.json
COPY ui/package-lock.json /build/ui/package-lock.json
COPY ui/tsconfig.json /build/ui/tsconfig.json
COPY ui/vite.config.ts /build/ui/vite.config.ts
COPY ui/index.html /build/ui/index.html
COPY ui/src/ /build/ui/src/
COPY ui/tests/ /build/ui/tests/
RUN npm ci --no-audit --no-fund
RUN npm test && npx tsc --noEmit && npm run build
FROM alpine:3.23 AS staging
# Assemble the complete filesystem layout in /staging
RUN mkdir -p \
/staging/data \
/staging/etc/nginx \
/staging/etc/service \
/staging/run/freifunk/fastd/peers \
/staging/run/freifunk/wireguard \
/staging/run/freifunk/bmxd \
/staging/run/freifunk/sysinfo \
/staging/run/freifunk/www \
/staging/usr/bin \
/staging/usr/lib/bmxd \
/staging/usr/lib/fastd \
/staging/usr/local/bin \
/staging/usr/local/lib \
/staging/usr/local/share/freifunk/ui
# Binaries from builder (only what we need)
COPY --from=builder /usr/local/bin/fastd /staging/usr/local/bin/
COPY --from=builder /usr/local/lib/libuecc.so* /staging/usr/local/lib/
COPY --from=builder /build/firmware/feeds/pool/bmxd/sources/bmxd /staging/usr/bin/
# UI build output
COPY --from=builder /build/ui/dist/ /staging/usr/local/share/freifunk/ui/
# License texts
COPY --from=builder /build/firmware/files/common/usr/lib/license/agreement-de.txt /staging/usr/local/share/freifunk/
COPY --from=builder /build/firmware/files/common/usr/lib/license/pico-de.txt /staging/usr/local/share/freifunk/
COPY --from=builder /build/firmware/license/gpl2-en.txt /staging/usr/local/share/freifunk/gpl2.txt
COPY --from=builder /build/firmware/license/gpl3-en.txt /staging/usr/local/share/freifunk/gpl3.txt
# Config files
COPY config/defaults.yaml /staging/usr/local/share/freifunk/defaults.yaml
COPY config/ca-root-ffdd.crt /staging/usr/local/share/freifunk/ca-root-ffdd.crt
COPY config/nginx.conf /staging/etc/nginx/nginx.conf
# Scripts
COPY scripts/backbone_runtime.py scripts/mesh-status.py scripts/node_config.py scripts/system_resources.py scripts/statistics_history.py scripts/statistics_collector.py scripts/exit_config.py scripts/exit_runtime.py scripts/exit_service.py scripts/exit_dns.py scripts/exit_observation.py scripts/exit_traffic.py scripts/gateway_role.py scripts/gateway_init.py scripts/gateway_store.py scripts/gateway_api.py scripts/gateway_health.py scripts/gateway_runtime.py scripts/gateway_fastd.py scripts/gateway_control.py scripts/gateway_admin.py scripts/uplink_routes.py scripts/lan_mesh_access.py scripts/node_identity.py scripts/mesh_interfaces.py scripts/mesh_firewall.py scripts/registration_tls.py scripts/registrar.py scripts/sysinfo.py scripts/wireguard_status.py /staging/usr/local/bin/
COPY scripts/fastd-backbone-cmd.sh /staging/usr/lib/fastd/backbone-cmd.sh
COPY scripts/bmxd-launcher.sh /staging/usr/local/bin/bmxd-launcher.sh
COPY scripts/bmxd-gateway.py /staging/usr/lib/bmxd/bmxd-gateway.py
COPY scripts/docker-entrypoint.sh /staging/usr/local/bin/docker-entrypoint.sh
COPY scripts/runit/ /staging/etc/service/
RUN chmod +x \
/staging/usr/local/bin/docker-entrypoint.sh \
/staging/usr/local/bin/mesh-status.py \
/staging/usr/local/bin/registrar.py \
/staging/usr/local/bin/sysinfo.py \
/staging/usr/local/bin/wireguard_status.py \
/staging/usr/lib/fastd/backbone-cmd.sh \
/staging/usr/local/bin/bmxd-launcher.sh \
/staging/usr/lib/bmxd/bmxd-gateway.py \
/staging/etc/service/registrar/run \
/staging/etc/service/sysinfo/run \
/staging/etc/service/statistics/run \
/staging/etc/service/exits/run \
/staging/etc/service/exit-dns/run \
/staging/etc/service/gateway-api/run \
/staging/etc/service/gateway-runtime/run \
/staging/etc/service/gateway-control/run \
/staging/etc/service/fastd/run \
/staging/etc/service/wireguard/run \
/staging/etc/service/bmxd/run \
/staging/etc/service/mesh-status/run \
/staging/etc/service/nginx/run
FROM staging AS tests
RUN apk add --no-cache py3-yaml python3 tzdata
COPY scripts/docker-entrypoint.sh scripts/backbone_runtime.py scripts/bmxd-gateway.py scripts/mesh-status.py scripts/node_config.py scripts/system_resources.py scripts/statistics_history.py scripts/statistics_collector.py scripts/exit_config.py scripts/exit_runtime.py scripts/exit_service.py scripts/exit_dns.py scripts/exit_observation.py scripts/exit_traffic.py scripts/gateway_role.py scripts/gateway_init.py scripts/gateway_store.py scripts/gateway_api.py scripts/gateway_health.py scripts/gateway_runtime.py scripts/gateway_fastd.py scripts/gateway_control.py scripts/gateway_admin.py scripts/uplink_routes.py scripts/lan_mesh_access.py scripts/node_identity.py scripts/mesh_interfaces.py scripts/mesh_firewall.py scripts/registration_tls.py scripts/registrar.py scripts/run_gateway_script.py scripts/sysinfo.py scripts/wireguard_status.py /opt/freifunk-tests/scripts/
COPY tests/ /opt/freifunk-tests/tests/
COPY config/ca-root-ffdd.crt /opt/freifunk-tests/config/ca-root-ffdd.crt
COPY scripts/fastd-backbone-cmd.sh /opt/freifunk-tests/scripts/fastd-backbone-cmd.sh
COPY scripts/runit/fastd/run /opt/freifunk-tests/scripts/runit/fastd/run
RUN cd /opt/freifunk-tests \
&& python3 -m unittest discover -v -s tests -t .
FROM alpine:3.23 AS final
ENV TZ=Europe/Berlin
# Image execution is known to be container-scoped, even with private cgroup
# namespaces and serviceLinks disabled. Native Python execution may use auto/host.
ENV SYSINFO_RESOURCE_SCOPE=container
RUN apk add --no-cache \
bash \
bridge-utils \
dnsmasq \
iproute2 \
iptables \
iputils \
json-c \
libcap \
libsodium \
nginx \
openssl \
py3-yaml \
python3 \
runit \
tcpdump \
tzdata \
wireguard-tools-wg \
&& ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime \
&& echo "$TZ" > /etc/timezone
# Single COPY from staging: all freifunk files in one layer
COPY --from=tests /staging/ /
# Identity belongs to the built image, not runtime environment or its host checkout.
# Keep these args late so a new revision reuses dependency/UI/test build caches.
ARG BUILD_REF_TYPE
ARG BUILD_REF
ARG BUILD_COMMIT
ARG BUILD_VERSION
LABEL org.opencontainers.image.revision=$BUILD_COMMIT \
org.opencontainers.image.version=$BUILD_VERSION \
org.opencontainers.image.ref.name=$BUILD_REF
RUN python3 -c 'import json,sys; from pathlib import Path; Path("/usr/local/share/freifunk/build-identity.json").write_text(json.dumps(dict(zip(("ref_type", "ref", "commit", "version"), sys.argv[1:])))+"\n")' \
"$BUILD_REF_TYPE" "$BUILD_REF" "$BUILD_COMMIT" "$BUILD_VERSION"
VOLUME ["/data"]
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD []