-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
165 lines (138 loc) · 5.47 KB
/
Dockerfile
File metadata and controls
165 lines (138 loc) · 5.47 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
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
RUN patch -d /build/fastd -p1 < /tmp/fastd-urandom.patch
RUN patch -d /build/fastd -p1 < /tmp/fastd-log-format.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
RUN make -C /build/firmware/feeds/pool/bmxd/sources clean all
WORKDIR /build/ui
COPY ui/package.json /build/ui/package.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/
RUN npm install --no-audit --no-fund
RUN 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/nginx.conf /staging/etc/nginx/nginx.conf
# Scripts
COPY scripts/backbone_runtime.py scripts/mesh-status.py scripts/node_config.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/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
COPY scripts/backbone_runtime.py scripts/bmxd-gateway.py scripts/mesh-status.py scripts/node_config.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/
RUN cd /opt/freifunk-tests \
&& python3 -m unittest discover -v -s tests -t .
FROM alpine:3.23 AS final
ENV TZ=Europe/Berlin
RUN apk add --no-cache \
bash \
bridge-utils \
iproute2 \
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/ /
VOLUME ["/data"]
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD []