-
Notifications
You must be signed in to change notification settings - Fork 9
/
Dockerfile
34 lines (28 loc) · 906 Bytes
/
Dockerfile
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
# Copyright Pit Kleyersburg <[email protected]>
# SPDX-License-Identifier: MIT OR Apache-2.0
# Stage 0: builder image
FROM rust:latest as builder
COPY . /app
WORKDIR /app
RUN set -ex ;\
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) rustArch='x86_64-unknown-linux-musl' ;; \
armhf) rustArch='armv7-unknown-linux-musleabihf' ;; \
arm64) rustArch='aarch64-unknown-linux-musl' ;; \
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
esac; \
rustup target add "$rustArch" ;\
cargo build --target "$rustArch" --release ;\
cargo test --target "$rustArch" --release -- --nocapture ;\
mv target/"$rustArch"/release/dfw dfw ;\
:
# Stage 1: final image
FROM alpine
RUN apk add --no-cache \
iptables \
ip6tables \
nftables \
;
COPY --from=builder /app/dfw /dfw
ENTRYPOINT ["/dfw"]