-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.release
More file actions
72 lines (51 loc) · 1.54 KB
/
Dockerfile.release
File metadata and controls
72 lines (51 loc) · 1.54 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
FROM node:22-alpine AS console-builder
WORKDIR /build/console
COPY console/package.json console/pnpm-lock.yaml ./
RUN corepack enable && pnpm install --frozen-lockfile
COPY console/ ./
RUN pnpm build
FROM ghcr.io/rust-cross/cargo-zigbuild:latest AS builder
ARG TARGET
ENV TARGET=${TARGET}
RUN apt-get update && apt-get install -y \
build-essential \
wget \
pkg-config \
ca-certificates \
flex \
bison \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /tmp
RUN wget https://www.tcpdump.org/release/libpcap-1.10.4.tar.gz \
&& tar xf libpcap-1.10.4.tar.gz
ENV PKG_CONFIG_ALL_STATIC=1
ENV ac_cv_func_malloc_0_nonnull=yes
ENV PKG_CONFIG_SYSROOT_DIR=/
SHELL ["/bin/bash", "-c"]
RUN cd /tmp/libpcap-1.10.4 \
&& make clean || true \
&& export ZIG_TARGET=$(echo ${TARGET} | sed -e 's/-unknown//' -e 's/armv7/arm/') \
&& CC="zig cc -target ${ZIG_TARGET}" \
CFLAGS="-O2" \
LDFLAGS="" \
./configure \
--host=${ZIG_TARGET} \
--disable-shared \
--prefix=/opt/libpcap \
&& make -j$(nproc) \
&& make install
ENV PKG_CONFIG_PATH=/opt/libpcap/lib/pkgconfig
WORKDIR /build
COPY daemon/Cargo.toml ./daemon/
WORKDIR /build/daemon
RUN mkdir src && echo "fn main(){}" > src/main.rs
RUN rustup target add ${TARGET}
RUN cargo zigbuild --release --target ${TARGET} || true
# Real build
COPY daemon/ ./
COPY --from=console-builder /build/console/build ../console/build
RUN mkdir /out
RUN cargo zigbuild --release --target ${TARGET} \
&& cp target/${TARGET}/release/foxd /out/foxd
FROM scratch
COPY --from=builder /out/foxd /foxd