-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (33 loc) · 1.12 KB
/
Dockerfile
File metadata and controls
41 lines (33 loc) · 1.12 KB
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
# Use cargo-chef for optimal caching
FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
WORKDIR /app
# Start with just a recipe for dependencies
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
# Build dependencies
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
# Build only dependencies to cache them
RUN cargo chef cook --release --recipe-path recipe.json
# Now build application code
COPY . .
RUN cargo build --release
# Runtime stage - Use Debian bookworm which has libssl3
FROM debian:bookworm-slim
WORKDIR /app
# Install OpenSSL and CA certificates for HTTPS requests
RUN apt-get update && \
apt-get install -y --no-install-recommends libssl3 ca-certificates && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Copy the binary from the build stage
COPY --from=builder /app/target/release/urlflatine /usr/local/bin/urlflatine
# Set environment variables for the service
# By default, listen on all interfaces (0.0.0.0) for Docker
ENV LISTEN_HOST=0.0.0.0
ENV LISTEN_PORT=8080
# Expose the port the service runs on
EXPOSE 8080
# Run the binary
CMD ["urlflatine"]