-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
44 lines (31 loc) · 1.05 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
# Build stage
FROM golang:1.21-alpine AS builder
WORKDIR /app
# Install git for go mod download
RUN apk add --no-cache git
# Copy the source code
COPY . .
# Download dependencies and verify modules
RUN go mod download && \
go mod verify
# Build the binary
RUN CGO_ENABLED=0 GOOS=linux go build -o /bin/controller cmd/controller/main.go
# Final stage
FROM envoyproxy/envoy:v1.27-latest
# Copy the controller binary
COPY --from=builder /bin/controller /bin/controller
# Copy deployment configuration
COPY deployments/deployment.yaml /etc/envoy-ingress-controller/deployment.yaml
# Create non-root user
RUN adduser --system --group controller && \
chown -R controller:controller /bin/controller /etc/envoy-ingress-controller
# Install libcap2-bin for setcap command
RUN apt-get update && \
apt-get install -y libcap2-bin && \
rm -rf /var/lib/apt/lists/*
# Set necessary capabilities for Envoy
RUN setcap "cap_net_bind_service=+ep" /usr/local/bin/envoy
# Switch to non-root user
USER controller
# Set the entrypoint
ENTRYPOINT ["/bin/controller"]