FROM rust:1.75-alpine AS builder # Install build dependencies RUN apk add --no-cache musl-dev openssl-dev # Set working directory WORKDIR /app # Copy source code COPY . . # Build the application RUN cargo build --release # Runtime stage FROM alpine:latest # Install runtime dependencies RUN apk add --no-cache libgcc # Create app user RUN addgroup -g 1001 appuser && adduser -D -s /bin/sh -u 1001 -G appuser appuser # Set working directory WORKDIR /app # Copy binary from builder COPY --from=builder /app/target/release/sdk_relay /usr/local/bin/sdk_relay # Configuration file will be mounted via docker-compose # Set permissions RUN chown -R appuser:appuser /app # Switch to app user USER appuser # Expose ports EXPOSE 8090 8091 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ CMD wget --quiet --tries=1 --timeout=5 --spider http://localhost:8091 || exit 1 # Run the application CMD ["/usr/local/bin/sdk_relay"]