Try out multi arch builds
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
b5a19bb1d2
commit
7c6e536ec3
146
.drone.yml
146
.drone.yml
@ -1,28 +1,124 @@
|
||||
platform: ${platform}
|
||||
# kind: pipeline
|
||||
# name: build
|
||||
#
|
||||
# workspace:
|
||||
# base: /go
|
||||
#
|
||||
# steps:
|
||||
# - name: build
|
||||
# image: golang:1.11
|
||||
# commands:
|
||||
# - go version
|
||||
# - go env
|
||||
# - go get -u github.com/golang/dep/cmd/dep
|
||||
# - make build
|
||||
|
||||
workspace:
|
||||
base: /go
|
||||
kind: pipeline
|
||||
name: linux-amd64
|
||||
|
||||
pipeline:
|
||||
build:
|
||||
image: golang:1.10
|
||||
commands:
|
||||
- go version
|
||||
- go env
|
||||
- go get -u github.com/golang/dep/cmd/dep
|
||||
- make build
|
||||
# publish:
|
||||
# image: plugins/docker:${docker_tag}
|
||||
# repo: iamthefij/dockron
|
||||
# secrets:
|
||||
# - docker_username
|
||||
# - docker_password
|
||||
# tag:
|
||||
# - ${docker_tag}
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
# ref:
|
||||
# - refs/heads/master
|
||||
# - refs/tags/v*
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- platform: linux/amd64
|
||||
docker_tag: latest
|
||||
# - platform: linux/arm
|
||||
# docker_tag: linux-arm
|
||||
steps:
|
||||
|
||||
- name: build
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: iamthefij/multiarch-pipeline-test
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-amd64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: linux-arm
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
# ref:
|
||||
# - refs/heads/master
|
||||
# - refs/tags/v*
|
||||
|
||||
steps:
|
||||
|
||||
- name: build
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: iamthefij/multiarch-pipeline-test
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
build_args:
|
||||
- ARCH=arm
|
||||
- REPO=arm32v6
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: linux-arm64
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
# ref:
|
||||
# - refs/heads/master
|
||||
# - refs/tags/v*
|
||||
|
||||
steps:
|
||||
|
||||
- name: build
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: iamthefij/multiarch-pipeline-test
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
build_args:
|
||||
- ARCH=arm64
|
||||
- REPO=arm64v8
|
||||
|
||||
# ---
|
||||
# kind: pipeline
|
||||
# name: manifest
|
||||
#
|
||||
# depends_on:
|
||||
# - linux-amd64
|
||||
# - linux-arm
|
||||
# - linux-arm64
|
||||
#
|
||||
# trigger:
|
||||
# event:
|
||||
# - push
|
||||
# - tag
|
||||
# ref:
|
||||
# - refs/heads/master
|
||||
# - refs/tags/v*
|
||||
#
|
||||
# steps:
|
||||
# - name: publish manifest
|
||||
# image: plugins/manifest
|
||||
# settings:
|
||||
# spec: manifest.tmpl
|
||||
# auto_tag: true
|
||||
# ignore_missing: true
|
||||
# username:
|
||||
# from_secret: docker_username
|
||||
# password:
|
||||
# from_secret: docker_password
|
||||
#
|
||||
|
10
Dockerfile
10
Dockerfile
@ -1,5 +1,7 @@
|
||||
FROM golang:1.10 AS builder
|
||||
ARG REPO=library
|
||||
FROM golang:1.11-alpine AS builder
|
||||
|
||||
RUN apk add --no-cache git
|
||||
RUN go get -u github.com/golang/dep/cmd/dep
|
||||
|
||||
WORKDIR /go/src/app/
|
||||
@ -7,9 +9,11 @@ COPY ./Gopkg.* /go/src/app/
|
||||
RUN dep ensure --vendor-only
|
||||
|
||||
COPY ./main.go /go/src/app/
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o dockron .
|
||||
|
||||
FROM busybox:latest
|
||||
ARG ARCH=amd64
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -a -installsuffix nocgo -o dockron .
|
||||
|
||||
FROM ${REPO}/busybox:latest
|
||||
WORKDIR /root/
|
||||
COPY --from=builder /go/src/app/dockron .
|
||||
|
||||
|
26
Makefile
26
Makefile
@ -1,4 +1,4 @@
|
||||
DOCKER_TAG ?= dockron-dev
|
||||
DOCKER_TAG ?= dockron-dev-${USER}
|
||||
|
||||
.PHONY: default
|
||||
default: build
|
||||
@ -37,8 +37,26 @@ dep-update:
|
||||
|
||||
.PHONY: docker-build
|
||||
docker-build:
|
||||
docker build -t $(DOCKER_TAG) .
|
||||
docker build . -t ${DOCKER_TAG}-linux-amd64
|
||||
|
||||
# Cross build for arm architechtures
|
||||
.PHONY: docker-cross-build-arm
|
||||
docker-cross-build-arm:
|
||||
docker build --build-arg REPO=arm32v6 --build-arg ARCH=arm . -t ${DOCKER_TAG}-linux-arm
|
||||
|
||||
.PHONY: docker-cross-build-arm
|
||||
docker-cross-build-arm64:
|
||||
docker build --build-arg REPO=arm64v8 --build-arg ARCH=arm64 . -t ${DOCKER_TAG}-linux-arm64
|
||||
|
||||
.PHONY: docker-run
|
||||
docker-run:
|
||||
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --name $(DOCKER_TAG)-run $(DOCKER_TAG)
|
||||
docker-run: docker-build
|
||||
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --name $(DOCKER_TAG)-run $(DOCKER_TAG)-linux-amd64
|
||||
|
||||
# Cross run on host architechture
|
||||
.PHONY: docker-cross-run-arm
|
||||
docker-cross-run-arm: docker-cross-build-arm
|
||||
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --name $(DOCKER_TAG)-run ${DOCKER_TAG}-linux-arm
|
||||
|
||||
.PHONY: docker-cross-run-arm64
|
||||
docker-cross-run-arm64: docker-cross-build-arm64
|
||||
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --name $(DOCKER_TAG)-run ${DOCKER_TAG}-linux-arm64
|
||||
|
25
manifest.tmpl
Normal file
25
manifest.tmpl
Normal file
@ -0,0 +1,25 @@
|
||||
image: iamthefij/dockron:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
||||
{{#if build.tags}}
|
||||
tags:
|
||||
{{#each build.tags}}
|
||||
- {{this}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
manifests:
|
||||
-
|
||||
image: iamthefij/dockron:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
-
|
||||
image: iamthefij/dockron:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
|
||||
platform:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
variant: v8
|
||||
-
|
||||
image: iamthefij/dockron:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
|
||||
platform:
|
||||
architecture: arm
|
||||
os: linux
|
||||
variant: v7
|
Loading…
Reference in New Issue
Block a user