forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quick
executable file
·60 lines (53 loc) · 2.68 KB
/
quick
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
#!/usr/bin/env bash
## This script builds the Rancher server image exclusively, sans Dapper
set -eo pipefail
set -x
# variables
COMMIT=$(git rev-parse --short HEAD)
TAG="${TAG:-$(yq '.env.TAG | sub("-.*", "")' < .github/workflows/pull-request.yml)-${COMMIT}}"
OS="${OS:-linux}"
ARCH="${ARCH:-amd64}"
REPO="${REPO:-rancher}"
CATTLE_K3S_VERSION=$(grep -m1 'ENV CATTLE_K3S_VERSION' package/Dockerfile | awk '{print $3}')
CATTLE_KDM_BRANCH=$(grep -m1 'ARG CATTLE_KDM_BRANCH=' package/Dockerfile | cut -d '=' -f2)
RKE_VERSION=$(grep -m1 'github.com/rancher/rke' go.mod | awk '{print $2}')
if [[ -z "$RKE_VERSION" ]]; then
RKE_VERSION=$(grep -m1 'github.com/rancher/rke' go.mod | awk '{print $4}')
fi
CATTLE_RANCHER_WEBHOOK_VERSION=$(yq '.webhookVersion' < build.yaml)
CATTLE_CSP_ADAPTER_MIN_VERSION=$(yq '.cspAdapterMinVersion' < build.yaml)
CATTLE_RANCHER_PROVISIONING_CAPI_VERSION=$(yq '.provisioningCAPIVersion' < build.yaml)
CATTLE_FLEET_VERSION=$(yq '.fleetVersion' < build.yaml)
# download airgap images and export it to a tarball
curl -Lf https://github.com/rancher/k3s/releases/download/"${CATTLE_K3S_VERSION}"/k3s-images.txt -o ./k3s-images.txt
AIRGAP_IMAGES=$(grep -e 'docker.io/rancher/mirrored-pause' -e 'docker.io/rancher/mirrored-coredns-coredns' ./k3s-images.txt)
xargs -n1 docker pull <<< "${AIRGAP_IMAGES}"
xargs -n2 docker save -o ./k3s-airgap-images.tar <<< "${AIRGAP_IMAGES}"
# download kontainer driver metadata
curl -sLf https://releases.rancher.com/kontainer-driver-metadata/"${CATTLE_KDM_BRANCH}"/data.json > ./data.json
# start the builds
docker buildx build \
--build-arg VERSION="${TAG}" \
--build-arg ARCH="${ARCH}" \
--build-arg IMAGE_REPO="${REPO}" \
--build-arg COMMIT="${COMMIT}" \
--build-arg RKE_VERSION="${RKE_VERSION}" \
--build-arg CATTLE_RANCHER_WEBHOOK_VERSION="${CATTLE_RANCHER_WEBHOOK_VERSION}" \
--build-arg CATTLE_RANCHER_PROVISIONING_CAPI_VERSION="${CATTLE_RANCHER_PROVISIONING_CAPI_VERSION}" \
--build-arg CATTLE_CSP_ADAPTER_MIN_VERSION="${CATTLE_CSP_ADAPTER_MIN_VERSION}" \
--build-arg CATTLE_FLEET_VERSION="${CATTLE_FLEET_VERSION}" \
--tag "${REPO}"/rancher:"${TAG}" \
--platform="${OS}/${ARCH}" \
--file ./package/Dockerfile .
docker buildx build \
--build-arg VERSION="${TAG}" \
--build-arg ARCH="${ARCH}" \
--build-arg RANCHER_TAG="${TAG}" \
--build-arg RANCHER_REPO="${REPO}" \
--build-arg COMMIT="${COMMIT}" \
--build-arg RKE_VERSION="${RKE_VERSION}" \
--build-arg CATTLE_RANCHER_WEBHOOK_VERSION="${CATTLE_RANCHER_WEBHOOK_VERSION}" \
--build-arg CATTLE_RANCHER_PROVISIONING_CAPI_VERSION="${CATTLE_RANCHER_PROVISIONING_CAPI_VERSION}" \
--tag "${REPO}"/rancher-agent:"${TAG}" \
--platform="${OS}/${ARCH}" \
--file ./package/Dockerfile.agent .