-
Notifications
You must be signed in to change notification settings - Fork 400
/
Dockerfile
66 lines (53 loc) · 1.94 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
# syntax=docker/dockerfile:1.4
# Copyright 2018 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.
# Fetch the following into binaries for linux and then host them in a tar.gz file in an alpine image
# - kube-apiserver (fetch)
# - kubectl (fetch)
# - etcd (fetch)
FROM golang:1.21 --platform=local as builder
# Version and platform args.
ARG KUBERNETES_VERSION
ARG ETCD_VERSION=v3.5.13
ARG OS=linux
ARG ARCH
# Tools path.
ENV DEST=/usr/local/kubebuilder/bin/
# Install dependencies.
RUN apt update && \
apt install unzip rsync -y && \
mkdir -p $DEST
# kube-apiserver
RUN curl -sfLO https://dl.k8s.io/${KUBERNETES_VERSION}/bin/${OS}/${ARCH}/kube-apiserver && \
chmod +x kube-apiserver && \
cp kube-apiserver $DEST
# kubectl
RUN curl -sfLO https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/bin/${OS}/${ARCH}/kubectl && \
chmod +x kubectl && \
cp kubectl $DEST
# etcd
ENV ETCD_BASE_NAME=etcd-${ETCD_VERSION}-${OS}-${ARCH}
RUN curl -sfLO https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/${ETCD_BASE_NAME}.tar.gz && \
tar xzf ${ETCD_BASE_NAME}.tar.gz && \
cp ${ETCD_BASE_NAME}/etcd $DEST
# Package into tarball.
WORKDIR /usr/local
RUN tar -czvf /kubebuilder_${OS}_${ARCH}.tar.gz kubebuilder/
# Copy tarball to final image.
ARG ARCH
FROM gcr.io/distroless/static:nonroot-${ARCH}
# Platform args.
ARG OS=linux
ARG ARCH
COPY --from=builder /kubebuilder_${OS}_${ARCH}.tar.gz /