(maint) move to harness.drone.io

This commit is contained in:
TP Honey
2022-12-22 09:24:52 +00:00
parent e57a6d22e3
commit 6775028e9b
8 changed files with 272 additions and 462 deletions

View File

@@ -1,105 +0,0 @@
# go version
go = "golang:1.13"
# docker repository
repo = "drone/drone-runner-docker"
def main(ctx):
return [
pipeline_linux(),
pipeline_windows("1903"),
pipeline_windows("1809"),
pipeline_manifest(),
# manifest
]
def pipeline_linux():
return {
"kind": "pipeline",
"type": "docker",
"name": "linux",
"steps": [
test,
build,
publish("arm"),
publish("arm64"),
publish("amd64"),
]
}
def pipeline_windows(version):
return {
"kind": "pipeline",
"type": "ssh",
"name": "windows_%s" % version,
"server": {
},
"platform": {
"os": "windows",
},
"steps": [
"sh scripts/ci_%s.ps1" % version,
],
}
def pipeline_manifest():
return [
"kind": "pipeline",
"type": "docker",
"name": "linux",
"steps": [
{
}
]
]
# publish creates a docker publish step.
def publish(arch):
return {
"name": "publish_%s" % arch,
"image": "plugins/docker",
"pull": "if-not-exists",
"settings": {
"auto_tag": "true",
"auto_tag_suffix": "linux-%s" % arch,
"dockerfile": "docker/Dockerfile.linux.%s" % arch,
"repo": repo,
},
"when": {
"event": [ "push", "tag" ]
}
}
# test defines a test step that downloads
# dependencies and tests the packages.
test = {
"name": "test",
"image": go,
"volumes": mounts,
"commands": [
"go test -v ./...",
],
}
# build defines a build step that compiles
# the binaries.
build = {
"name": "build",
"image": go,
"volumes": mounts,
"commands": [
"sh scripts/build.sh",
],
"when": {
"event": [ "push", "tag" ]
}
}
# mount points shared by all steps.
mounts = [{
"name": "go",
"path": "/go",
}]

View File

@@ -1,278 +1,327 @@
kind: pipeline kind: pipeline
type: docker type: vm
name: linux name: testing
pool:
use: ubuntu
platform: platform:
os: linux os: linux
arch: amd64 arch: amd64
steps: steps:
- name: test - name: test
image: golang:1.16 image: golang:1.16
commands: commands:
- go test -cover ./... - go test -cover ./...
volumes: volumes:
- name: go - name: go
path: /go path: /go
- name: build - name: build
image: golang:1.16 image: golang:1.16
commands: commands:
- sh scripts/build.sh - sh scripts/build.sh
volumes: volumes:
- name: go - name: go
path: /go path: /go
when:
event:
- push
- tag
- name: publish_amd64
image: plugins/docker
pull: if-not-exists
settings:
repo: drone/drone-runner-docker
auto_tag: true
auto_tag_suffix: linux-amd64
dockerfile: docker/Dockerfile.linux.amd64
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
ref:
- refs/heads/master
- refs/tags/*
- name: publish_arm
image: plugins/docker
pull: if-not-exists
settings:
repo: drone/drone-runner-docker
auto_tag: true
auto_tag_suffix: linux-arm
platform: linux/arm/v7
dockerfile: docker/Dockerfile.linux.arm
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
ref:
- refs/heads/master
- refs/tags/*
- name: publish_arm64
image: plugins/docker
pull: if-not-exists
settings:
repo: drone/drone-runner-docker
auto_tag: true
auto_tag_suffix: linux-arm64
platform: linux/arm64
dockerfile: docker/Dockerfile.linux.arm64
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
ref:
- refs/heads/master
- refs/tags/*
- name: publish_ppc64le
image: plugins/docker
pull: if-not-exists
settings:
repo: drone/drone-runner-docker
auto_tag: true
auto_tag_suffix: linux-ppc64le
platform: linux/ppc64le
dockerfile: docker/Dockerfile.linux.ppc64le
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
ref:
- refs/heads/master
- refs/tags/*
volumes: volumes:
- name: go - name: go
temp: {} temp: {}
--- ---
kind: pipeline kind: pipeline
type: ssh type: vm
name: windows-1903 name: linux-amd64
platform: platform:
os: windows os: linux
arch: amd64
server: pool:
host: use: ubuntu
from_secret: windows_server_1903
password:
from_secret: windows_password
user:
from_secret: windows_username
steps: steps:
- name: build_latest - name: environment
environment: image: golang:1.16
VERSION: 1903 pull: always
USERNAME: environment:
from_secret: docker_username CGO_ENABLED: "0"
PASSWORD: commands:
from_secret: docker_password - go version
commands: - go env
- powershell.exe scripts/windows/latest.ps1 - name: build
when: image: golang:1.16
event: [ push ] environment:
CGO_ENABLED: "0"
- name: build_tag commands:
environment: - go build -o release/linux/amd64/drone-runner-docker
VERSION: 1903 - name: publish
USERNAME: image: plugins/docker
from_secret: docker_username pull: if-not-exists
PASSWORD: settings:
from_secret: docker_password repo: drone/drone-runner-docker
commands: auto_tag: true
- powershell.exe scripts/windows/tag.ps1 auto_tag_suffix: linux-amd64
when: dockerfile: docker/Dockerfile.linux.amd64
event: [ tag ] username:
from_secret: docker_username
password:
from_secret: docker_password
when:
ref:
- refs/heads/master
- refs/tags/*
depends_on: depends_on:
- linux - testing
trigger: trigger:
ref: ref:
- refs/heads/master - refs/heads/master
- refs/tags/* - refs/tags/**
- refs/pull/**
---
kind: pipeline
type: vm
name: linux-arm64
platform:
os: linux
arch: arm64
pool:
use: ubuntu_arm64
steps:
- name: environment
image: golang:1.16
pull: always
environment:
CGO_ENABLED: "0"
commands:
- go version
- go env
- name: build
image: golang:1.16
environment:
CGO_ENABLED: "0"
commands:
- go build -o release/linux/arm64/drone-runner-docker
- name: publish
image: plugins/docker
pull: if-not-exists
settings:
repo: drone/drone-runner-docker
auto_tag: true
auto_tag_suffix: linux-arm64
dockerfile: docker/Dockerfile.linux.arm64
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
ref:
- refs/heads/master
- refs/tags/*
depends_on:
- testing
trigger:
ref:
- refs/heads/master
- refs/tags/**
- refs/pull/**
---
kind: pipeline
type: vm
name: linux-ppc64le
platform:
os: linux
arch: amd64
pool:
use: ubuntu
steps:
- name: environment
image: golang:1.16
pull: always
environment:
CGO_ENABLED: "0"
commands:
- go version
- go env
- name: build
image: golang:1.16
environment:
CGO_ENABLED: "0"
commands:
- go build -o release/linux/ppc64le/drone-runner-docker
- name: publish
image: plugins/docker
pull: if-not-exists
settings:
repo: drone/drone-runner-docker
auto_tag: true
auto_tag_suffix: linux-ppc64le
platform: linux/ppc64le
dockerfile: docker/Dockerfile.linux.ppc64le
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
ref:
- refs/heads/master
- refs/tags/*
depends_on:
- testing
trigger:
ref:
- refs/heads/master
- refs/tags/**
- refs/pull/**
--- ---
kind: pipeline kind: pipeline
type: ssh type: vm
name: windows-1809 name: windows-1809
platform: platform:
os: windows os: windows
arch: amd64
server: pool:
host: use: windows
from_secret: windows_server_1809
password:
from_secret: windows_password
user:
from_secret: windows_username
steps: steps:
- name: build_latest - name: environment
environment: image: golang:1.16
VERSION: 1809 pull: always
USERNAME: environment:
from_secret: docker_username CGO_ENABLED: "0"
PASSWORD: commands:
from_secret: docker_password - go version
commands: - go env
- powershell.exe scripts/windows/latest.ps1 - name: build
when: image: golang:1.16
event: [ push ] environment:
CGO_ENABLED: "0"
- name: build_tag commands:
environment: - go build -o release/windows/amd64/drone-runner-docker.exe
VERSION: 1809 - name: docker
USERNAME: image: plugins/docker
from_secret: docker_username settings:
PASSWORD: dockerfile: docker/Dockerfile.windows.1809
from_secret: docker_password repo: drone/drone-runner-docker
commands: username:
- powershell.exe scripts/windows/tag.ps1 from_secret: docker_username
when: password:
event: [ tag ] from_secret: docker_password
auto_tag: true
auto_tag_suffix: windows-1809-amd64
daemon_off: true
purge: false
when:
ref:
- refs/heads/master
- refs/tags/**
depends_on: depends_on:
- linux - testing
trigger: trigger:
ref: ref:
- refs/heads/master - refs/heads/master
- refs/tags/* - refs/tags/**
- refs/pull/**
--- ---
kind: pipeline kind: pipeline
type: ssh type: vm
name: windows-1909 name: windows-ltsc2022
platform: platform:
os: windows os: windows
arch: amd64
server: pool:
host: use: windows-2022
from_secret: windows_server_1909
password:
from_secret: windows_password
user:
from_secret: windows_username
steps: steps:
- name: build_latest - name: environment
environment: image: golang:1.16
VERSION: 1909 pull: always
USERNAME: environment:
from_secret: docker_username CGO_ENABLED: "0"
PASSWORD: commands:
from_secret: docker_password - go version
commands: - go env
- powershell.exe scripts/windows/latest.ps1 - name: build
when: image: golang:1.16
event: [ push ] environment:
CGO_ENABLED: "0"
- name: build_tag commands:
environment: - go build -o release/windows/amd64/drone-runner-docker.exe
VERSION: 1909 - name: docker
USERNAME: image: plugins/docker
from_secret: docker_username settings:
PASSWORD: dockerfile: docker/Dockerfile.windows.ltsc2022
from_secret: docker_password repo: drone/drone-runner-docker
commands: username:
- powershell.exe scripts/windows/tag.ps1 from_secret: docker_username
when: password:
event: [ tag ] from_secret: docker_password
auto_tag: true
auto_tag_suffix: windows-ltsc2022-amd64
daemon_off: true
purge: false
when:
ref:
- refs/heads/master
- refs/tags/**
depends_on: depends_on:
- linux - testing
trigger: trigger:
ref: ref:
- refs/heads/master - refs/heads/master
- refs/tags/* - refs/tags/**
- refs/pull/**
--- ---
kind: pipeline kind: pipeline
type: docker type: docker
name: manifest name: manifest
steps: steps:
- name: manifest - name: manifest
image: plugins/manifest image: plugins/manifest
settings: settings:
spec: docker/manifest.tmpl spec: docker/manifest.tmpl
auto_tag: true auto_tag: true
ignore_missing: true ignore_missing: true
password: password:
from_secret: docker_password from_secret: docker_password
username: username:
from_secret: docker_username from_secret: docker_username
depends_on: depends_on:
- windows-1903 - linux-amd64
- windows-1809 - linux-arm64
- windows-1909 - linux-ppc64le
- windows-1809
- windows-ltsc2022
trigger: trigger:
ref: ref:
- refs/heads/master - refs/heads/master
- refs/tags/* - refs/tags/*

View File

@@ -1,22 +0,0 @@
FROM alpine:3 as alpine
RUN apk add -U --no-cache ca-certificates
RUN wget https://github.com/tmate-io/tmate/releases/download/2.4.0/tmate-2.4.0-static-linux-arm32v7.tar.xz
RUN tar -xf tmate-2.4.0-static-linux-arm32v7.tar.xz
RUN mv tmate-2.4.0-static-linux-arm32v7/tmate /bin/
RUN chmod +x /bin/tmate
FROM scratch
EXPOSE 3000
ENV GODEBUG netdns=go
ENV DRONE_PLATFORM_OS linux
ENV DRONE_PLATFORM_ARCH arm
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=alpine /bin/tmate /bin/
LABEL com.centurylinklabs.watchtower.stop-signal="SIGINT"
ADD release/linux/arm/drone-runner-docker /bin/
ENTRYPOINT ["/bin/drone-runner-docker"]

View File

@@ -1,12 +0,0 @@
# escape=`
FROM mcr.microsoft.com/windows/nanoserver:1909
USER ContainerAdministrator
EXPOSE 3000
ENV GODEBUG netdns=go
ENV DRONE_PLATFORM_OS windows
ENV DRONE_PLATFORM_ARCH amd64
ENV DRONE_PLATFORM_KERNEL 1909
ADD release/windows/amd64/drone-runner-docker.exe C:/drone-runner-docker.exe
ENTRYPOINT [ "C:\\drone-runner-docker.exe" ]

View File

@@ -1,12 +1,12 @@
# escape=` # escape=`
FROM mcr.microsoft.com/windows/nanoserver:1903 FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
USER ContainerAdministrator USER ContainerAdministrator
EXPOSE 3000 EXPOSE 3000
ENV GODEBUG netdns=go ENV GODEBUG=netdns=go
ENV DRONE_PLATFORM_OS windows ENV DRONE_PLATFORM_OS windows
ENV DRONE_PLATFORM_ARCH amd64 ENV DRONE_PLATFORM_ARCH amd64
ENV DRONE_PLATFORM_KERNEL 1903 ENV DRONE_PLATFORM_KERNEL ltsc2022
ADD release/windows/amd64/drone-runner-docker.exe C:/drone-runner-docker.exe ADD release/windows/amd64/drone-runner-docker.exe C:/drone-runner-docker.exe
ENTRYPOINT [ "C:\\drone-runner-docker.exe" ] ENTRYPOINT [ "C:\\drone-runner-docker.exe" ]

View File

@@ -17,29 +17,11 @@ manifests:
variant: v8 variant: v8
architecture: arm64 architecture: arm64
os: linux os: linux
-
image: drone/drone-runner-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
variant: v7
architecture: arm
os: linux
-
image: drone/drone-runner-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
variant: v6
architecture: arm
os: linux
- -
image: drone/drone-runner-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-ppc64le image: drone/drone-runner-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-ppc64le
platform: platform:
architecture: ppc64le architecture: ppc64le
os: linux os: linux
-
image: drone/drone-runner-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64
platform:
architecture: amd64
os: windows
version: 1803
- -
image: drone/drone-runner-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64 image: drone/drone-runner-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
platform: platform:
@@ -47,14 +29,8 @@ manifests:
os: windows os: windows
version: 1809 version: 1809
- -
image: drone/drone-runner-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64 image: drone/drone-runner-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-ltsc2022-amd64
platform: platform:
architecture: amd64 architecture: amd64
os: windows os: windows
version: 1903 version: ltsc2022
-
image: drone/drone-runner-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
platform:
architecture: amd64
os: windows
version: 1909

View File

@@ -1,25 +0,0 @@
# this script is used by the continuous integration server to
# build and publish the docker image for a commit to master.
$env:GOOS="windows"
$env:GOARCH="amd64"
$env:CGO_ENABLED="0"
if (-not (Test-Path env:VERSION)) {
$env:VERSION="1809"
}
echo $env:GOOS
echo $env:GOARCH
echo $env:VERSION
# build the binary
go build -o release/windows/amd64/drone-runner-docker.exe
# build and publish the docker image
docker login -u $env:USERNAME -p $env:PASSWORD
docker build -f docker/Dockerfile.windows.amd64.$env:VERSION -t drone/drone-runner-docker:windows-$env:VERSION-amd64 .
docker push drone/drone-runner-docker:windows-$env:VERSION-amd64
# remove images from local cache
docker rmi drone/drone-runner-docker:windows-$env:VERSION-amd64

View File

@@ -1,51 +0,0 @@
# this script is used by the continuous integration server to
# build and publish the docker image for a tagged revsision.
$env:GOOS="windows"
$env:GOARCH="amd64"
$env:CGO_ENABLED="0"
if (-not (Test-Path env:VERSION)) {
$env:VERSION="1809"
}
if (-not (Test-Path env:DRONE_SEMVER_SHORT)) {
echo "missing semver"
exit 1
}
# define the image tags
$env:IMAGE_PATCH="drone/drone-runner-docker:$env:DRONE_SEMVER_SHORT-windows-$env:VERSION-amd64"
$env:IMAGE_MAJOR="drone/drone-runner-docker:$env:DRONE_SEMVER_MAJOR-windows-$env:VERSION-amd64"
$env:IMAGE_MINOR="drone/drone-runner-docker:$env:DRONE_SEMVER_MAJOR.$env:DRONE_SEMVER_MINOR-windows-$env:VERSION-amd64"
echo "build environment:"
echo $env:GOOS
echo $env:GOARCH
echo $env:VERSION
# build the binary
go build -o release/windows/amd64/drone-runner-docker.exe
# authenticate with the docker registry
docker login -u $env:USERNAME -p $env:PASSWORD
echo "building images:"
echo $env:IMAGE_PATCH
echo $env:IMAGE_MINOR
echo $env:IMAGE_MAJOR
# build and tag the docker images
docker build -f docker/Dockerfile.windows.amd64.$env:VERSION -t $env:IMAGE_PATCH .
docker tag $env:IMAGE_PATCH $env:IMAGE_MAJOR
docker tag $env:IMAGE_PATCH $env:IMAGE_MINOR
# publish the docker images
docker push $env:IMAGE_MAJOR
docker push $env:IMAGE_MINOR
docker push $env:IMAGE_PATCH
# remove images after from local cache
docker rmi $env:IMAGE_MAJOR
docker rmi $env:IMAGE_MINOR
docker rmi $env:IMAGE_PATCH