-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.container
30 lines (27 loc) · 1.21 KB
/
Dockerfile.container
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
ARG BUILDKIT_SBOM_SCAN_CONTEXT=true
FROM --platform=$BUILDPLATFORM tonistiigi/xx@sha256:0c6a569797744e45955f39d4f7538ac344bfb7ebf0a54006a0a4297b153ccf0f AS xx
ARG TARGETPLATFORM
FROM --platform=$BUILDPLATFORM rust:alpine@sha256:9ab8f4eab808b1383c7e60a15fbf291e949fec85c3f98c34fb145b16c4ced0a1 AS builder
ARG BUILDKIT_SBOM_SCAN_CONTEXT=true
RUN apk add clang lld openssl-dev curl bash
# copy xx scripts to your build stage
COPY --from=xx / /
ARG TARGETPLATFORM
RUN xx-apk add --no-cache musl-dev zlib-dev zlib-static openssl-dev openssl-libs-static pkgconfig alpine-sdk
WORKDIR /app
RUN cargo new --lib whatismyip
WORKDIR /app/whatismyip
COPY Cargo.* ./
RUN xx-cargo build --release --target-dir ./build
COPY . ./
RUN xx-cargo build --release --target-dir ./build && \
xx-verify --static "./build/$(xx-cargo --print-target-triple)/release/whatismyip" && \
cp -v "./build/$(xx-cargo --print-target-triple)/release/whatismyip" "./build/whatismyip"
RUN addgroup -g 568 nonroot
RUN adduser -u 568 -G nonroot -D nonroot
FROM scratch
COPY --from=builder "/app/whatismyip/build/whatismyip" /
COPY --from=builder /etc/group /etc/group
COPY --from=builder /etc/passwd /etc/passwd
RUN ["/whatismyip", "--version"]
ENTRYPOINT ["/whatismyip"]