-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
44 lines (30 loc) · 1.12 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
# Use the official Golang image as the base image
FROM golang:1.22-alpine AS builder
# Set the working directory inside the container
WORKDIR /app
# Copy the go.mod, go.sum and main.go files
COPY go.mod go.sum main.go ./
# Copy the controllers directory
COPY controllers ./controllers
# Download the Go module dependencies
RUN go mod download
# Build the Go application
RUN go build -o auto-register-k8s-spark-ui .
# Use a minimal base image to run the application
FROM alpine:latest
# Install CA certificatesdocker run -it auto-register-k8s-spark-ui sh
RUN apk --no-cache add ca-certificates
# Create a user and group
RUN addgroup -g 3000 -S auto-register-ui && \
adduser -u 1000 -S auto-register-ui -G auto-register-ui
# Set the working directory
WORKDIR /app
COPY LICENSE LICENSE
# Copy the built Go binary from the builder stage
COPY --from=builder /app/auto-register-k8s-spark-ui /app/
# Change ownership of the application files
RUN chown -R auto-register-ui:auto-register-ui /app
# Switch to the non-root user
USER auto-register-ui:auto-register-ui
# Command to run the application
CMD ["./auto-register-k8s-spark-ui"]