Set up dockerfile, and handle SIGINT signals
This commit is contained in:
parent
f78d762999
commit
65619653c6
4 changed files with 41 additions and 3 deletions
31
api/Dockerfile
Normal file
31
api/Dockerfile
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# This dockerfile builds the API and runs it on a minimal container with the Datastore adaptor
|
||||
|
||||
FROM rust:latest 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 datastore-adaptor && mv ./target/release/crabfit-api ./api
|
||||
|
||||
# Runtime image
|
||||
FROM debian:bullseye-slim
|
||||
|
||||
# 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue