-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.server
More file actions
93 lines (63 loc) · 2.53 KB
/
Dockerfile.server
File metadata and controls
93 lines (63 loc) · 2.53 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Dockerfile for cf-speedtest-server
# Base image
ARG RUST_BASE_IMAGE=1.94.0-alpine3.23
# Image METADATA
ARG IMAGE_BUILD_DATE=1970-01-01T00:00:00+00:00
ARG IMAGE_VCS_REF=00000000
# The version of `cf-speedtest-server`
ARG VERSION="0.0.0"
# Non-root user and group IDs
ARG UID=65532
ARG GID=65532
# Proxy settings
ARG http_proxy=""
ARG https_proxy=""
FROM rust:${RUST_BASE_IMAGE} AS chef
ARG http_proxy
ARG https_proxy
RUN cargo install cargo-chef --locked
WORKDIR /app
FROM chef AS planner
ARG http_proxy
ARG https_proxy
COPY . .
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \
--mount=type=cache,target=/usr/local/cargo/git,sharing=locked \
cargo chef prepare --recipe-path recipe.json
FROM chef as builder
ARG http_proxy
ARG https_proxy
COPY --from=planner /app/recipe.json recipe.json
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \
--mount=type=cache,target=/usr/local/cargo/git,sharing=locked \
cargo chef cook --release --recipe-path recipe.json
RUN set -e && \
apk --no-cache add \
git=2.52.0-r0
COPY . .
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \
--mount=type=cache,target=/usr/local/cargo/git,sharing=locked \
cargo build --release --package cf-speedtest-server --target x86_64-unknown-linux-musl
FROM scratch
ARG IMAGE_BUILD_DATE
ARG IMAGE_VCS_REF
ARG VERSION
ARG UID
ARG GID
# OCI labels for image metadata
LABEL description="Distroless Image for cf-speedtest-server" \
org.opencontainers.image.created=${IMAGE_BUILD_DATE} \
org.opencontainers.image.authors="Hantong Chen <public-service@7rs.net>" \
org.opencontainers.image.url="https://github.com/hanyu-dev/cf-speedtest-server" \
org.opencontainers.image.documentation="https://github.com/hanyu-dev/cf-speedtest-server/blob/main/README.md" \
org.opencontainers.image.source="https://github.com/hanyu-dev/cf-speedtest-server" \
org.opencontainers.image.version=${VERSION}+image.${IMAGE_VCS_REF} \
org.opencontainers.image.vendor="Hantong Chen" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.title="Distroless Image for cf-speedtest-server" \
org.opencontainers.image.description="Distroless Image for cf-speedtest-server"
COPY --from=builder --chown="${UID}:${GID}" --chmod=775 /app/target/x86_64-unknown-linux-musl/release/cf-speedtest-server /opt/cf-speedtest-server/cf-speedtest-server
WORKDIR /opt/cf-speedtest-server
STOPSIGNAL SIGQUIT
USER ${UID}:${GID}
ENTRYPOINT ["/opt/cf-speedtest-server/cf-speedtest-server"]