feat: Add Dockerization support

This commit is contained in:
danielvici123
2026-06-09 20:13:39 +02:00
parent 520fd4f1e6
commit 0103d2939d
6 changed files with 151 additions and 8 deletions

44
Dockerfile Normal file
View File

@@ -0,0 +1,44 @@
# Build stage
FROM rust:alpine AS builder
# Install build dependencies
RUN apk add --no-cache musl-dev
WORKDIR /usr/src/dhl
# 1. Copy only the dependency manifests
COPY Cargo.toml Cargo.lock ./
# 2. Create a dummy source file to build dependencies
RUN mkdir src && echo "fn main() {}" > src/main.rs && \
cargo build --release && \
rm -rf src
# 3. Now copy the real source code
COPY src ./src
# 4. Build the actual application
# We touch the main file to ensure cargo rebuilds it
RUN touch src/main.rs && cargo build --release
# Final stage
FROM alpine:latest
# Set environment variable to signal the app it's running in Docker
ENV DOCKER_CONTAINER=true
# Install runtime dependencies
RUN apk add --no-cache ca-certificates
WORKDIR /app
# Copy the binary from the builder stage
COPY --from=builder /usr/src/dhl/target/release/dhl /usr/local/bin/dhl
# Volume for configuration and response files
VOLUME ["/app"]
# Default port
EXPOSE 3000
CMD ["dhl"]