-
Notifications
You must be signed in to change notification settings - Fork 115
Expand file tree
/
Copy pathDockerfile
More file actions
executable file
·46 lines (30 loc) · 938 Bytes
/
Copy pathDockerfile
File metadata and controls
executable file
·46 lines (30 loc) · 938 Bytes
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
# Build stage
FROM registry.access.redhat.com/ubi9/go-toolset:1.24 AS builder
WORKDIR /app
USER 0
# Copy go mod and sum files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy the source code
COPY . .
# Build the application with version embedded via ldflags
ARG AMBIENT_VERSION=dev
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w -X main.GitVersion=${AMBIENT_VERSION}" -o main .
# Final stage
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
ARG GIT_COMMIT=unknown
RUN microdnf install -y git && microdnf clean all
WORKDIR /app
# Copy the binary from builder stage
COPY --from=builder /app/main .
# Default agents directory
ENV AGENTS_DIR=/app/agents
# Set executable permissions and make accessible to any user
RUN chmod +x ./main && chmod 775 /app
USER 1001
# Expose port
EXPOSE 8080
# Command to run the executable
LABEL org.opencontainers.image.revision=$GIT_COMMIT
CMD ["./main"]