-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (28 loc) · 1.09 KB
/
Dockerfile
File metadata and controls
38 lines (28 loc) · 1.09 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
# Build the binary
FROM golang as builder
USER root
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
ARG VERSION \
COMMIT \
BUILD_DATE
# Copy the entire Go module structure
COPY . .
# Build
RUN CGO_ENABLED=0 LDFLAGS="-s -w \
-X github.com/stacklok/toolhive-registry-server/internal/versions.Version=${VERSION} \
-X github.com/stacklok/toolhive-registry-server/internal/versions.Commit=${COMMIT} \
-X github.com/stacklok/toolhive-registry-server/internal/versions.BuildDate=${BUILD_DATE} \
-X github.com/stacklok/toolhive-registry-server/internal/versions.BuildType=release" \
GOOS=linux GOARCH=amd64 go build -ldflags "${LDFLAGS}" -o main ./cmd/thv-registry-api/main.go
# Use minimal base image to package the binary
FROM registry.access.redhat.com/ubi10/ubi-minimal:10.1-1776834797
COPY --from=builder /workspace/main /
COPY LICENSE /licenses/LICENSE
USER 1001
ENTRYPOINT ["/main"]