-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
43 lines (30 loc) · 1.1 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
# Use the official Rust image as the build environment
FROM rust:1.80 AS builder
# Set the working directory inside the container
WORKDIR /app
# Update package lists and install required packages
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends pkg-config libssl-dev lld clang libc6
# Copy the source code into the container
COPY . .
# Set build arguments for the runtime environment
ARG GCP_PROJECT_ID
# Set environment variables for the build
ENV SQLX_OFFLINE=true
ENV APP_ENVIRONMENT=production
ENV GCP_PROJECT_ID=${GCP_PROJECT_ID}
# Build the application
RUN cargo build --release
# Use a minimal base image for the runtime environment
FROM gcr.io/distroless/cc-debian12 AS runtime
# Set the working directory inside the container
WORKDIR /app
# Copy the compiled binary from the builder stage
COPY --from=builder /app/target/release/axum-web-gcp axum-web-gcp
# Set environment variables for the runtime
ENV APP_ENVIRONMENT=production
ENV GCP_PROJECT_ID=${GCP_PROJECT_ID}
# Expose the port that the application listens on
EXPOSE 8080
# Run the application
ENTRYPOINT ["./axum-web-gcp"]