diff --git a/.dockerignore b/.dockerignore
deleted file mode 100644
index 92d6c40..0000000
--- a/.dockerignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*
-!dist/
diff --git a/.drone.jsonnet b/.drone.jsonnet
deleted file mode 100644
index 9220851..0000000
--- a/.drone.jsonnet
+++ /dev/null
@@ -1,349 +0,0 @@
-local PipelineTest = {
- kind: 'pipeline',
- name: 'test',
- platform: {
- os: 'linux',
- arch: 'amd64',
- },
- steps: [
- {
- name: 'deps',
- image: 'golang:1.19',
- commands: [
- 'make deps',
- ],
- volumes: [
- {
- name: 'godeps',
- path: '/go',
- },
- ],
- },
- {
- name: 'lint',
- image: 'golang:1.19',
- commands: [
- 'make lint',
- ],
- volumes: [
- {
- name: 'godeps',
- path: '/go',
- },
- ],
- },
- {
- name: 'test',
- image: 'golang:1.19',
- commands: [
- 'make test',
- ],
- volumes: [
- {
- name: 'godeps',
- path: '/go',
- },
- ],
- },
- ],
- volumes: [
- {
- name: 'godeps',
- temp: {},
- },
- ],
- trigger: {
- ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
- },
-};
-
-
-local PipelineBuildBinaries = {
- kind: 'pipeline',
- name: 'build-binaries',
- platform: {
- os: 'linux',
- arch: 'amd64',
- },
- steps: [
- {
- name: 'build',
- image: 'techknowlogick/xgo:go-1.19.x',
- commands: [
- 'ln -s /drone/src /source',
- 'make release',
- ],
- },
- {
- name: 'executable',
- image: 'alpine',
- commands: [
- '$(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help',
- ],
- },
- {
- name: 'changelog-generate',
- image: 'thegeeklab/git-chglog',
- commands: [
- 'git fetch -tq',
- 'git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased}',
- ],
- },
- {
- name: 'changelog-format',
- image: 'thegeeklab/alpine-tools',
- commands: [
- 'prettier CHANGELOG.md',
- 'prettier -w CHANGELOG.md',
- ],
- },
- {
- name: 'publish',
- image: 'plugins/github-release',
- settings: {
- overwrite: true,
- api_key: {
- from_secret: 'github_token',
- },
- files: ['dist/*'],
- title: '${DRONE_TAG}',
- note: 'CHANGELOG.md',
- },
- when: {
- ref: [
- 'refs/tags/**',
- ],
- },
- },
- ],
- depends_on: [
- 'test',
- ],
- trigger: {
- ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
- },
-};
-
-local PipelineBuildContainer(arch='amd64') = {
- kind: 'pipeline',
- name: 'build-container-' + arch,
- platform: {
- os: 'linux',
- arch: arch,
- },
- steps: [
- {
- name: 'build',
- image: 'golang:1.19',
- commands: [
- 'make build',
- ],
- },
- {
- name: 'dryrun',
- image: 'thegeeklab/drone-docker-buildx:20',
- settings: {
- dry_run: true,
- dockerfile: 'docker/Dockerfile.' + arch,
- repo: 'thegeeklab/${DRONE_REPO_NAME}',
- },
- depends_on: ['build'],
- when: {
- ref: ['refs/pull/**'],
- },
- },
- {
- name: 'publish-dockerhub',
- image: 'thegeeklab/drone-docker-buildx:20',
- settings: {
- auto_tag: true,
- auto_tag_suffix: arch,
- dockerfile: 'docker/Dockerfile.' + arch,
- repo: 'thegeeklab/${DRONE_REPO_NAME}',
- username: { from_secret: 'docker_username' },
- password: { from_secret: 'docker_password' },
- },
- when: {
- ref: ['refs/heads/main', 'refs/tags/**'],
- },
- depends_on: ['dryrun'],
- },
- {
- name: 'publish-quay',
- image: 'thegeeklab/drone-docker-buildx:20',
- settings: {
- auto_tag: true,
- auto_tag_suffix: arch,
- dockerfile: 'docker/Dockerfile.' + arch,
- registry: 'quay.io',
- repo: 'quay.io/thegeeklab/${DRONE_REPO_NAME}',
- username: { from_secret: 'quay_username' },
- password: { from_secret: 'quay_password' },
- },
- when: {
- ref: ['refs/heads/main', 'refs/tags/**'],
- },
- depends_on: ['dryrun'],
- },
- ],
- depends_on: [
- 'test',
- ],
- trigger: {
- ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
- },
-};
-
-local PipelineDocs = {
- kind: 'pipeline',
- name: 'docs',
- platform: {
- os: 'linux',
- arch: 'amd64',
- },
- concurrency: {
- limit: 1,
- },
- steps: [
- {
- name: 'markdownlint',
- image: 'thegeeklab/markdownlint-cli',
- commands: [
- "markdownlint 'docs/content/**/*.md' 'README.md' 'CONTRIBUTING.md'",
- ],
- },
- {
- name: 'spellcheck',
- image: 'thegeeklab/alpine-tools',
- commands: [
- "spellchecker --files '_docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls --no-suggestions",
- ],
- environment: {
- FORCE_COLOR: true,
- NPM_CONFIG_LOGLEVEL: 'error',
- },
- },
- {
- name: 'publish',
- image: 'plugins/gh-pages',
- settings: {
- username: { from_secret: 'github_username' },
- password: { from_secret: 'github_token' },
- pages_directory: '_docs/',
- target_branch: 'docs',
- },
- when: {
- ref: ['refs/heads/main'],
- },
- },
- ],
- depends_on: [
- 'build-binaries',
- 'build-container-amd64',
- 'build-container-arm64',
- ],
- trigger: {
- ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
- },
-};
-
-local PipelineNotifications = {
- kind: 'pipeline',
- name: 'notifications',
- platform: {
- os: 'linux',
- arch: 'amd64',
- },
- steps: [
- {
- image: 'plugins/manifest',
- name: 'manifest-dockerhub',
- settings: {
- ignore_missing: true,
- auto_tag: true,
- username: { from_secret: 'docker_username' },
- password: { from_secret: 'docker_password' },
- spec: 'docker/manifest.tmpl',
- },
- when: {
- status: ['success'],
- },
- },
- {
- image: 'plugins/manifest',
- name: 'manifest-quay',
- settings: {
- ignore_missing: true,
- auto_tag: true,
- username: { from_secret: 'quay_username' },
- password: { from_secret: 'quay_password' },
- spec: 'docker/manifest-quay.tmpl',
- },
- when: {
- status: ['success'],
- },
- },
- {
- name: 'pushrm-dockerhub',
- image: 'chko/docker-pushrm:1',
- environment: {
- DOCKER_PASS: {
- from_secret: 'docker_password',
- },
- DOCKER_USER: {
- from_secret: 'docker_username',
- },
- PUSHRM_FILE: 'README.md',
- PUSHRM_SHORT: 'Drone Admin Tools',
- PUSHRM_TARGET: 'thegeeklab/${DRONE_REPO_NAME}',
- },
- when: {
- status: ['success'],
- },
- },
- {
- name: 'pushrm-quay',
- image: 'chko/docker-pushrm:1',
- environment: {
- APIKEY__QUAY_IO: {
- from_secret: 'quay_token',
- },
- PUSHRM_FILE: 'README.md',
- PUSHRM_TARGET: 'quay.io/thegeeklab/${DRONE_REPO_NAME}',
- },
- when: {
- status: ['success'],
- },
- },
- {
- name: 'matrix',
- image: 'thegeeklab/drone-matrix',
- settings: {
- homeserver: { from_secret: 'matrix_homeserver' },
- roomid: { from_secret: 'matrix_roomid' },
- template: 'Status: **{{ build.Status }}**
Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.Link }}){{#if build.Branch}} ({{ build.Branch }}){{/if}} by {{ commit.Author }}
Message: {{ commit.Message.Title }}',
- username: { from_secret: 'matrix_username' },
- password: { from_secret: 'matrix_password' },
- },
- when: {
- status: ['success', 'failure'],
- },
- },
- ],
- depends_on: [
- 'docs',
- ],
- trigger: {
- ref: ['refs/heads/main', 'refs/tags/**'],
- status: ['success', 'failure'],
- },
-};
-
-[
- PipelineTest,
- PipelineBuildBinaries,
- PipelineBuildContainer(arch='amd64'),
- PipelineBuildContainer(arch='arm64'),
- PipelineDocs,
- PipelineNotifications,
-]
diff --git a/.drone.yml b/.drone.yml
index 73e8a61..929409d 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -98,38 +98,42 @@ depends_on:
---
kind: pipeline
-name: build-container-amd64
+name: build-container
platform:
os: linux
arch: amd64
steps:
- - name: build
- image: golang:1.19
- commands:
- - make build
-
- name: dryrun
image: thegeeklab/drone-docker-buildx:20
settings:
- dockerfile: docker/Dockerfile.amd64
+ dockerfile: Dockerfile.multiarch
dry_run: true
+ platforms:
+ - linux/amd64
+ - linux/arm64
+ - linux/arm/v7
+ - linux/arm/v6
+ provenance: false
repo: thegeeklab/${DRONE_REPO_NAME}
when:
ref:
- refs/pull/**
- depends_on:
- - build
- name: publish-dockerhub
image: thegeeklab/drone-docker-buildx:20
settings:
auto_tag: true
- auto_tag_suffix: amd64
- dockerfile: docker/Dockerfile.amd64
+ dockerfile: Dockerfile.multiarch
password:
from_secret: docker_password
+ platforms:
+ - linux/amd64
+ - linux/arm64
+ - linux/arm/v7
+ - linux/arm/v6
+ provenance: false
repo: thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: docker_username
@@ -144,82 +148,15 @@ steps:
image: thegeeklab/drone-docker-buildx:20
settings:
auto_tag: true
- auto_tag_suffix: amd64
- dockerfile: docker/Dockerfile.amd64
- password:
- from_secret: quay_password
- registry: quay.io
- repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
- username:
- from_secret: quay_username
- when:
- ref:
- - refs/heads/main
- - refs/tags/**
- depends_on:
- - dryrun
-
-trigger:
- ref:
- - refs/heads/main
- - refs/tags/**
- - refs/pull/**
-
-depends_on:
- - test
-
----
-kind: pipeline
-name: build-container-arm64
-
-platform:
- os: linux
- arch: arm64
-
-steps:
- - name: build
- image: golang:1.19
- commands:
- - make build
-
- - name: dryrun
- image: thegeeklab/drone-docker-buildx:20
- settings:
- dockerfile: docker/Dockerfile.arm64
- dry_run: true
- repo: thegeeklab/${DRONE_REPO_NAME}
- when:
- ref:
- - refs/pull/**
- depends_on:
- - build
-
- - name: publish-dockerhub
- image: thegeeklab/drone-docker-buildx:20
- settings:
- auto_tag: true
- auto_tag_suffix: arm64
- dockerfile: docker/Dockerfile.arm64
- password:
- from_secret: docker_password
- repo: thegeeklab/${DRONE_REPO_NAME}
- username:
- from_secret: docker_username
- when:
- ref:
- - refs/heads/main
- - refs/tags/**
- depends_on:
- - dryrun
-
- - name: publish-quay
- image: thegeeklab/drone-docker-buildx:20
- settings:
- auto_tag: true
- auto_tag_suffix: arm64
- dockerfile: docker/Dockerfile.arm64
+ dockerfile: Dockerfile.multiarch
password:
from_secret: quay_password
+ platforms:
+ - linux/amd64
+ - linux/arm64
+ - linux/arm/v7
+ - linux/arm/v6
+ provenance: false
registry: quay.io
repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
username:
@@ -286,8 +223,7 @@ trigger:
depends_on:
- build-binaries
- - build-container-amd64
- - build-container-arm64
+ - build-container
---
kind: pipeline
@@ -298,34 +234,6 @@ platform:
arch: amd64
steps:
- - name: manifest-dockerhub
- image: plugins/manifest
- settings:
- auto_tag: true
- ignore_missing: true
- password:
- from_secret: docker_password
- spec: docker/manifest.tmpl
- username:
- from_secret: docker_username
- when:
- status:
- - success
-
- - name: manifest-quay
- image: plugins/manifest
- settings:
- auto_tag: true
- ignore_missing: true
- password:
- from_secret: quay_password
- spec: docker/manifest-quay.tmpl
- username:
- from_secret: quay_username
- when:
- status:
- - success
-
- name: pushrm-dockerhub
image: chko/docker-pushrm:1
environment:
@@ -381,6 +289,6 @@ depends_on:
---
kind: signature
-hmac: 5917d97d7142ecdc72c3f4f5fe37ade695f05e90cf162c6c017eaa7767bf1e31
+hmac: fe8e83619566fffc192a7f365503b31b409e7701a454e41a34f1e13ce3ec9e20
...
diff --git a/docker/Dockerfile.amd64 b/Dockerfile.multiarch
similarity index 67%
rename from docker/Dockerfile.amd64
rename to Dockerfile.multiarch
index 9fcfe09..eff827a 100644
--- a/docker/Dockerfile.amd64
+++ b/Dockerfile.multiarch
@@ -1,3 +1,14 @@
+FROM --platform=$BUILDPLATFORM golang:1.19@sha256:bb9811fad43a7d6fd2173248d8331b2dcf5ac9af20976b1937ecd214c5b8c383 as build
+
+ARG TARGETOS
+ARG TARGETARCH
+ARG TARGETVARIANT
+
+ADD . /src
+WORKDIR /src
+
+RUN make build
+
FROM alpine:3.17@sha256:f271e74b17ced29b915d351685fd4644785c6d1559dd1f2d4189a5e851ef753a
LABEL maintainer="Robert Kaussow "
@@ -7,5 +18,5 @@ LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-admin"
LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-admin"
LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-admin"
-ADD dist/drone-admin /bin/
+COPY --from=build /src/dist/drone-admin /bin/drone-admin
ENTRYPOINT [ "/bin/drone-admin" ]
diff --git a/Makefile b/Makefile
index 2bf9d74..e7dd89e 100644
--- a/Makefile
+++ b/Makefile
@@ -20,8 +20,13 @@ XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
GENERATE ?=
XGO_VERSION := go-1.19.x
-XGO_TARGETS ?= linux/amd64,linux/arm64
+XGO_TARGETS ?= linux/amd64,linux/arm64,linux/arm-6,linux/arm-7
+TARGETOS ?= linux
+TARGETARCH ?= amd64
+ifneq ("$(TARGETVARIANT)","")
+GOARM ?= $(subst v,,$(TARGETVARIANT))
+endif
TAGS ?= netgo
ifndef VERSION
@@ -69,14 +74,14 @@ test:
build: $(DIST)/$(EXECUTABLE)
$(DIST)/$(EXECUTABLE): $(SOURCES)
- $(GO) build -v -tags '$(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -o $@ ./cmd/$(EXECUTABLE)
+ GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=$(GOARM) $(GO) build -v -tags '$(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -o $@ ./cmd/$(EXECUTABLE)
$(DIST_DIRS):
mkdir -p $(DIST_DIRS)
.PHONY: xgo
xgo: | $(DIST_DIRS)
- $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -v -ldflags '-extldflags "-static" $(LDFLAGS)' -tags '$(TAGS)' -targets '$(XGO_TARGETS)' -out $(EXECUTABLE) --pkg cmd/$(EXECUTABLE) .
+ GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=$(GOARM) $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -v -ldflags '-extldflags "-static" $(LDFLAGS)' -tags '$(TAGS)' -targets '$(XGO_TARGETS)' -out $(EXECUTABLE) --pkg cmd/$(EXECUTABLE) .
cp /build/* $(CWD)/$(DIST)
ls -l $(CWD)/$(DIST)
diff --git a/docker/Dockerfile.arm64 b/docker/Dockerfile.arm64
deleted file mode 100644
index 3e0c7f6..0000000
--- a/docker/Dockerfile.arm64
+++ /dev/null
@@ -1,11 +0,0 @@
-FROM arm64v8/alpine:3.17@sha256:41d876d4e44348d1c27445fdb0e64592e0eb926d4dbbcf09a3526dee7e628329
-
-LABEL maintainer="Robert Kaussow "
-LABEL org.opencontainers.image.authors="Robert Kaussow "
-LABEL org.opencontainers.image.title="drone-admin"
-LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-admin"
-LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-admin"
-LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-admin"
-
-ADD dist/drone-admin /bin/
-ENTRYPOINT [ "/bin/drone-admin" ]
diff --git a/docker/manifest-quay.tmpl b/docker/manifest-quay.tmpl
deleted file mode 100644
index 41dd1c9..0000000
--- a/docker/manifest-quay.tmpl
+++ /dev/null
@@ -1,18 +0,0 @@
-image: quay.io/thegeeklab/drone-admin:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
-{{#if build.tags}}
-tags:
-{{#each build.tags}}
- - {{this}}
-{{/each}}
-{{/if}}
-manifests:
- - image: quay.io/thegeeklab/drone-admin:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}amd64
- platform:
- architecture: amd64
- os: linux
-
- - image: quay.io/thegeeklab/drone-admin:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm64
- platform:
- architecture: arm64
- os: linux
- variant: v8
diff --git a/docker/manifest.tmpl b/docker/manifest.tmpl
deleted file mode 100644
index c02de5f..0000000
--- a/docker/manifest.tmpl
+++ /dev/null
@@ -1,18 +0,0 @@
-image: thegeeklab/drone-admin:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
-{{#if build.tags}}
-tags:
-{{#each build.tags}}
- - {{this}}
-{{/each}}
-{{/if}}
-manifests:
- - image: thegeeklab/drone-admin:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}amd64
- platform:
- architecture: amd64
- os: linux
-
- - image: thegeeklab/drone-admin:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm64
- platform:
- architecture: arm64
- os: linux
- variant: v8