diff --git a/.drone-multiarch.yml b/.drone-multiarch.yml new file mode 100644 index 00000000..4e10aeff --- /dev/null +++ b/.drone-multiarch.yml @@ -0,0 +1,106 @@ +kind: pipeline +name: amd64 + +platform: + os: linux + arch: amd64 + +steps: + - name: build + image: rancher/dapper:v0.4.1 + volumes: + - name: docker + path: /var/run/docker.sock + commands: + - dapper ci + - name: stage-binaries + image: rancher/dapper:v0.4.1 + commands: + - cp -r ./bin/* ./ + when: + event: + - tag + - name: publish-rke-tools-amd64 + image: plugins/docker + settings: + username: + from_secret: dockerhub_username + password: + from_secret: dockerhub_password + dockerfile: package/Dockerfile + build_args: + - ARCH=amd64 + repo: jianghang8421/rke-tools + tag: "${DRONE_TAG}-amd64" + when: + event: + - tag +volumes: + - name: docker + host: + path: /var/run/docker.sock +--- +kind: pipeline +name: arm64 + +platform: + os: linux + arch: arm64 + +steps: + - name: build + image: rancher/dapper:v0.4.1 + volumes: + - name: docker + path: /var/run/docker.sock + commands: + - dapper ci + - name: stage-binaries + image: rancher/dapper:v0.4.1 + commands: + - cp -r ./bin/* ./ + when: + event: + - tag + - name: publish-rke-tools-arm64 + image: plugins/docker:linux-arm64 + settings: + username: + from_secret: dockerhub_username + password: + from_secret: dockerhub_password + dockerfile: package/Dockerfile + build_args: + - ARCH=arm64 + repo: jianghang8421/rke-tools + tag: "${DRONE_TAG}-arm64" + when: + event: + - tag +volumes: + - name: docker + host: + path: /var/run/docker.sock +--- +kind: pipeline +name: manifest + +steps: + - name: push-manifest + image: plugins/manifest:1.0.2 + settings: + username: + from_secret: dockerhub_username + password: + from_secret: dockerhub_password + target: "jianghang8421/rke-tools:${DRONE_TAG}" + template: "jianghang8421/rke-tools:${DRONE_TAG}-ARCH" + platforms: + - linux/amd64 + - linux/arm64 + when: + event: + - tag +depends_on: +- amd64 +- arm64 diff --git a/Dockerfile.dapper b/Dockerfile.dapper index b30d9b0a..3a000506 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -1,5 +1,5 @@ FROM ubuntu:16.04 -# FROM arm=armhf/ubuntu:16.04 +# FROM arm=armhf/ubuntu:16.04 arm64=aarch64/ubuntu:16.04 ARG DAPPER_HOST_ARCH ENV HOST_ARCH=${DAPPER_HOST_ARCH} ARCH=${DAPPER_HOST_ARCH} @@ -8,7 +8,7 @@ RUN apt-get update && \ apt-get install -y gcc ca-certificates git wget curl vim less file && \ rm -f /bin/sh && ln -s /bin/bash /bin/sh -ENV GOLANG_ARCH_amd64=amd64 GOLANG_ARCH_arm=armv6l GOLANG_ARCH=GOLANG_ARCH_${ARCH} \ +ENV GOLANG_ARCH_amd64=amd64 GOLANG_ARCH_arm=armv6l GOLANG_ARCH_arm64=arm64 GOLANG_ARCH=GOLANG_ARCH_${ARCH} \ GOPATH=/go PATH=/go/bin:/usr/local/go/bin:${PATH} SHELL=/bin/bash RUN wget -O - https://dl.google.com/go/go1.9.2.linux-${!GOLANG_ARCH}.tar.gz | tar -xzf - -C /usr/local && \ @@ -16,6 +16,7 @@ RUN wget -O - https://dl.google.com/go/go1.9.2.linux-${!GOLANG_ARCH}.tar.gz | ta ENV DOCKER_URL_amd64=https://get.docker.com/builds/Linux/x86_64/docker-1.10.3 \ DOCKER_URL_arm=https://github.com/rancher/docker/releases/download/v1.10.3-ros1/docker-1.10.3_arm \ + DOCKER_URL_arm64=https://github.com/rancher/docker/releases/download/v1.10.3-ros1/docker-1.10.3_arm64 \ DOCKER_URL=DOCKER_URL_${ARCH} RUN wget -O - ${!DOCKER_URL} > /usr/bin/docker && chmod +x /usr/bin/docker diff --git a/package/Dockerfile b/package/Dockerfile index 6f405540..9c81829d 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -1,19 +1,33 @@ FROM nginx:1.14.0-alpine LABEL maintainer "Rancher Labs " -RUN apk -U --no-cache add bash curl wget ca-certificates tar sysstat\ +ARG ARCH=amd64 +ENV DOCKER_URL_amd64=https://get.docker.com/builds/Linux/x86_64/docker-1.12.3.tgz \ + DOCKER_URL_arm64=https://github.com/rancher/docker/releases/download/v1.12.3/docker-v1.12.3_arm64.tgz \ + DOCKER_URL=DOCKER_URL_${ARCH} +RUN apk -U --no-cache add bash \ + && rm -f /bin/sh \ + && ln -s /bin/bash /bin/sh +RUN apk -U --no-cache add curl wget ca-certificates tar sysstat\ && mkdir -p /opt/rke-tools/bin /etc/confd \ - && curl -sLf https://github.com/kelseyhightower/confd/releases/download/v0.16.0/confd-0.16.0-linux-amd64 > /usr/bin/confd \ + && curl -sLf https://github.com/kelseyhightower/confd/releases/download/v0.16.0/confd-0.16.0-linux-${ARCH} > /usr/bin/confd \ && chmod +x /usr/bin/confd \ - && curl -sLf https://get.docker.com/builds/Linux/x86_64/docker-1.12.3.tgz | tar xvzf - -C /opt/rke-tools/bin --strip-components=1 docker/docker \ + && curl -sLf ${!DOCKER_URL} | tar xvzf - -C /opt/rke-tools/bin --strip-components=1 docker/docker \ && chmod +x /opt/rke-tools/bin/docker \ && apk del curl +ENV PORTMAP_URL_amd64=https://github.com/projectcalico/cni-plugin/releases/download/v1.9.1/portmap \ + PORTMAP_URL_arm64=https://github.com/jianghang8421/plugins/releases/download/v1.9.1-rancher/portmap-arm64 \ + PORTMAP_URL=PORTMAP_URL_${ARCH} + RUN mkdir -p /opt/cni/bin RUN wget -q -O - https://github.com/containernetworking/cni/releases/download/v0.4.0/cni-amd64-v0.4.0.tgz | tar xzf - -C /tmp -RUN wget -q -O /tmp/portmap https://github.com/projectcalico/cni-plugin/releases/download/v1.9.1/portmap +RUN wget -q -O /tmp/portmap ${!PORTMAP_URL} -RUN wget -q -O - https://github.com/coreos/etcd/releases/download/v3.0.17/etcd-v3.0.17-linux-amd64.tar.gz | tar xzf - -C /tmp && \ +ENV ETCD_URL_amd64=https://github.com/coreos/etcd/releases/download/v3.0.17/etcd-v3.0.17-linux-amd64.tar.gz \ + ETCD_URL_arm64=https://github.com/etcd-io/etcd/releases/download/v3.3.10/etcd-v3.3.10-linux-arm64.tar.gz \ + ETCD_URL=ETCD_URL_${ARCH} +RUN wget -q -O - ${!ETCD_URL} | tar xzf - -C /tmp && \ mv /tmp/etcd-*/etcdctl /usr/local/bin/etcdctl && \ rm -rf /tmp/etcd-* && rm -f /etcd-*.tar.gz && \ apk del wget diff --git a/scripts/package b/scripts/package index 64b6a3f7..962913b1 100755 --- a/scripts/package +++ b/scripts/package @@ -20,6 +20,6 @@ cp ../bin/rke-etcd-backup . cp -r ../{conf.d,cert-deployer,templates,nginx-proxy,*.sh} . IMAGE=${REPO}/rke-tools:${TAG} -docker build -t ${IMAGE} . +docker build --build-arg ARCH=${ARCH} -t ${IMAGE} . echo ${IMAGE} > ../dist/images echo Built ${IMAGE}