From ce11c0f6f3520c8f754469ed22d901f0667d51dc Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 4 Feb 2019 21:42:35 -0700 Subject: [PATCH] Get ARM CI working --- .dockerignore | 3 +- .drone.yml | 246 +++++++++++++++++++++++++++++++++--------- Dockerfile.dapper | 2 +- package/Dockerfile | 2 +- scripts/package-cli | 14 +-- scripts/package-image | 8 +- 6 files changed, 211 insertions(+), 64 deletions(-) diff --git a/.dockerignore b/.dockerignore index bd0daaabad..5201e48524 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,6 @@ ./bin -./build +./build/data +./build/data.tar.gz ./pkg/data/zz_generated_bindata.go ./package/data.tar.gz ./.vagrant diff --git a/.drone.yml b/.drone.yml index 1843d20570..3d06e3d761 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,51 +1,64 @@ --- kind: pipeline -name: intel +name: amd64 platform: os: linux arch: amd64 steps: - - name: build - privileged: true - image: rancher/dapper:v0.4.0 - volumes: - - name: docker - path: /var/run/docker.sock - commands: - - dapper ci +- name: build + image: rancher/dapper:v0.4.1 + commands: + - dapper ci + volumes: + - name: docker + path: /var/run/docker.sock + +- name: github_binary_release + image: ibuildthecloud/github-release:v0.0.1 + settings: + api_key: + from_secret: github_token + prerelease: true + checksum: + - sha256 + checksum_file: CHECKSUMsum-amd64.txt + checksum_flatten: true + files: + - "dist/artifacts/*" + when: + instance: + - drone-publish.rancher.io + ref: + - refs/head/master + - refs/tags/* + event: + - tag + +- name: docker-publish + image: plugins/docker + settings: + dockerfile: package/Dockerfile + password: + from_secret: docker_password + repo: "ibuildthecloud/k3s" + tag: "${DRONE_TAG}-amd64" + username: + from_secret: docker_username + when: + instance: + - drone-publish.rancher.io + ref: + - refs/head/master + - refs/tags/* + event: + - tag volumes: - - name: docker - host: - path: /var/run/docker.sock - ---- -kind: pipeline -name: arm - -platform: - os: linux - arch: arm64 - -steps: - - name: build - privileged: true - image: rancher/dapper:v0.4.0 - environment: - DAPPER_HOST_ARCH: arm - volumes: - - name: docker - path: /var/run/docker.sock - commands: - - dapper ci - -volumes: - - name: docker - host: - path: /var/run/docker.sock - +- name: docker + host: + path: /var/run/docker.sock --- kind: pipeline @@ -56,16 +69,153 @@ platform: arch: arm64 steps: - - name: build - privileged: true - image: rancher/dapper:v0.4.0 - volumes: - - name: docker - path: /var/run/docker.sock - commands: - - dapper ci +- name: build + image: rancher/dapper:v0.4.1 + commands: + - dapper ci + volumes: + - name: docker + path: /var/run/docker.sock + +- name: github_binary_release + image: ibuildthecloud/github-release:v0.0.1 + settings: + api_key: + from_secret: github_token + prerelease: true + checksum: + - sha256 + checksum_file: CHECKSUMsum-arm64.txt + checksum_flatten: true + files: + - "dist/artifacts/*" + when: + instance: + - drone-publish.rancher.io + ref: + - refs/head/master + - refs/tags/* + event: + - tag + +- name: docker-publish + image: plugins/docker + settings: + dockerfile: package/Dockerfile + password: + from_secret: docker_password + repo: "ibuildthecloud/k3s" + tag: "${DRONE_TAG}-arm64" + username: + from_secret: docker_username + when: + instance: + - drone-publish.rancher.io + ref: + - refs/head/master + - refs/tags/* + event: + - tag volumes: +- name: docker + host: + path: /var/run/docker.sock + +--- +kind: pipeline +name: arm + +platform: + os: linux + arch: arm + +steps: +- name: build + image: rancher/dapper:v0.4.1 + commands: + - dapper ci + volumes: - name: docker - host: - path: /var/run/docker.sock + path: /var/run/docker.sock + +- name: github_binary_release + image: ibuildthecloud/github-release:v0.0.1 + settings: + api_key: + from_secret: github_token + prerelease: true + checksum: + - sha256 + checksum_file: CHECKSUMsum-arm.txt + checksum_flatten: true + files: + - "dist/artifacts/*" + when: + instance: + - drone-publish.rancher.io + ref: + - refs/head/master + - refs/tags/* + event: + - tag + +- name: docker-publish + image: plugins/docker + settings: + dockerfile: package/Dockerfile + password: + from_secret: docker_password + repo: "ibuildthecloud/k3s" + tag: "${DRONE_TAG}-arm" + username: + from_secret: docker_username + when: + instance: + - drone-publish.rancher.io + ref: + - refs/head/master + - refs/tags/* + event: + - tag + +volumes: +- name: docker + host: + path: /var/run/docker.sock + +--- +kind: pipeline +name: manifest + +platform: + os: linux + arch: amd64 + +steps: +- name: manifest + image: plugins/manifest:1.0.2 + settings: + username: + from_secret: docker_username + password: + from_secret: docker_password + platforms: + - linux/amd64 + - linux/arm64 + - linux/arm + target: "ibuildthecloud/k3s:${DRONE_TAG}" + template: "ibuildthecloud/k3s:${DRONE_TAG}-ARCH" + when: + instance: + - drone-publish.rancher.io + ref: + - refs/head/master + - refs/tags/* + event: + - tag + +depends_on: +- amd64 +- arm64 +- arm diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 21d22fdc07..d9ea6095c8 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -19,7 +19,7 @@ ENV ARCH $DAPPER_HOST_ARCH ENV DAPPER_RUN_ARGS --privileged ENV DAPPER_ENV REPO TAG DRONE_TAG IMAGE_NAME ENV DAPPER_SOURCE /go/src/github.com/rancher/k3s/ -ENV DAPPER_OUTPUT ./bin ./dist +ENV DAPPER_OUTPUT ./bin ./dist ./build/out/ ENV DAPPER_DOCKER_SOCKET true ENV HOME ${DAPPER_SOURCE} ENV CROSS true diff --git a/package/Dockerfile b/package/Dockerfile index 2a932fbd72..03cce2735f 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -1,6 +1,6 @@ FROM alpine:3.8 as base RUN apk add -U ca-certificates -ADD data.tar.gz /image +ADD build/out/data.tar.gz /image RUN mkdir -p /image/etc/ssl/certs /image/run /image/var/run /image/tmp /image/lib/modules /image/lib/firmware && \ cp /etc/ssl/certs/ca-certificates.crt /image/etc/ssl/certs/ca-certificates.crt RUN cd image/bin && \ diff --git a/scripts/package-cli b/scripts/package-cli index 01559b54c2..14ba3ab48f 100755 --- a/scripts/package-cli +++ b/scripts/package-cli @@ -20,13 +20,13 @@ done rm -rf build/data -mkdir -p build/data -mkdir -p dist +mkdir -p build/data build/out +mkdir -p dist/artifacts -tar cvzf ./build/data.tar.gz --exclude ./bin/hyperkube ./bin -HASH=$(sha256sum ./build/data.tar.gz | awk '{print $1}') +tar cvzf ./build/out/data.tar.gz --exclude ./bin/hyperkube ./bin +HASH=$(sha256sum ./build/out/data.tar.gz | awk '{print $1}') -cp ./build/data.tar.gz ./build/data/${HASH}.tgz +cp ./build/out/data.tar.gz ./build/data/${HASH}.tgz BIN_SUFFIX="-${ARCH}" if [ ${ARCH} = amd64 ]; then @@ -35,8 +35,8 @@ elif [ ${ARCH} = arm ]; then BIN_SUFFIX="-armhf" fi -cp -f ./bin/hyperkube dist/hyperkube${BIN_SUFFIX} -CMD_NAME=dist/k3s${BIN_SUFFIX} +cp -f ./bin/hyperkube dist/artifacts/hyperkube${BIN_SUFFIX} +CMD_NAME=dist/artifacts/k3s${BIN_SUFFIX} go generate LDFLAGS="-X github.com/rancher/k3s/version.Version=$VERSION -w -s" diff --git a/scripts/package-image b/scripts/package-image index 03dfda2fb1..83e803c44a 100755 --- a/scripts/package-image +++ b/scripts/package-image @@ -3,16 +3,12 @@ set -e source $(dirname $0)/version.sh -cd $(dirname $0)/../package +cd $(dirname $0)/.. TAG=${TAG:-${VERSION}${SUFFIX}} REPO=${REPO:-rancher} IMAGE_NAME=${IMAGE_NAME:-k3s} -cp -f ../build/data.tar.gz . - IMAGE=${REPO}/${IMAGE_NAME}:${TAG} -docker build -t ${IMAGE} . -mkdir -p ../dist -echo ${IMAGE} > ../dist/images +docker build -t ${IMAGE} -f package/Dockerfile . echo Built ${IMAGE}