Activate cross-build on drone

This commit is contained in:
Antoine GIRARD 2018-06-24 05:35:48 +02:00
parent eaf427db00
commit 970cc4d243
No known key found for this signature in database
GPG Key ID: F3B46D1708E22963
2 changed files with 103 additions and 10 deletions

View File

@ -236,29 +236,109 @@ pipeline:
event: [ push ]
branch: [ master ]
docker:
image: golang:1.10
pull: true
commands:
- GOARCH=amd64 QEMU_ARCH=amd64 make docker-generate-arch-dockerfile docker-download-qemu-binary
- GOARCH=arm QEMU_ARCH=arm make docker-generate-arch-dockerfile docker-download-qemu-binary
- GOARCH=arm64 QEMU_ARCH=aarch64 make docker-generate-arch-dockerfile docker-download-qemu-binary
when:
event: [ push, tag ]
docker:
image: multiarch/qemu-user-static:register
pull: true
privileged: true
when:
event: [ push, tag ]
docker:
image: plugins/docker:17.12
pull: true
secrets: [ docker_username, docker_password ]
group: docker
repo: gitea/gitea
tag: '${DRONE_BRANCH##release/v}-${DRONE_ARCH/\//-}'
tag: '${DRONE_BRANCH##release/v}-linux-amd64'
build_args:
- TARGET=amd64
dockerfile: docker/Dockerfile.amd64
when:
event: [ push ]
branch: [ release/* ]
docker:
image: plugins/docker:17.12
secrets: [ docker_username, docker_password ]
pull: true
secrets: [ docker_username, docker_password ]
group: docker
repo: gitea/gitea
tag: 'latest-${DRONE_ARCH/\//-}'
tag: '${DRONE_BRANCH##release/v}-linux-arm'
build_args:
- TARGET=arm32v6
dockerfile: docker/Dockerfile.arm
when:
event: [ push ]
branch: [ release/* ]
docker:
image: plugins/docker:17.12
pull: true
secrets: [ docker_username, docker_password ]
group: docker
repo: gitea/gitea
tag: '${DRONE_BRANCH##release/v}-linux-arm64'
build_args:
- TARGET=arm64v8
dockerfile: docker/Dockerfile.aarch64
when:
event: [ push ]
branch: [ release/* ]
docker:
image: plugins/docker:17.12
pull: true
secrets: [ docker_username, docker_password ]
group: docker
repo: gitea/gitea
tag: 'latest-linux-amd64'
build_args:
- TARGET=amd64
dockerfile: docker/Dockerfile.amd64
when:
event: [ push, tag ]
docker:
image: plugins/docker:17.12
pull: true
secrets: [ docker_username, docker_password ]
group: docker
repo: gitea/gitea
tag: 'latest-linux-arm'
build_args:
- TARGET=arm32v6
dockerfile: docker/Dockerfile.arm
when:
event: [ push, tag ]
docker:
image: plugins/docker:17.12
pull: true
secrets: [ docker_username, docker_password ]
group: docker
repo: gitea/gitea
tag: 'latest-linux-arm64'
build_args:
- TARGET=arm64v8
dockerfile: docker/Dockerfile.aarch64
when:
event: [ push, tag ]
docker:
image: plugins/manifest
pull: true
secrets: [ docker_username, docker_password ]
platforms: linux/amd64
platforms: [ linux/amd64, linux/arm, linux/arm64 ]
template: 'gitea/gitea:${DRONE_BRANCH##release/v}-OS-ARCH'
target: 'gitea/gitea:${DRONE_BRANCH##release/v}'
when:
@ -267,8 +347,9 @@ pipeline:
docker:
image: plugins/manifest
pull: true
secrets: [ docker_username, docker_password ]
platforms: linux/amd64
platforms: [ linux/amd64, linux/arm, linux/arm64 ]
template: gitea/gitea:latest-OS-ARCH
target: gitea/gitea:latest
when:

22
docker/Makefile vendored
View File

@ -31,12 +31,9 @@ docker-cross : docker-setup-qemu
#exemple TARGET=amd64 GOARCH=amd64 QEMU_ARCH=amd64 make docker-cross
#exemple TARGET=arm32v6 GOARCH=arm QEMU_ARCH=arm make docker-cross
.PHONY: docker-setup-qemu
docker-setup-qemu:
.PHONY: docker-generate-arch-dockerfile
docker-generate-arch-dockerfile:
@if [ "$(QEMU_ARCH)" != ${GOHOSTARCH} ]; then \
echo "Loading qemu libs for multi-arch support."; \
(cd docker && curl -sL https://github.com/multiarch/qemu-user-static/releases/download/${QEMU_VERSION}/qemu-${QEMU_ARCH}-static.tar.gz | tar xz); \
docker run --rm --privileged multiarch/qemu-user-static:register --reset; \
echo "Generate dockerfile for specific arch."; \
sed "s/^#QEMU phase/COPY docker\/qemu-${QEMU_ARCH}-static* \/usr\/bin\//g" Dockerfile > docker/Dockerfile.${QEMU_ARCH}; \
sed -i 's/^FROM $$target\/golang:1.10-alpine3.7 AS build-env/FROM karalabe\/xgo-latest AS build-env/g' docker/Dockerfile.${QEMU_ARCH}; \
@ -45,6 +42,21 @@ docker-setup-qemu:
else cp Dockerfile docker/Dockerfile.${QEMU_ARCH}; \
fi;
.PHONY: docker-download-qemu-binary
docker-download-qemu-binary:
@if [ "$(QEMU_ARCH)" != ${GOHOSTARCH} ]; then \
echo "Downloading qemu binary for multi-arch support."; \
(cd docker && curl -sL https://github.com/multiarch/qemu-user-static/releases/download/${QEMU_VERSION}/qemu-${QEMU_ARCH}-static.tar.gz | tar xz); \
fi;
.PHONY: docker-setup-qemu
docker-setup-qemu: docker-generate-arch-dockerfile docker-download-qemu-binary
@if [ "$(QEMU_ARCH)" != ${GOHOSTARCH} ]; then \
echo "Loading qemu libs for multi-arch support."; \
docker run --rm --privileged multiarch/qemu-user-static:register --reset; \
fi;
.PHONY: docker-setup-clean
docker-setup-clean:
rm -f docker/qemu-*-static