-
Notifications
You must be signed in to change notification settings - Fork 198
Expand file tree
/
Copy pathpeerdb-server.Dockerfile
More file actions
56 lines (49 loc) · 2.19 KB
/
Copy pathpeerdb-server.Dockerfile
File metadata and controls
56 lines (49 loc) · 2.19 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
# syntax=docker/dockerfile:1@sha256:2780b5c3bab67f1f76c781860de469442999ed1a0d7992a5efdf2cffc0e3d769
FROM lukemathwalker/cargo-chef:latest-rust-1.93.0-alpine@sha256:fb285bf1dddc093cca6a6847f9ed6071d69ee1f22eb85c354d6e9697867907d2 AS chef
WORKDIR /root
FROM chef AS planner
COPY nexus nexus
WORKDIR /root/nexus
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
ENV OPENSSL_STATIC=1
ARG BUILD_MODE="release"
RUN apk add --no-cache build-base pkgconfig curl unzip openssl-dev openssl-libs-static
WORKDIR /root/nexus
COPY scripts /root/scripts
RUN /root/scripts/install-protobuf.sh
COPY --from=planner /root/nexus/recipe.json .
ARG CARGO_FLAGS=""
# Build dependencies with cache mounts for Cargo registry and target directory
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/root/nexus/target \
sh -eu -c ' \
if [ "$BUILD_MODE" = "release" ]; then RELEASE_FLAG="--release"; else RELEASE_FLAG=""; fi; \
cargo chef cook $RELEASE_FLAG $CARGO_FLAGS -p peerdb-server --recipe-path recipe.json \
'
COPY nexus /root/nexus
COPY protos /root/protos
WORKDIR /root/nexus
# Build the actual binary with cache mounts
# TODO: switch to --artifact-dir whenever cargo supports it in stable
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/root/nexus/target \
sh -eu -c ' \
if [ "$BUILD_MODE" = "release" ]; then RELEASE_FLAG="--release"; else RELEASE_FLAG=""; fi; \
cargo build $RELEASE_FLAG $CARGO_FLAGS --bin peerdb-server \
' && \
mkdir -p /root/target && \
cp target/${BUILD_MODE}/peerdb-server /root/target/
FROM alpine:3.23@sha256:25109184c71bdad752c8312a8623239686a9a2071e8825f20acb8f2198c3f659
ENV TZ=UTC
RUN apk add --no-cache ca-certificates postgresql-client curl iputils && \
adduser -s /bin/sh -D peerdb && \
install -d -m 0755 -o peerdb /var/log/peerdb
USER peerdb
WORKDIR /home/peerdb
COPY --from=builder --chown=peerdb /root/target/peerdb-server ./peerdb-server
ARG PEERDB_VERSION_SHA_SHORT
ENV PEERDB_VERSION_SHA_SHORT=${PEERDB_VERSION_SHA_SHORT}
ENTRYPOINT ["./peerdb-server"]