2023-01-23 01:20:30 +00:00
|
|
|
# Build stage
|
|
|
|
FROM --platform=linux/i386 alpine:latest AS build
|
2022-06-30 19:30:24 +00:00
|
|
|
|
2023-01-23 01:20:30 +00:00
|
|
|
# Install dependencies
|
|
|
|
RUN apk add --no-cache cmake ninja g++ linux-headers binutils
|
2022-06-30 19:30:24 +00:00
|
|
|
|
2023-01-23 01:20:30 +00:00
|
|
|
# Copy source files
|
2022-07-03 14:27:48 +00:00
|
|
|
COPY . /wibo
|
2022-06-30 19:30:24 +00:00
|
|
|
|
2023-01-23 01:20:30 +00:00
|
|
|
# Build static binary
|
2023-01-23 15:36:14 +00:00
|
|
|
RUN cmake -S /wibo -B /wibo/build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-static" \
|
2023-01-23 01:20:30 +00:00
|
|
|
&& cmake --build /wibo/build \
|
|
|
|
&& strip -g /wibo/build/wibo
|
2022-06-30 19:30:24 +00:00
|
|
|
|
2023-01-23 01:20:30 +00:00
|
|
|
# Export binary (usage: docker build --target export --output build .)
|
|
|
|
FROM scratch AS export
|
|
|
|
COPY --from=build /wibo/build/wibo .
|
2022-06-30 19:30:24 +00:00
|
|
|
|
2023-01-23 01:20:30 +00:00
|
|
|
# Runnable container
|
|
|
|
FROM alpine:latest
|
2022-07-06 11:03:19 +00:00
|
|
|
COPY --from=build /wibo/build/wibo /usr/local/sbin/wibo
|
2022-06-30 19:30:24 +00:00
|
|
|
CMD /usr/local/sbin/wibo
|