|
| 1 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 2 | +# you may not use this file except in compliance with the License. |
| 3 | +# You may obtain a copy of the License at |
| 4 | +# |
| 5 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# |
| 7 | +# Unless required by applicable law or agreed to in writing, software |
| 8 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | +# See the License for the specific language governing permissions and |
| 11 | +# limitations under the License. |
| 12 | + |
| 13 | +################################################################################ |
| 14 | +## BUILD ARGS ## |
| 15 | +################################################################################ |
| 16 | +# This build arg allows the specification of a custom Golang image. |
| 17 | +ARG GOLANG_IMAGE=golang:1.20.1 |
| 18 | + |
| 19 | +# The distroless image on which the CPI manager image is built. |
| 20 | +# |
| 21 | +# Please do not use "latest". Explicit tags should be used to provide |
| 22 | +# deterministic builds. Follow what kubernetes uses to build |
| 23 | +# kube-controller-manager, for example for 1.23.x: |
| 24 | +# https://github.com/kubernetes/kubernetes/blob/release-1.24/build/common.sh#L94 |
| 25 | +ARG DISTROLESS_IMAGE=k8s.gcr.io/build-image/go-runner:v2.3.1-go1.20.1-bullseye.0 |
| 26 | + |
| 27 | +# We use Alpine as the source for default CA certificates and some output |
| 28 | +# images |
| 29 | +ARG ALPINE_IMAGE=alpine:3.15.4 |
| 30 | + |
| 31 | +# cinder-csi-plugin uses Debian as a base image |
| 32 | +ARG DEBIAN_IMAGE=registry.k8s.io/build-image/debian-base:bullseye-v1.4.3 |
| 33 | + |
| 34 | +################################################################################ |
| 35 | +## BUILD STAGE ## |
| 36 | +################################################################################ |
| 37 | + |
| 38 | +# Build an image containing a common ca-certificates used by all target images |
| 39 | +# regardless of how they are built. We arbitrarily take ca-certificates from |
| 40 | +# the amd64 Alpine image. |
| 41 | +FROM --platform=linux/amd64 ${ALPINE_IMAGE} as certs |
| 42 | +RUN apk add --no-cache ca-certificates |
| 43 | + |
| 44 | + |
| 45 | +# Build all command targets. We build all command targets in a single build |
| 46 | +# stage for efficiency. Target images copy their binary from this image. |
| 47 | +# We use go's native cross compilation for multi-arch in this stage, so the |
| 48 | +# builder itself is always amd64 |
| 49 | +FROM --platform=linux/amd64 ${GOLANG_IMAGE} as builder |
| 50 | + |
| 51 | +ARG GOPROXY=https://goproxy.io,direct |
| 52 | +ARG TARGETOS |
| 53 | +ARG TARGETARCH |
| 54 | +ARG VERSION |
| 55 | + |
| 56 | +WORKDIR /build |
| 57 | +COPY Makefile go.mod go.sum ./ |
| 58 | +COPY cmd/ cmd/ |
| 59 | +COPY pkg/ pkg/ |
| 60 | +RUN make build GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOPROXY=${GOPROXY} VERSION=${VERSION} |
| 61 | + |
| 62 | + |
| 63 | +################################################################################ |
| 64 | +## TARGET IMAGES ## |
| 65 | +################################################################################ |
| 66 | + |
| 67 | +## |
| 68 | +## openstack-cloud-controller-manager |
| 69 | +## |
| 70 | +FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE} as openstack-cloud-controller-manager |
| 71 | + |
| 72 | +COPY --from=certs /etc/ssl/certs /etc/ssl/certs |
| 73 | +COPY --from=builder /build/openstack-cloud-controller-manager /bin/openstack-cloud-controller-manager |
| 74 | + |
| 75 | +LABEL name="openstack-cloud-controller-manager" \ |
| 76 | + license="Apache Version 2.0" \ |
| 77 | + maintainers="Kubernetes Authors" \ |
| 78 | + description="OpenStack cloud controller manager" \ |
| 79 | + distribution-scope="public" \ |
| 80 | + summary="OpenStack cloud controller manager" \ |
| 81 | + help="none" |
| 82 | + |
| 83 | +CMD [ "/bin/openstack-cloud-controller-manager" ] |
| 84 | + |
| 85 | +## |
| 86 | +## barbican-kms-plugin |
| 87 | +## |
| 88 | +FROM --platform=${TARGETPLATFORM} ${ALPINE_IMAGE} as barbican-kms-plugin |
| 89 | +# barbican-kms-plugin uses ALPINE instead of distroless because its entrypoint |
| 90 | +# uses a shell for environment substitution. If there are no other uses this |
| 91 | +# could be replaced by callers passing arguments explicitly. |
| 92 | + |
| 93 | +COPY --from=builder /build/barbican-kms-plugin /bin/barbican-kms-plugin |
| 94 | +COPY --from=certs /etc/ssl/certs /etc/ssl/certs |
| 95 | + |
| 96 | +LABEL name="barbican-kms-plugin" \ |
| 97 | + license="Apache Version 2.0" \ |
| 98 | + maintainers="Kubernetes Authors" \ |
| 99 | + description="Barbican kms plugin" \ |
| 100 | + distribution-scope="public" \ |
| 101 | + summary="Barbican kms plugin" \ |
| 102 | + help="none" |
| 103 | + |
| 104 | +CMD ["sh", "-c", "/bin/barbican-kms-plugin --socketpath ${socketpath} --cloud-config ${cloudconfig}"] |
| 105 | + |
| 106 | +## |
| 107 | +## cinder-csi-plugin |
| 108 | +## |
| 109 | +FROM --platform=${TARGETPLATFORM} ${DEBIAN_IMAGE} as cinder-csi-plugin |
| 110 | + |
| 111 | +# Install e4fsprogs for format |
| 112 | +RUN clean-install btrfs-progs e2fsprogs mount udev xfsprogs |
| 113 | + |
| 114 | +COPY --from=builder /build/cinder-csi-plugin /bin/cinder-csi-plugin |
| 115 | +COPY --from=certs /etc/ssl/certs /etc/ssl/certs |
| 116 | + |
| 117 | +LABEL name="cinder-csi-plugin" \ |
| 118 | + license="Apache Version 2.0" \ |
| 119 | + maintainers="Kubernetes Authors" \ |
| 120 | + description="Cinder CSI Plugin" \ |
| 121 | + distribution-scope="public" \ |
| 122 | + summary="Cinder CSI Plugin" \ |
| 123 | + help="none" |
| 124 | + |
| 125 | +CMD ["/bin/cinder-csi-plugin"] |
| 126 | + |
| 127 | +## |
| 128 | +## k8s-keystone-auth |
| 129 | +## |
| 130 | +FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE} as k8s-keystone-auth |
| 131 | + |
| 132 | +COPY --from=builder /build/k8s-keystone-auth /bin/k8s-keystone-auth |
| 133 | +COPY --from=certs /etc/ssl/certs /etc/ssl/certs |
| 134 | + |
| 135 | +LABEL name="k8s-keystone-auth" \ |
| 136 | + license="Apache Version 2.0" \ |
| 137 | + maintainers="Kubernetes Authors" \ |
| 138 | + description="K8s Keystone Auth" \ |
| 139 | + distribution-scope="public" \ |
| 140 | + summary="K8s Keystone Auth" \ |
| 141 | + help="none" |
| 142 | + |
| 143 | +EXPOSE 8443 |
| 144 | + |
| 145 | +CMD ["/bin/k8s-keystone-auth"] |
| 146 | + |
| 147 | +## |
| 148 | +## magnum-auto-healer |
| 149 | +## |
| 150 | +FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE} as magnum-auto-healer |
| 151 | + |
| 152 | +COPY --from=builder /build/magnum-auto-healer /bin/magnum-auto-healer |
| 153 | +COPY --from=certs /etc/ssl/certs /etc/ssl/certs |
| 154 | + |
| 155 | +LABEL name="magnum-auto-healer" \ |
| 156 | + license="Apache Version 2.0" \ |
| 157 | + maintainers="Kubernetes Authors" \ |
| 158 | + description="Magnum auto healer" \ |
| 159 | + distribution-scope="public" \ |
| 160 | + summary="Magnum auto healer" \ |
| 161 | + help="none" |
| 162 | + |
| 163 | +CMD ["/bin/magnum-auto-healer"] |
| 164 | + |
| 165 | +## |
| 166 | +## manila-csi-plugin |
| 167 | +## |
| 168 | +FROM --platform=${TARGETPLATFORM} ${ALPINE_IMAGE} as manila-csi-plugin |
| 169 | +# manila-csi-plugin uses ALPINE because it pulls in jq and curl |
| 170 | + |
| 171 | +RUN apk add --no-cache jq curl |
| 172 | + |
| 173 | +COPY --from=builder /build/manila-csi-plugin /bin/manila-csi-plugin |
| 174 | +COPY --from=certs /etc/ssl/certs /etc/ssl/certs |
| 175 | + |
| 176 | +LABEL name="manila-csi-plugin" \ |
| 177 | + license="Apache Version 2.0" \ |
| 178 | + maintainers="Kubernetes Authors" \ |
| 179 | + description="Manila CSI Plugin" \ |
| 180 | + distribution-scope="public" \ |
| 181 | + summary="Manila CSI Plugin" \ |
| 182 | + help="none" |
| 183 | + |
| 184 | +ENTRYPOINT ["/bin/manila-csi-plugin"] |
| 185 | + |
| 186 | +## |
| 187 | +## octavia-ingress-controller |
| 188 | +## |
| 189 | +FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE} as octavia-ingress-controller |
| 190 | + |
| 191 | +COPY --from=builder /build/octavia-ingress-controller /bin/octavia-ingress-controller |
| 192 | +COPY --from=certs /etc/ssl/certs /etc/ssl/certs |
| 193 | + |
| 194 | +LABEL name="octavia-ingress-controller" \ |
| 195 | + license="Apache Version 2.0" \ |
| 196 | + maintainers="Kubernetes Authors" \ |
| 197 | + description="Octavia ingress controller" \ |
| 198 | + distribution-scope="public" \ |
| 199 | + summary="Octavia ingress controller" \ |
| 200 | + help="none" |
| 201 | + |
| 202 | +CMD ["/bin/octavia-ingress-controller"] |
0 commit comments