forked from GRA0007/crab.fit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
33 lines (24 loc) · 950 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
31
32
33
# This dockerfile builds the API and runs it on a minimal container with the Datastore adaptor
FROM rust:bookworm as builder
# Install CA Certs for Hyper
RUN apt-get install -y --no-install-recommends ca-certificates
RUN update-ca-certificates
WORKDIR /usr/src/app
COPY . .
# Will build and cache the binary and dependent crates in release mode
RUN --mount=type=cache,target=/usr/local/cargo,from=rust:latest,source=/usr/local/cargo \
--mount=type=cache,target=target \
cargo build --release --features sql-adaptor && mv ./target/release/crabfit-api ./api
# Runtime image
FROM debian:bookworm-slim
RUN apt-get update; apt-get install -y openssl
# Run as "app" user
RUN useradd -ms /bin/bash app
USER app
WORKDIR /app
# Get compiled binaries from builder's cargo install directory
COPY --from=builder /usr/src/app/api /app/api
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# Run the app
EXPOSE 3000
CMD ./api