Files
dhl/Dockerfile
danielvici123 9ced8d11c6
All checks were successful
Release Docker Image / Push Docker image to Registry (push) Successful in 1m40s
Build and Release / Build All Platforms (push) Successful in 1m57s
docker: Add OCI source label to Dockerfile
2026-06-09 21:23:12 +02:00

47 lines
1.0 KiB
Docker

# 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
LABEL org.opencontainers.image.source="https://git.danielvici.com/danielvici123/dhl"
# 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"]