-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
31 lines (22 loc) · 884 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
# Use a base image with the latest version of Rust installed for the build stage
FROM rust:latest as build
# Create a new empty shell project
RUN USER=root cargo new --bin eletypes-backend
# Set the working directory in the container
WORKDIR /eletypes-backend
# Copy over your manifests
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
# Cache dependencies to optimize build times
RUN cargo build --release
RUN rm src/*.rs
# Copy the local application code into the container
COPY . .
# Build the application for release
RUN cargo build --release
# Use a minimal base image for the final stage
FROM gcr.io/distroless/cc
# Copy the build artifact from the build stage
COPY --from=build /eletypes-backend/target/release/eletypes-backend /usr/local/bin/eletypes-backend
# Specify the command to run when the container starts
CMD ["/usr/local/bin/eletypes-backend"]