From 2ae402d26773616598ee4cae201abcd32658cbd0 Mon Sep 17 00:00:00 2001 From: Thomas Deutsch Date: Sat, 17 Apr 2021 12:54:26 +0200 Subject: [PATCH 01/12] added dependabot --- .github/dependabot.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..9806711 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +version: 2 +updates: + +# Maintain dependencies for Docker +- package-ecosystem: docker + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + +# Maintain dependencies for GitHub Actions +- package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + open-pull-requests-limit: 10 \ No newline at end of file From ae2763b4e039a531300121851fb923dd171aa15b Mon Sep 17 00:00:00 2001 From: Thomas Deutsch Date: Sat, 17 Apr 2021 12:54:52 +0200 Subject: [PATCH 02/12] added workflow for pull-requests and release --- .github/workflows/pullrequests.yml | 39 +++++++++++ .github/workflows/release.yml | 103 +++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 .github/workflows/pullrequests.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/pullrequests.yml b/.github/workflows/pullrequests.yml new file mode 100644 index 0000000..f975fa2 --- /dev/null +++ b/.github/workflows/pullrequests.yml @@ -0,0 +1,39 @@ +name: ci + +on: + pull_request: + types: [assigned, opened, synchronize, reopened] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Generate Build-Args + id: build-args + run: | + # echo ::set-output name=build-arg1::"buildarg1" + # echo ::set-output name=build-arg2::"buildarg2" + - + name: Hadolint + uses: brpaz/hadolint-action@v1.3.1 + with: + dockerfile: Dockerfile + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm/v7,linux/arm/v6,linux/arm64 + push: false \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..fd36835 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,103 @@ +name: ci + +# This worflow needs this secret: +# +# DOCKERPASSWORD = Docker Hub token + +on: + push: + branches: [master] + tags: 'v*.*.*' + schedule: + - cron: "0 13 * * 1" + +env: + PLATFORMS: "linux/amd64,linux/arm/v7,linux/arm/v6,linux/arm64, linux/ppc64le" # Build for which platforms + IMAGENAME: "tdeutsch/speedtest" # Name of the image + DEFAULT_TAG: "latest" # Which tag is beeing used if we are building for master/main branch + DOCKER_USER: "tdeutsch" # Which user to use to login to DockerHub + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - + name: Generate Build-Args + id: build-args + run: | + # echo ::set-output name=build-arg1::"buildarg1" + # echo ::set-output name=build-arg2::"buildarg2" + - + name: Checkout + uses: actions/checkout@v2 + - + name: Prepare + id: prep + run: | + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/} + if [[ $VERSION =~ ^v([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$ ]]; then + MAJOR="${BASH_REMATCH[1]}" + MINOR="${BASH_REMATCH[2]}" + PATCH="${BASH_REMATCH[3]}" + + TAGS="${{ env.IMAGENAME }}:latest" + TAGS="${TAGS},${{ env.IMAGENAME }}:${MAJOR}" + TAGS="${TAGS},${{ env.IMAGENAME }}:${MAJOR}.${MINOR}" + TAGS="${TAGS},${{ env.IMAGENAME }}:${MAJOR}.${MINOR}.${PATCH}" + else + TAGS="${{ env.IMAGENAME }}:${VERSION}" + fi + elif [[ $GITHUB_REF == refs/heads/* ]]; then + TAGS="${{ env.IMAGENAME }}:${{ env.DEFAULT_TAG }}" + elif [[ $GITHUB_REF == refs/pull/* ]]; then + TAGS="${{ env.IMAGENAME }}:pr-${{ github.event.number }}" + fi + echo ::set-output name=tags::${TAGS} + echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + - + name: Hadolint + uses: brpaz/hadolint-action@v1.3.1 + with: + dockerfile: Dockerfile + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ env.DOCKER_USER }} + password: ${{ secrets.DOCKERPASSWORD }} + - + name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + platforms: ${{ env.PLATFORMS }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.prep.outputs.tags }} + build-args: | + ${{ steps.build-args.outputs.build-arg1 }} + ${{ steps.build-args.outputs.build-arg2 }} + labels: | + org.opencontainers.image.title=${{ github.event.repository.name }} + org.opencontainers.image.description=${{ github.event.repository.description }} + org.opencontainers.image.url=${{ github.event.repository.html_url }} + org.opencontainers.image.source=${{ github.event.repository.clone_url }} + org.opencontainers.image.created=${{ steps.prep.outputs.created }} + org.opencontainers.image.revision=${{ github.sha }} + org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }} + - + name: Docker Hub Description + uses: peter-evans/dockerhub-description@v2 + with: + username: ${{ env.DOCKER_USER }} + password: ${{ secrets.DOCKERPASSWORD }} + repository: ${{ env.IMAGENAME }} + From 08f6bc521d3c5510af65e4a0a5877eedc14a4912 Mon Sep 17 00:00:00 2001 From: Thomas Deutsch Date: Sat, 17 Apr 2021 12:56:47 +0200 Subject: [PATCH 03/12] fix context --- .github/workflows/pullrequests.yml | 4 ++-- .github/workflows/release.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pullrequests.yml b/.github/workflows/pullrequests.yml index f975fa2..62fa82d 100644 --- a/.github/workflows/pullrequests.yml +++ b/.github/workflows/pullrequests.yml @@ -21,7 +21,7 @@ jobs: name: Hadolint uses: brpaz/hadolint-action@v1.3.1 with: - dockerfile: Dockerfile + dockerfile: container/Dockerfile - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -33,7 +33,7 @@ jobs: id: docker_build uses: docker/build-push-action@v2 with: - context: . + context: container/ file: ./Dockerfile platforms: linux/amd64,linux/arm/v7,linux/arm/v6,linux/arm64 push: false \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fd36835..26a9c4c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,7 +59,7 @@ jobs: name: Hadolint uses: brpaz/hadolint-action@v1.3.1 with: - dockerfile: Dockerfile + dockerfile: container/Dockerfile - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -77,7 +77,7 @@ jobs: id: docker_build uses: docker/build-push-action@v2 with: - context: . + context: container/ file: ./Dockerfile platforms: ${{ env.PLATFORMS }} push: ${{ github.event_name != 'pull_request' }} From 46c379b13761e447b1f20e161e81a7b58b462f35 Mon Sep 17 00:00:00 2001 From: Thomas Deutsch Date: Sat, 17 Apr 2021 12:57:29 +0200 Subject: [PATCH 04/12] fix context for dependabot --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 9806711..1c54606 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,7 +3,7 @@ updates: # Maintain dependencies for Docker - package-ecosystem: docker - directory: "/" + directory: "container/" schedule: interval: daily open-pull-requests-limit: 10 From 3178a9758340e39b7c0286f9fe61ac4c46a5973b Mon Sep 17 00:00:00 2001 From: Thomas Deutsch Date: Sat, 17 Apr 2021 12:59:40 +0200 Subject: [PATCH 05/12] make hadolint happy ignore=DL3018 --- container/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/container/Dockerfile b/container/Dockerfile index 21797aa..76d1a47 100644 --- a/container/Dockerfile +++ b/container/Dockerfile @@ -5,6 +5,7 @@ FROM alpine:latest as compiler # install build framework and libraries +# hadolint ignore=DL3018 RUN apk add --no-cache alpine-sdk cmake curl-dev libxml2-dev # configure and build binary @@ -17,10 +18,12 @@ RUN git clone https://github.com/taganaka/SpeedTest.git . \ FROM python:3-alpine # install necessary packages and fonts +# hadolint ignore=DL3018 RUN apk add --no-cache gnuplot ttf-droid libcurl libxml2 libstdc++ libgcc tini # copy requirements file and install with pip COPY requirements.txt /requirements.txt +# hadolint ignore=DL3018 RUN apk add --no-cache --virtual build-deps musl-dev gcc postgresql-dev \ && apk add --no-cache postgresql-libs \ && pip install --no-cache-dir -r /requirements.txt \ From 838b603f9082ec0e511e47f373a51148698373fa Mon Sep 17 00:00:00 2001 From: Thomas Deutsch Date: Sat, 17 Apr 2021 13:01:14 +0200 Subject: [PATCH 06/12] best practice to use specific versions --- container/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container/Dockerfile b/container/Dockerfile index 76d1a47..558109d 100644 --- a/container/Dockerfile +++ b/container/Dockerfile @@ -2,7 +2,7 @@ # Licensed under the MIT License # ---------- build taganaka/SpeedTest binary ---------- -FROM alpine:latest as compiler +FROM alpine:3.13.4 as compiler # install build framework and libraries # hadolint ignore=DL3018 From f5394d10feed18c1dfaa0520ec13bd1c5ed107b2 Mon Sep 17 00:00:00 2001 From: Thomas Deutsch Date: Sat, 17 Apr 2021 13:03:50 +0200 Subject: [PATCH 07/12] Build and push is not able to find file --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 26a9c4c..d2db438 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,7 +78,6 @@ jobs: uses: docker/build-push-action@v2 with: context: container/ - file: ./Dockerfile platforms: ${{ env.PLATFORMS }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.prep.outputs.tags }} From b8f0cb77b4cf3ea55fc06aa1600307eaa6728e0f Mon Sep 17 00:00:00 2001 From: Thomas Deutsch Date: Sat, 17 Apr 2021 13:06:19 +0200 Subject: [PATCH 08/12] still trying to get build working --- .github/workflows/pullrequests.yml | 4 ++-- .github/workflows/release.yml | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pullrequests.yml b/.github/workflows/pullrequests.yml index 62fa82d..ff4fcaf 100644 --- a/.github/workflows/pullrequests.yml +++ b/.github/workflows/pullrequests.yml @@ -33,7 +33,7 @@ jobs: id: docker_build uses: docker/build-push-action@v2 with: - context: container/ - file: ./Dockerfile + context: . + file: ./container/Dockerfile platforms: linux/amd64,linux/arm/v7,linux/arm/v6,linux/arm64 push: false \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d2db438..f9b4d0d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -77,7 +77,8 @@ jobs: id: docker_build uses: docker/build-push-action@v2 with: - context: container/ + context: . + file: ./container/Dockerfile platforms: ${{ env.PLATFORMS }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.prep.outputs.tags }} From ab63360a08c43c73324d80258ef5fb708120607d Mon Sep 17 00:00:00 2001 From: Thomas Deutsch Date: Sat, 17 Apr 2021 13:23:33 +0200 Subject: [PATCH 09/12] change name to upstream's name --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f9b4d0d..d0880a8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,9 +13,9 @@ on: env: PLATFORMS: "linux/amd64,linux/arm/v7,linux/arm/v6,linux/arm64, linux/ppc64le" # Build for which platforms - IMAGENAME: "tdeutsch/speedtest" # Name of the image + IMAGENAME: "ansemjo/speedtest" # Name of the image DEFAULT_TAG: "latest" # Which tag is beeing used if we are building for master/main branch - DOCKER_USER: "tdeutsch" # Which user to use to login to DockerHub + DOCKER_USER: "ansemjo" # Which user to use to login to DockerHub jobs: docker: From dd3d0031a2053e59b8addc58e88a61ef80d0c1cb Mon Sep 17 00:00:00 2001 From: Thomas Deutsch Date: Sat, 17 Apr 2021 15:20:41 +0200 Subject: [PATCH 10/12] Update .github/workflows/pullrequests.yml Co-authored-by: ansemjo <11139925+ansemjo@users.noreply.github.com> --- .github/workflows/pullrequests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pullrequests.yml b/.github/workflows/pullrequests.yml index ff4fcaf..d33d3a1 100644 --- a/.github/workflows/pullrequests.yml +++ b/.github/workflows/pullrequests.yml @@ -35,5 +35,5 @@ jobs: with: context: . file: ./container/Dockerfile - platforms: linux/amd64,linux/arm/v7,linux/arm/v6,linux/arm64 - push: false \ No newline at end of file + platforms: linux/amd64 + push: false From 00911103d0e8b5df9f62fcb9422ec05f0378a750 Mon Sep 17 00:00:00 2001 From: Thomas Deutsch Date: Sat, 17 Apr 2021 15:36:28 +0200 Subject: [PATCH 11/12] add workflow for a devel branch --- .github/workflows/development.yml | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/development.yml diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml new file mode 100644 index 0000000..86cb040 --- /dev/null +++ b/.github/workflows/development.yml @@ -0,0 +1,39 @@ +name: ci + +on: + push: + branches: [devel] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Generate Build-Args + id: build-args + run: | + # echo ::set-output name=build-arg1::"buildarg1" + # echo ::set-output name=build-arg2::"buildarg2" + - + name: Hadolint + uses: brpaz/hadolint-action@v1.3.1 + with: + dockerfile: container/Dockerfile + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + file: ./container/Dockerfile + platforms: linux/amd64 + push: false From e01d472c3e743dbbf68191a4445b6374c45f5036 Mon Sep 17 00:00:00 2001 From: Thomas Deutsch Date: Sat, 17 Apr 2021 15:37:17 +0200 Subject: [PATCH 12/12] Rename Dockerhub Password Secret and use a secret for the username as well. --- .github/workflows/release.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d0880a8..cc19059 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,8 @@ name: ci # This worflow needs this secret: # -# DOCKERPASSWORD = Docker Hub token +# DOCKERHUB_TOKEN = Docker Hub token +# DOCKERHUB_USER = Docker Hub user on: push: @@ -13,9 +14,9 @@ on: env: PLATFORMS: "linux/amd64,linux/arm/v7,linux/arm/v6,linux/arm64, linux/ppc64le" # Build for which platforms - IMAGENAME: "ansemjo/speedtest" # Name of the image - DEFAULT_TAG: "latest" # Which tag is beeing used if we are building for master/main branch - DOCKER_USER: "ansemjo" # Which user to use to login to DockerHub + IMAGENAME: "${{ secrets.DOCKERHUB_USER }}/speedtest" # Name of the image + DEFAULT_TAG: "latest" # Which tag is beeing used if we are building for master/main branch + DOCKER_USER: "${{ secrets.DOCKERHUB_USER }}" # Which user to use to login to DockerHub jobs: docker: @@ -70,8 +71,8 @@ jobs: name: Login to Docker Hub uses: docker/login-action@v1 with: - username: ${{ env.DOCKER_USER }} - password: ${{ secrets.DOCKERPASSWORD }} + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push id: docker_build @@ -97,7 +98,7 @@ jobs: name: Docker Hub Description uses: peter-evans/dockerhub-description@v2 with: - username: ${{ env.DOCKER_USER }} - password: ${{ secrets.DOCKERPASSWORD }} + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} repository: ${{ env.IMAGENAME }}