-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (30 loc) · 1.3 KB
/
Copy pathDockerfile
File metadata and controls
40 lines (30 loc) · 1.3 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
# Start with a Rust base image
FROM rust:1.90-bullseye AS builder
ARG PROFILE=release
WORKDIR work
COPY ./crates ./crates
COPY ./Cargo.toml ./Cargo.lock ./
ARG GIT_REVISION
ENV GIT_REVISION=$GIT_REVISION
# BuildKit cargo cache mounts: registry/git/target persist on the mp3
# stateful-pool PVC across commits. Cache-mount contents aren't committed to
# the image layer, so copy the binary out to a stable path in the same RUN.
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \
--mount=type=cache,target=/usr/local/cargo/git,sharing=locked \
--mount=type=cache,target=/work/target,sharing=locked \
cargo build --bin key-server --profile $PROFILE --config net.git-fetch-with-cli=true \
&& cp /work/target/release/key-server /work/key-server
FROM debian:bullseye-slim AS runtime
EXPOSE 2024
RUN apt-get update && apt-get install -y cmake clang libpq5 ca-certificates libpq-dev postgresql
COPY --from=builder /work/key-server /opt/key-server/bin/
# Handle all environment variables
RUN echo '#!/bin/bash\n\
# Export all environment variables\n\
for var in $(env | cut -d= -f1); do\n\
export "$var"\n\
done\n\
\n\
exec /opt/key-server/bin/key-server "$@"' > /opt/key-server/entrypoint.sh && \
chmod +x /opt/key-server/entrypoint.sh
ENTRYPOINT ["/opt/key-server/entrypoint.sh"]