-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
51 lines (36 loc) · 1.11 KB
/
Dockerfile
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
44
45
46
47
48
49
50
51
# Build stage
FROM golang:1.22-alpine AS builder
WORKDIR /build
# Add build arguments
ARG VERSION
ARG GIT_COMMIT
ARG BUILD_DATE
# Install build dependencies
RUN apk add --no-cache git
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Verify module dependencies
RUN go mod verify
# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-X github.com/NeuralTrust/ai-gateway-ce/pkg/version.Version=${VERSION} \
-X github.com/NeuralTrust/ai-gateway-ce/pkg/version.GitCommit=${GIT_COMMIT} \
-X github.com/NeuralTrust/ai-gateway-ce/pkg/version.BuildDate=${BUILD_DATE}" \
-o gateway ./cmd/gateway
# Final stage
FROM alpine:3.18
WORKDIR /app
# Install runtime dependencies
RUN apk add --no-cache ca-certificates tzdata
# Copy binary and config files
COPY --from=builder /build/gateway /app/
COPY config/ /app/config/
# Set environment variables
ENV GIN_MODE=release
# Add entrypoint script
COPY scripts/docker-entrypoint.sh /app/
RUN chmod +x /app/docker-entrypoint.sh
EXPOSE 8080 8081
ENTRYPOINT ["/app/docker-entrypoint.sh"]