47 lines
999 B
Docker
47 lines
999 B
Docker
# API Gateway Dockerfile for Dante GPU Rental Platform
|
|
FROM golang:1.23-alpine AS builder
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Install build dependencies
|
|
RUN apk add --no-cache git ca-certificates tzdata
|
|
|
|
# Copy go mod files
|
|
COPY go.mod go.sum ./
|
|
|
|
# Download dependencies
|
|
RUN go mod download
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build the application
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main ./cmd/
|
|
|
|
# Final stage
|
|
FROM alpine:latest
|
|
|
|
# Install runtime dependencies
|
|
RUN apk --no-cache add ca-certificates curl tzdata \
|
|
&& adduser -D -s /bin/sh appuser
|
|
|
|
WORKDIR /root/
|
|
|
|
# Copy the binary from builder stage
|
|
COPY --from=builder /app/main .
|
|
COPY --from=builder /app/configs ./configs
|
|
|
|
# Change ownership to appuser
|
|
RUN chown -R appuser:appuser /root/
|
|
USER appuser
|
|
|
|
# Expose port
|
|
EXPOSE 8080
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:8080/health || exit 1
|
|
|
|
# Run the application
|
|
CMD ["./main"] |