From 38dea5e7f7e5448fdf7044343fd46519761dee09 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sat, 22 Feb 2020 14:44:39 +0100 Subject: [PATCH] refactoring and versioning fix --- .dockerignore | 8 - .drone.jsonnet | 162 +++++++++--------- .drone.yml | 80 ++++----- Dockerfile.linux.amd64 => Dockerfile | 18 +- manifest.tmpl | 4 +- overlay/.tarignore | 2 + .../local/bin/{entrypoint.sh => entrypoint} | 3 +- .../local/bin/{healthcheck.sh => healthcheck} | 3 +- 8 files changed, 132 insertions(+), 148 deletions(-) delete mode 100644 .dockerignore rename Dockerfile.linux.amd64 => Dockerfile (77%) create mode 100644 overlay/.tarignore rename overlay/usr/local/bin/{entrypoint.sh => entrypoint} (93%) rename overlay/usr/local/bin/{healthcheck.sh => healthcheck} (91%) diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index e46e3b4..0000000 --- a/.dockerignore +++ /dev/null @@ -1,8 +0,0 @@ -.git -.git* -.drone.* -*.md -.dockerignore -Dockerfile -Dockerfile.* -docker-compose.yml diff --git a/.drone.jsonnet b/.drone.jsonnet index 7ea8ce1..bae3ec8 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,44 +1,43 @@ -local PipelineBuild(os='linux', arch='amd64') = { - local tag = os + '-' + arch, - local version_tag = os + '-' + arch, - local file_suffix = std.strReplace(version_tag, '-', '.'), - kind: "pipeline", - name: version_tag, +local PipelineBuild(arch='amd64') = { + kind: 'pipeline', + name: 'build-' + arch, platform: { - os: os, + os: 'linux', arch: arch, }, steps: [ { name: 'dryrun', - image: 'plugins/docker:' + tag, - pull: 'always', + image: 'plugins/docker', settings: { dry_run: true, - tags: version_tag, - dockerfile: './Dockerfile.' + file_suffix, - repo: 'xoxys/kanboard', - username: { from_secret: "docker_username" }, - password: { from_secret: "docker_password" }, - build_args: { - KANBOARD_VERSION: "${DRONE_TAG%-*}", - }, + dockerfile: 'Dockerfile', + repo: 'xoxys/$DRONE_REPO_NAME', + username: { from_secret: 'docker_username' }, + password: { from_secret: 'docker_password' }, + build_args: [ + 'BUILD_VERSION=${DRONE_TAG%-*}', + ], + }, + when: { + ref: [ + 'refs/pull/**', + ], }, }, { name: 'publish', - image: 'plugins/docker:' + tag, - pull: 'always', + image: 'plugins/docker', settings: { auto_tag: true, - auto_tag_suffix: version_tag, - dockerfile: './Dockerfile.' + file_suffix, - repo: 'xoxys/kanboard', - username: { from_secret: "docker_username" }, - password: { from_secret: "docker_password" }, - build_args: { - KANBOARD_VERSION: "${DRONE_TAG%-*}", - }, + auto_tag_suffix: arch, + dockerfile: 'Dockerfile', + repo: 'xoxys/$DRONE_REPO_NAME', + username: { from_secret: 'docker_username' }, + password: { from_secret: 'docker_password' }, + build_args: [ + 'BUILD_VERSION=${DRONE_TAG%-*}', + ], }, when: { ref: [ @@ -48,15 +47,14 @@ local PipelineBuild(os='linux', arch='amd64') = { }, }, { - name: "publish-gitea", - image: "plugins/gitea-release", - pull: "always", + name: 'publish-gitea', + image: 'plugins/gitea-release', settings: { - api_key: { "from_secret": "gitea_token" }, - base_url: "https://gitea.rknet.org", + api_key: { from_secret: 'gitea_token' }, + base_url: 'https://gitea.rknet.org', overwrite: true, - title: "${DRONE_TAG}", - note: "CHANGELOG.md", + title: '${DRONE_TAG}', + note: 'CHANGELOG.md', }, when: { ref: ['refs/tags/**'], @@ -66,83 +64,85 @@ local PipelineBuild(os='linux', arch='amd64') = { }; local PipelineNotifications(depends_on=[]) = { - kind: "pipeline", - name: "notifications", + kind: 'pipeline', + name: 'notifications', platform: { - os: "linux", - arch: "amd64", + os: 'linux', + arch: 'amd64', }, steps: [ { - image: "plugins/manifest", - name: "manifest", - pull: "always", + image: 'plugins/manifest', + name: 'manifest', settings: { ignore_missing: true, - tags: ["${DRONE_TAG}", "${DRONE_TAG%-*}", "${DRONE_TAG%.*}", "${DRONE_TAG%%.*}"], - username: { from_secret: "docker_username" }, - password: { from_secret: "docker_password" }, - spec: "./manifest.tmpl", + tags: [ + '${DRONE_TAG}', + '${DRONE_TAG%-*}', + '${DRONE_TAG%.*}', + '${DRONE_TAG%%.*}', + ], + username: { from_secret: 'docker_username' }, + password: { from_secret: 'docker_password' }, + spec: 'manifest.tmpl', }, when: { - ref: [ - 'refs/heads/master', - 'refs/tags/**', + status: [ + 'success', ], }, }, { - name: "readme", - image: "sheogorath/readme-to-dockerhub", - pull: "always", + name: 'readme', + image: 'sheogorath/readme-to-dockerhub', environment: { - DOCKERHUB_USERNAME: { from_secret: "docker_username" }, - DOCKERHUB_PASSWORD: { from_secret: "docker_password" }, - DOCKERHUB_REPO_PREFIX: "xoxys", - DOCKERHUB_REPO_NAME: "kanboard", - README_PATH: "README.md", - SHORT_DESCRIPTION: "Rootless Kanboard - Kanban project management software" + DOCKERHUB_USERNAME: { from_secret: 'docker_username' }, + DOCKERHUB_PASSWORD: { from_secret: 'docker_password' }, + DOCKERHUB_REPO_PREFIX: 'xoxys', + DOCKERHUB_REPO_NAME: '$DRONE_REPO_NAME', + README_PATH: 'README.md', + SHORT_DESCRIPTION: 'Rootless Kanboard - Kanban project management software', }, when: { - ref: [ - 'refs/heads/master', - 'refs/tags/**', + status: [ + 'success', ], }, }, { - name: "microbadger", - image: "plugins/webhook", - pull: "always", + name: 'matrix', + image: 'plugins/matrix', settings: { - urls: { from_secret: "microbadger_url" }, - }, - }, - { - image: "plugins/matrix", - name: "matrix", - pull: 'always', - settings: { - homeserver: "https://matrix.rknet.org", - roomid: "MtidqQXWWAtQcByBhH:rknet.org", - template: "Status: **{{ build.status }}**
Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}
Message: {{ build.message }}", - username: { from_secret: "matrix_username" }, - password: { from_secret: "matrix_password" }, + homeserver: { from_secret: 'matrix_homeserver' }, + roomid: { from_secret: 'matrix_roomid' }, + template: 'Status: **{{ build.status }}**
Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}
Message: {{ build.message }}', + username: { from_secret: 'matrix_username' }, + password: { from_secret: 'matrix_password' }, }, when: { - status: [ "success", "failure" ], + status: [ + 'success', + 'failure', + ], }, }, ], trigger: { - status: [ "success", "failure" ], + ref: [ + 'refs/heads/master', + 'refs/tags/**', + ], + status: [ + 'success', + 'failure', + ], }, depends_on: depends_on, }; [ - PipelineBuild(os='linux', arch='amd64'), + PipelineBuild(arch='amd64'), PipelineNotifications(depends_on=[ - "linux-amd64", - ]) + 'build-amd64', + ]), ] diff --git a/.drone.yml b/.drone.yml index ef7a125..660bdb3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,6 +1,6 @@ --- kind: pipeline -name: linux-amd64 +name: build-amd64 platform: os: linux @@ -8,41 +8,40 @@ platform: steps: - name: dryrun - pull: always - image: plugins/docker:linux-amd64 + image: plugins/docker settings: build_args: - KANBOARD_VERSION: "${DRONE_TAG%-*}" - dockerfile: ./Dockerfile.linux.amd64 + - BUILD_VERSION=${DRONE_TAG%-*} + dockerfile: Dockerfile dry_run: true password: from_secret: docker_password - repo: xoxys/kanboard - tags: linux-amd64 + repo: xoxys/$DRONE_REPO_NAME username: from_secret: docker_username + when: + ref: + - refs/pull/** - name: publish - pull: always - image: plugins/docker:linux-amd64 + image: plugins/docker settings: auto_tag: true - auto_tag_suffix: linux-amd64 + auto_tag_suffix: amd64 build_args: - KANBOARD_VERSION: "${DRONE_TAG%-*}" - dockerfile: ./Dockerfile.linux.amd64 + - BUILD_VERSION=${DRONE_TAG%-*} + dockerfile: Dockerfile password: from_secret: docker_password - repo: xoxys/kanboard + repo: xoxys/$DRONE_REPO_NAME username: from_secret: docker_username when: ref: - refs/heads/master - - "refs/tags/**" + - refs/tags/** - name: publish-gitea - pull: always image: plugins/gitea-release settings: api_key: @@ -50,10 +49,10 @@ steps: base_url: https://gitea.rknet.org note: CHANGELOG.md overwrite: true - title: "${DRONE_TAG}" + title: ${DRONE_TAG} when: ref: - - "refs/tags/**" + - refs/tags/** --- kind: pipeline @@ -65,57 +64,47 @@ platform: steps: - name: manifest - pull: always image: plugins/manifest settings: ignore_missing: true password: from_secret: docker_password - spec: ./manifest.tmpl + spec: manifest.tmpl tags: - - "${DRONE_TAG}" - - "${DRONE_TAG%-*}" - - "${DRONE_TAG%.*}" - - "${DRONE_TAG%%.*}" + - ${DRONE_TAG} + - ${DRONE_TAG%-*} + - ${DRONE_TAG%.*} + - ${DRONE_TAG%%.*} username: from_secret: docker_username when: - ref: - - refs/heads/master - - "refs/tags/**" + status: + - success - name: readme - pull: always image: sheogorath/readme-to-dockerhub environment: DOCKERHUB_PASSWORD: from_secret: docker_password - DOCKERHUB_REPO_NAME: kanboard + DOCKERHUB_REPO_NAME: $DRONE_REPO_NAME DOCKERHUB_REPO_PREFIX: xoxys DOCKERHUB_USERNAME: from_secret: docker_username README_PATH: README.md SHORT_DESCRIPTION: Rootless Kanboard - Kanban project management software when: - ref: - - refs/heads/master - - "refs/tags/**" - -- name: microbadger - pull: always - image: plugins/webhook - settings: - urls: - from_secret: microbadger_url + status: + - success - name: matrix - pull: always image: plugins/matrix settings: - homeserver: https://matrix.rknet.org + homeserver: + from_secret: matrix_homeserver password: from_secret: matrix_password - roomid: MtidqQXWWAtQcByBhH:rknet.org + roomid: + from_secret: matrix_roomid template: "Status: **{{ build.status }}**
Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}
Message: {{ build.message }}" username: from_secret: matrix_username @@ -125,15 +114,14 @@ steps: - failure trigger: + ref: + - refs/heads/master + - refs/tags/** status: - success - failure depends_on: -- linux-amd64 - ---- -kind: signature -hmac: e4f6bc169c5cf8661b73dd9b921f6facd998f0c3035f29b53998f35315b7af32 +- build-amd64 ... diff --git a/Dockerfile.linux.amd64 b/Dockerfile similarity index 77% rename from Dockerfile.linux.amd64 rename to Dockerfile index 9d44937..2d9a465 100644 --- a/Dockerfile.linux.amd64 +++ b/Dockerfile @@ -2,12 +2,14 @@ FROM xoxys/nginx:latest LABEL maintainer="Robert Kaussow " \ org.label-schema.name="Kanboard" \ - org.label-schema.version="1.2" \ + org.label-schema.vcs-url="https://gitea.rknet.org/docker/kanboard" \ org.label-schema.vendor="Robert Kaussow" \ org.label-schema.schema-version="1.0" -ARG KANBOARD_VERSION=master -ARG KANBOARD_TARBALL=https://github.com/kanboard/kanboard/archive/${KANBOARD_VERSION}.tar.gz +ARG BUILD_VERSION=master +ENV KANBOARD_VERSION="${BUILD_VERSION:-master}" + +ADD overlay/ / RUN apk --update add --virtual .build-deps tar curl && \ apk --update add ssmtp mailx php7 php7-phar php7-curl \ @@ -17,12 +19,12 @@ RUN apk --update add --virtual .build-deps tar curl && \ rm -rf /var/www/localhost && \ rm -f /etc/php7/php-fpm.d/www.conf && \ mkdir -p /var/www/app && \ - curl -SsL ${KANBOARD_TARBALL} | tar xz -C /var/www/app/ --strip-components=1 && \ + echo "Installing Kanboard '${KANBOARD_VERSION}' ..." && \ + curl -SsL "https://github.com/kanboard/kanboard/archive/${KANBOARD_VERSION}.tar.gz" | tar xz -C /var/www/app/ -X /.tarignore --strip-components=1 && \ curl -SsL -o /etc/php7/browscap.ini https://browscap.org/stream?q=Lite_PHP_BrowsCapINI && \ apk del .build-deps && \ rm -rf /var/cache/apk/* && \ rm -rf /tmp/* && \ - rm -rf /var/www/app/ChangeLog /var/www/app/config.default.php && \ mkdir -p /var/run/php && \ chown -R nginx /var/run/php && \ mkdir -p /var/lib/php/tmp_upload && \ @@ -32,8 +34,6 @@ RUN apk --update add --virtual .build-deps tar curl && \ chown nginx /etc/php7/php.ini && \ chown -R nginx:nginx /var/www/app -ADD overlay/ / - VOLUME /var/www/app/plugins VOLUME /var/www/app/data @@ -43,7 +43,7 @@ USER nginx STOPSIGNAL SIGTERM -ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] -HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD /usr/local/bin/healthcheck.sh +ENTRYPOINT ["/usr/local/bin/entrypoint"] +HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD /usr/local/bin/healthcheck WORKDIR /var/www/app CMD [] diff --git a/manifest.tmpl b/manifest.tmpl index 0266df0..61a7040 100644 --- a/manifest.tmpl +++ b/manifest.tmpl @@ -4,12 +4,12 @@ tags: {{#each build.tags}} {{#if this}} - {{trimPrefix "v" this}} - - {{trimPrefix "v" this}}-linux-amd64 + - {{trimPrefix "v" this}}-amd64 {{/if}} {{/each}} {{/if}} manifests: - - image: xoxys/kanboard:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64 + - image: xoxys/kanboard:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}amd64 platform: architecture: amd64 os: linux diff --git a/overlay/.tarignore b/overlay/.tarignore new file mode 100644 index 0000000..37ae940 --- /dev/null +++ b/overlay/.tarignore @@ -0,0 +1,2 @@ +ChangeLog +config.default.php diff --git a/overlay/usr/local/bin/entrypoint.sh b/overlay/usr/local/bin/entrypoint similarity index 93% rename from overlay/usr/local/bin/entrypoint.sh rename to overlay/usr/local/bin/entrypoint index f580091..a7d883a 100755 --- a/overlay/usr/local/bin/entrypoint.sh +++ b/overlay/usr/local/bin/entrypoint @@ -1,4 +1,5 @@ -#!/bin/sh +#!/usr/bin/env sh + /usr/local/bin/gomplate -V -o /etc/php7/php.ini -f /etc/templates/php.ini.tmpl /usr/local/bin/gomplate -V -o /var/www/app/data/config.php -f /etc/templates/config.php.tmpl diff --git a/overlay/usr/local/bin/healthcheck.sh b/overlay/usr/local/bin/healthcheck similarity index 91% rename from overlay/usr/local/bin/healthcheck.sh rename to overlay/usr/local/bin/healthcheck index e713662..f9c2823 100755 --- a/overlay/usr/local/bin/healthcheck.sh +++ b/overlay/usr/local/bin/healthcheck @@ -1,6 +1,7 @@ -#!/bin/sh +#!/usr/bin/env sh set -eo pipefail + URL=http://localhost:8080 wget --quiet --tries=1 --spider ${URL}