-
Notifications
You must be signed in to change notification settings - Fork 208
/
Copy pathDockerfile.rhel
49 lines (45 loc) · 1.44 KB
/
Dockerfile.rhel
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
FROM --platform=$BUILDPLATFORM golang:1.23 AS builder
ARG SERVICE_NAME
# Copy local modules required by the build
WORKDIR /workspace
COPY api/ api/
COPY common/ common/
COPY k8sutils/ k8sutils/
COPY profiles/ profiles/
WORKDIR /workspace/$SERVICE_NAME
RUN mkdir -p /workspace/build
# Pre-copy/cache go.mod for pre-downloading dependencies and only redownloading
COPY $SERVICE_NAME/go.mod $SERVICE_NAME/go.sum ./
RUN --mount=type=cache,target=/go/pkg \
go mod download && go mod verify
# Copy rest of source code
COPY $SERVICE_NAME/ .
# Build for target architecture
ARG TARGETARCH
RUN go mod tidy
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
CGO_ENABLED=0 GOARCH=$TARGETARCH \
go build -a -o /workspace/build/$SERVICE_NAME .
RUN make licenses
FROM registry.access.redhat.com/ubi9:9.5-1736404036
ARG SERVICE_NAME
ARG VERSION
ARG RELEASE
ARG SUMMARY
ARG DESCRIPTION
LABEL "name"=$SERVICE_NAME
LABEL "vendor"="Odigos"
LABEL "maintainer"="Odigos"
LABEL "version"=$VERSION
LABEL "release"=$RELEASE
LABEL "summary"=$SUMMARY
LABEL "description"=$DESCRIPTION
WORKDIR /
COPY --from=builder /workspace/build/$SERVICE_NAME ./app
COPY --from=builder /workspace/$SERVICE_NAME/licenses ./licenses
COPY --from=builder /workspace/$SERVICE_NAME/LICENSE ./licenses/.
USER 65532:65532
# TODO: calling the binary by SERVICE_NAME should be better for us in debugging
# but it does not work in distroless image
ENTRYPOINT ["/app"]