This commit is contained in:
parent
b5a19bb1d2
commit
44a54f1c7f
101
.drone.yml
101
.drone.yml
@ -1,28 +1,87 @@
|
||||
platform: ${platform}
|
||||
kind: pipeline
|
||||
name: test
|
||||
|
||||
workspace:
|
||||
base: /go
|
||||
base: /go/src/dockron
|
||||
|
||||
pipeline:
|
||||
build:
|
||||
image: golang:1.10
|
||||
steps:
|
||||
- name: build
|
||||
image: golang:1.11
|
||||
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}
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- platform: linux/amd64
|
||||
docker_tag: latest
|
||||
# - platform: linux/arm
|
||||
# docker_tag: linux-arm
|
||||
---
|
||||
kind: pipeline
|
||||
name: publish
|
||||
|
||||
depends_on:
|
||||
- test
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
refs:
|
||||
- refs/heads/master
|
||||
- refs/tags/v*
|
||||
|
||||
workspace:
|
||||
base: /go/src/dockron
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: golang:1.11
|
||||
commands:
|
||||
- go get -u github.com/golang/dep/cmd/dep
|
||||
- make build-all-static
|
||||
|
||||
- name: push image - arm
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: iamthefij/dockron
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
build_args:
|
||||
- ARCH=arm
|
||||
- REPO=arm32v6
|
||||
|
||||
- name: push image - arm64
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: iamthefij/dockron
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
build_args:
|
||||
- ARCH=arm
|
||||
- REPO=arm32v6
|
||||
|
||||
- name: push image - amd64
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: iamthefij/dockron
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-amd64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
|
||||
- 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
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -26,5 +26,6 @@ _testmain.go
|
||||
|
||||
# Output
|
||||
dockron
|
||||
dockron-linux-*
|
||||
# deps
|
||||
vendor/
|
||||
|
29
Dockerfile
29
Dockerfile
@ -1,16 +1,21 @@
|
||||
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/
|
||||
# COPY ./Gopkg.* /go/src/app/
|
||||
# RUN dep ensure --vendor-only
|
||||
#
|
||||
# COPY ./main.go /go/src/app/
|
||||
#
|
||||
# RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -a -installsuffix nocgo -o dockron .
|
||||
|
||||
RUN go get -u github.com/golang/dep/cmd/dep
|
||||
|
||||
WORKDIR /go/src/app/
|
||||
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
|
||||
FROM ${REPO}/busybox:latest
|
||||
WORKDIR /root/
|
||||
COPY --from=builder /go/src/app/dockron .
|
||||
# COPY --from=builder /go/src/app/dockron .
|
||||
ARG ARCH=amd64
|
||||
COPY ./dockron-linux-${ARCH} ./dockron
|
||||
|
||||
CMD [ "./dockron" ]
|
||||
|
38
Makefile
38
Makefile
@ -1,4 +1,4 @@
|
||||
DOCKER_TAG ?= dockron-dev
|
||||
DOCKER_TAG ?= dockron-dev-${USER}
|
||||
|
||||
.PHONY: default
|
||||
default: build
|
||||
@ -20,6 +20,18 @@ dockron: vendor
|
||||
.PHONY: build
|
||||
build: dockron
|
||||
|
||||
dockron-linux-amd64: vendor
|
||||
GOARCH=amd64 CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o dockron-linux-amd64
|
||||
|
||||
dockron-linux-arm: vendor
|
||||
GOARCH=arm CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o dockron-linux-arm
|
||||
|
||||
dockron-linux-arm64: vendor
|
||||
GOARCH=arm64 CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o dockron-linux-arm64
|
||||
|
||||
.PHONY: build-all-static
|
||||
build-all-static: dockron-linux-amd64 dockron-linux-arm dockron-linux-arm64
|
||||
|
||||
# Cleans all build artifacts
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@ -37,8 +49,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