Skip to content

Commit

Permalink
Add multi-arch support
Browse files Browse the repository at this point in the history
  • Loading branch information
jianghang8421 committed Feb 26, 2019
1 parent 6f30765 commit 8e0d338
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 8 deletions.
106 changes: 106 additions & 0 deletions .drone-multiarch.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -8,14 +8,15 @@ 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 && \
go get golang.org/x/lint/golint && go get github.com/rancher/trash

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
Expand Down
24 changes: 19 additions & 5 deletions package/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
FROM nginx:1.14.0-alpine

LABEL maintainer "Rancher Labs <[email protected]>"
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
Expand Down
2 changes: 1 addition & 1 deletion scripts/package
Original file line number Diff line number Diff line change
Expand Up @@ -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}

0 comments on commit 8e0d338

Please sign in to comment.