# Build stage FROM golang:1.21-alpine AS builder WORKDIR /app # 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 -o /server ./cmd/server # Run stage FROM alpine:3.19 WORKDIR /app # Install runtime dependencies RUN apk add --no-cache ca-certificates tzdata mysql-client # Create uploads directory RUN mkdir -p /app/uploads # Copy binary from builder COPY --from=builder /server /app/server # Copy entrypoint script COPY entrypoint.sh /app/entrypoint.sh RUN chmod +x /app/entrypoint.sh # Expose port EXPOSE 8082 # Set environment variables ENV GIN_MODE=release ENV DB_DSN="root:wmms1234@tcp(db:3306)/wmms?charset=utf8mb4&parseTime=true" # Run the server CMD ["/app/server"]