From 73dada42ed480d193df4930590ca15f9e26f49a5 Mon Sep 17 00:00:00 2001 From: paspo Date: Thu, 13 Jul 2023 14:40:40 +0200 Subject: [PATCH] new drone --- .drone.star | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++ .drone.yaml | 49 -------------------- Dockerfile | 2 +- README.md | 6 +++ manifest.tmpl | 25 ++++++++++ 5 files changed, 158 insertions(+), 50 deletions(-) create mode 100644 .drone.star delete mode 100644 .drone.yaml create mode 100644 manifest.tmpl diff --git a/.drone.star b/.drone.star new file mode 100644 index 0000000..aaca9c0 --- /dev/null +++ b/.drone.star @@ -0,0 +1,126 @@ +def main(ctx): + archs = ["amd64", "arm64"] ## arm + glpi_version = "10.0.9" + + out = [] + for arch in archs: + out += onpush(ctx, glpi_version, arch) + + for arch in archs: + out += build_publish(ctx, glpi_version, arch) + + out += manifest_publish(ctx, glpi_version, archs) + + return out + +def onpush(ctx, glpi_version, arch): + return [{ + "kind": "pipeline", + "type": "docker", + "name": "build-onpush-%s-%s" % (glpi_version, arch), + "platform": { + "arch": arch, + "os": "linux", + }, + "steps": [{ + "name": "build_on_push", + "image": "plugins/docker:linux-%s" % (arch), + "settings": { + "context": ".", + "dockerfile": "./Dockerfile", + "dry_run": True, + "repo": "docker.asperti.com/paspo/glpi", + "build_args": [ + "GLPI_VERSION=%s" % (glpi_version) + ], + }, + }], + "trigger": { + "event": ['push'], + } + }] + +def build_publish(ctx, glpi_version, arch): + major = glpi_version.partition(".")[0]; + return [{ + "kind": "pipeline", + "type": "docker", + "name": "build-publish-%s-%s" % (glpi_version, arch), + "platform": { + "arch": arch, + "os": "linux", + }, + "steps": [{ + "name": "build_on_push", + "image": "plugins/docker:linux-%s" % (arch), + "settings": { + "context": ".", + "dockerfile": "./Dockerfile", + "build_args": [ + "GLPI_VERSION=%s" % (glpi_version) + ], + "username": { + "from_secret": "docker_username", + }, + "password": { + "from_secret": "docker_password", + }, + "registry": "docker.asperti.com", + "repo": "docker.asperti.com/paspo/glpi", + "tags": [ + "latest-%s" % (arch), + "%s-%s" % (major, arch), + "%s-%s" % (glpi_version, arch) + ], + "auto_tag": False, + "force_tag": True, + "daemon_off": False, + }, + }], + "trigger": { + "ref": [ + "refs/heads/master", + "refs/tags/**", + ], + }, + }] + +def manifest_publish(ctx, glpi_version, archs): + major = glpi_version.partition(".")[0]; + return [{ + "kind": "pipeline", + "type": "docker", + "name": "manifest-%s" % (glpi_version), + "platform": { + "arch": archs[0], + "os": "linux", + }, + "steps": [{ + "name": "manifest", + "image": "plugins/manifest", + "settings": { + "spec": "manifest.tmpl", + "username": { + "from_secret": "docker_username", + }, + "password": { + "from_secret": "docker_password", + }, + "tags": [ + "latest", + major, + glpi_version + ], + "ignore_missing": True, + "force_tag": True, + }, + }], + "trigger": { + "ref": [ + "refs/heads/master", + "refs/tags/**", + ], + }, + "depends_on": ["build-publish-%s-%s" % (glpi_version, arch) for arch in archs] + }] + diff --git a/.drone.yaml b/.drone.yaml deleted file mode 100644 index 1fbcf6b..0000000 --- a/.drone.yaml +++ /dev/null @@ -1,49 +0,0 @@ -kind: pipeline -type: docker -name: default - -steps: - - name: build_and_publish_tag - image: plugins/docker:linux-amd64 - settings: - force_tag: true - password: - from_secret: docker_password - registry: docker.asperti.com - repo: docker.asperti.com/paspo/glpi - context: . - dockerfile: ./Dockerfile - build_args: - - GLPI_VERSION=10.0.9 - username: - from_secret: docker_username - tags: - - latest - - ${DRONE_TAG} - - ${DRONE_SEMVER_MAJOR}.${DRONE_SEMVER_MINOR} - when: - event: - - tag - - - name: build_and_publish - image: plugins/docker:linux-amd64 - settings: - force_tag: true - password: - from_secret: docker_password - registry: docker.asperti.com - repo: docker.asperti.com/paspo/glpi - context: . - dockerfile: ./Dockerfile - build_args: - - GLPI_VERSION=10.0.9 - username: - from_secret: docker_username - tags: - - latest - when: - branch: - - master - event: - - push - - cron diff --git a/Dockerfile b/Dockerfile index b65529b..5cac898 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM alpine:3.18 -ARG GLPI_VERSION=10.0.8 +ARG GLPI_VERSION RUN \ mkdir -p /logs /config /files /marketplace && \ diff --git a/README.md b/README.md index a7242dd..0c9816d 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,9 @@ docker build -t docker.asperti.com/paspo/glpi . ## run see [docker-compose.yaml](docker-compose.yaml) + +## test drone config + +```sh +drone starlark --format --stdout +``` diff --git a/manifest.tmpl b/manifest.tmpl new file mode 100644 index 0000000..2a3ea1b --- /dev/null +++ b/manifest.tmpl @@ -0,0 +1,25 @@ +image: docker.asperti.com/paspo/glpi:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}} +{{#if build.tags}} +tags: +{{#each build.tags}} + - {{this}} +{{/each}} +{{/if}} +manifests: + - + image: docker.asperti.com/paspo/glpi:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}-amd64 + platform: + architecture: amd64 + os: linux + - + image: docker.asperti.com/paspo/glpi:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}-arm64 + platform: + variant: v8 + architecture: arm64 + os: linux + - + image: docker.asperti.com/paspo/glpi:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}-arm + platform: + variant: v7 + architecture: arm + os: linux