forked from wisespace-io/yubico-rs
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.static
More file actions
41 lines (30 loc) · 867 Bytes
/
Dockerfile.static
File metadata and controls
41 lines (30 loc) · 867 Bytes
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
# Change to build a different example, like otp_async
ARG EXAMPLE=otp
FROM rust:alpine as base
ARG EXAMPLE
RUN apk --no-cache add \
git \
gcc \
g++ \
openssl-dev \
openssl-libs-static \
pkgconfig
COPY . /src
WORKDIR /src
# Force a static binary
ENV RUSTFLAGS="-C target-feature=+crt-static"
# Ensure OpenSSL is linked statically
ENV OPENSSL_STATIC=1 \
PKG_CONFIG_ALLOW_CROSS=1 \
PKG_CONFIG_ALL_STATIC=1
RUN cargo build \
--release \
--target=x86_64-unknown-linux-musl \
--example "${EXAMPLE}"
FROM scratch
ARG EXAMPLE
COPY --from=base "/src/target/x86_64-unknown-linux-musl/release/examples/${EXAMPLE}" /otp
# Copy the ca-certificates.crt from base so certificates can be validated
COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
ENV RUST_BACKTRACE=1
ENTRYPOINT [ "/otp" ]