-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
52 lines (41 loc) · 1.22 KB
/
Dockerfile
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
# syntax=docker/dockerfile-upstream:master
ARG RUST_VERSION=1.72.0
FROM lukemathwalker/cargo-chef:latest-rust-${RUST_VERSION}-slim-bullseye AS cargo-chef
WORKDIR /app
FROM cargo-chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM cargo-chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
libpq-dev \
pkg-config \
libssl-dev \
ca-certificates \
wget \
&& rm -rf /var/lib/apt/lists/*
RUN cargo chef cook --profile release --recipe-path recipe.json
COPY . .
RUN cargo build --locked --release
FROM debian:bullseye-slim AS final
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
libpq-dev \
libssl1.1 \
procps \
&& rm -rf /var/lib/apt/lists/*
ARG APP_NAME=pragma-monitoring
ENV APP_NAME $APP_NAME
COPY --from=builder /app/target/release/${APP_NAME} /bin/server
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid 10001 \
appuser
USER appuser
EXPOSE 8080
ENV RUST_LOG=info
CMD ["/bin/server"]