-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (41 loc) · 1.35 KB
/
Dockerfile
File metadata and controls
60 lines (41 loc) · 1.35 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
FROM --platform=$BUILDPLATFORM alpine:latest AS certs
RUN apk add --no-cache ca-certificates
FROM --platform=$BUILDPLATFORM rust:alpine AS builder
ARG TARGETARCH
WORKDIR /app
RUN apk add --no-cache \
build-base \
perl \
zig
RUN cargo install cargo-zigbuild --locked
RUN rustup target add \
x86_64-unknown-linux-musl \
aarch64-unknown-linux-musl \
riscv64gc-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY src ./src
COPY schema ./schema
RUN set -eux; \
case "$TARGETARCH" in \
amd64) target="x86_64-unknown-linux-musl" ;; \
arm64) target="aarch64-unknown-linux-musl" ;; \
riscv64) target="riscv64gc-unknown-linux-musl" ;; \
*) echo "unsupported TARGETARCH=$TARGETARCH" >&2; exit 1 ;; \
esac; \
RUSTFLAGS="-C target-feature=+crt-static" \
cargo zigbuild --release --locked --target "$target"; \
mkdir -p /out; \
cp "target/$target/release/subcon" /out/subcon
FROM --platform=$TARGETPLATFORM alpine:latest AS runtime-base
WORKDIR /app
COPY --from=certs /etc/ssl/certs/ /etc/ssl/certs/
COPY example/conf ./conf
COPY schema ./schema
EXPOSE 25500
ENTRYPOINT ["/usr/local/bin/subcon"]
CMD ["--pref", "conf/pref.toml"]
FROM runtime-base AS runtime-prebuilt
ARG BIN_PATH=dist/subcon
COPY ${BIN_PATH} /usr/local/bin/subcon
FROM runtime-base AS runtime
COPY --from=builder /out/subcon /usr/local/bin/subcon