-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (31 loc) · 1.04 KB
/
Dockerfile
File metadata and controls
43 lines (31 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
FROM golang:1.24.3-alpine AS builder
# Install required system packages and update certificates
RUN apk update && \
apk upgrade && \
apk add --no-cache ca-certificates && \
update-ca-certificates
# Add Maintainer Info to the Image
LABEL maintainer="Mehrdad Amini <pcmehrdad@gmail.com>"
LABEL description="API Proxy Service"
# Set the Current Working Directory inside the container
WORKDIR /build/api-proxy
# Copy go mod files
COPY go.mod go.sum ./
# Download all dependencies
RUN go mod download
# Copy the source code
COPY main.go .
# Build the binary with optimizations
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o api-proxy .
# Start a new stage for final image
#FROM scratch
FROM gcr.io/distroless/static-debian11
WORKDIR /app
# Copy binary and configuration
COPY --from=builder /build/api-proxy/api-proxy .
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY config.json.example ./config.json
# Expose port
EXPOSE 3000
# Command to run
CMD ["./api-proxy"]