-
Notifications
You must be signed in to change notification settings - Fork 71
/
Dockerfile
71 lines (55 loc) · 2.11 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Copyright 2021 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# About: This dockerfile builds the kpromo binary for auditor tests and production use.
#
# Usage: Since there are two variants to build, you must include the variant name during build-time.
# kpromo production binary:
# docker build --build-arg variant=prod /path/to/Dockerfile
# test auditor:
# docker build --build-arg variant=test /path/to/Dockerfile
# Determine final build variant [prod | test].
ARG variant
ARG GO_VERSION
ARG OS_CODENAME
FROM golang:1.22-bookworm AS builder
# Copy the sources
WORKDIR /go/src/app
COPY . ./
# Build
ARG ARCH
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=${ARCH}
RUN make kpromo
FROM gcr.io/google.com/cloudsdktool/cloud-sdk:slim AS base
WORKDIR /
COPY --from=builder /go/src/app/bin/kpromo .
# The Docker configuration file (which include credential helpers for
# authenticating to various container registries) should be placed in the home
# directory of the running user, so it can be detected by artifact promotion
# tooling.
COPY --from=builder /go/src/app/docker/config.json /root/.docker/config.json
ENTRYPOINT ["/kpromo"]
# Testing image
FROM base AS test-variant
# Include auditor testing fixtures.
COPY --from=builder /go/src/app/test-e2e/cip-auditor/fixture /e2e-fixtures
# Trigger the auditor on startup.
ENTRYPOINT ["/kpromo", "cip", "audit", "--verbose"]
# Production image
FROM base AS prod-variant
LABEL maintainers="Kubernetes Authors"
LABEL description="kpromo: The Kubernetes project artifact promoter"
# Allow the runtime argument to choose the final variant.
FROM ${variant}-variant AS final