forked from Polyfrost/backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
30 lines (21 loc) · 867 Bytes
/
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
FROM rustlang/rust:nightly-alpine AS chef
USER root
RUN apk add --no-cache g++
RUN cargo install cargo-chef
WORKDIR /app
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN cargo build --release --locked --all-features --bin polyfrost-api
# ---------------------------------------------------------------------------------------------
FROM alpine:3
COPY --from=builder /app/target/release/polyfrost-api /usr/local/bin/polyfrost-api
# Use an unprivileged user
RUN adduser --home /nonexistent --no-create-home --disabled-password polyfrost-api
USER polyfrost-api
HEALTHCHECK --interval=10s --timeout=3s --retries=5 CMD wget --spider --q http://localhost:$PORT/ || exit 1
CMD ["polyfrost-api"]