From 992e24bab68fee4913932b0285ddaf570a984c4d Mon Sep 17 00:00:00 2001 From: sstidl Date: Sat, 4 Nov 2023 02:32:32 +0100 Subject: [PATCH 1/7] Create docker-publish.yml --- .github/workflows/docker-publish.yml | 98 ++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..cc9007d --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,98 @@ +name: Docker + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + schedule: + - cron: '30 20 * * *' + push: + branches: [ "dev" ] + # Publish semver tags as releases. + tags: [ 'v*.*.*' ] + pull_request: + branches: [ "dev" ] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Install the cosign tool except on PR + # https://github.com/sigstore/cosign-installer + - name: Install cosign + if: github.event_name != 'pull_request' + uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1 + with: + cosign-release: 'v2.1.1' + + # Set up BuildKit Docker container builder to be able to build + # multi-platform images and export cache + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + # Sign the resulting Docker image digest except on PRs. + # This will only write to the public Rekor transparency log when the Docker + # repository is public to avoid leaking data. If you would like to publish + # transparency data even for private images, pass --force to cosign below. + # https://github.com/sigstore/cosign + - name: Sign the published Docker image + if: ${{ github.event_name != 'pull_request' }} + env: + # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable + TAGS: ${{ steps.meta.outputs.tags }} + DIGEST: ${{ steps.build-and-push.outputs.digest }} + # This step uses the identity token to provision an ephemeral certificate + # against the sigstore community Fulcio instance. + run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} From cecf591d0f2857aa393f65fc32f79177aee95b77 Mon Sep 17 00:00:00 2001 From: sstidl Date: Sat, 4 Nov 2023 23:14:27 +0100 Subject: [PATCH 2/7] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index cc9007d..16c0896 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -6,8 +6,8 @@ name: Docker # documentation. on: - schedule: - - cron: '30 20 * * *' +# schedule: +# - cron: '30 20 * * *' push: branches: [ "dev" ] # Publish semver tags as releases. From 6c92ed8091071b458524f6507db493497a6e27dd Mon Sep 17 00:00:00 2001 From: sstidl Date: Sat, 4 Nov 2023 23:44:07 +0100 Subject: [PATCH 3/7] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 16c0896..87c8ada 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -9,11 +9,11 @@ on: # schedule: # - cron: '30 20 * * *' push: - branches: [ "dev" ] + branches: [ "*" ] # Publish semver tags as releases. tags: [ 'v*.*.*' ] pull_request: - branches: [ "dev" ] + branches: [ "main","master" ] env: # Use docker.io for Docker Hub if empty @@ -68,6 +68,13 @@ jobs: uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + # set latest tag for default branch + type=raw,value=latest,enable={{is_default_branch}} + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action From 60ea879bc3b1eb93986c32e693bdbeabcedf9872 Mon Sep 17 00:00:00 2001 From: Stefan Stidl Date: Sat, 4 Nov 2023 23:52:59 +0100 Subject: [PATCH 4/7] fix action --- .github/workflows/docker-publish.yml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 87c8ada..2bf09c4 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -6,14 +6,14 @@ name: Docker # documentation. on: -# schedule: -# - cron: '30 20 * * *' + # schedule: + # - cron: '30 20 * * *' push: - branches: [ "*" ] + branches: ["*"] # Publish semver tags as releases. - tags: [ 'v*.*.*' ] + tags: ["v*.*.*"] pull_request: - branches: [ "main","master" ] + branches: ["{{is_default_branch}}"] env: # Use docker.io for Docker Hub if empty @@ -21,10 +21,8 @@ env: # github.repository as / IMAGE_NAME: ${{ github.repository }} - jobs: build: - runs-on: ubuntu-latest permissions: contents: read @@ -43,7 +41,7 @@ jobs: if: github.event_name != 'pull_request' uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1 with: - cosign-release: 'v2.1.1' + cosign-release: "v2.1.1" # Set up BuildKit Docker container builder to be able to build # multi-platform images and export cache @@ -68,11 +66,11 @@ jobs: uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | + tags: | type=ref,event=branch type=ref,event=pr - # set latest tag for default branch - type=raw,value=latest,enable={{is_default_branch}} + # set latest tag for default branch + type=raw,value=latest,enable={{is_default_branch}} type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} From 7c05ba084e37e5ec0ddd2cfa57824aad5bab9c5d Mon Sep 17 00:00:00 2001 From: Stefan Stidl Date: Sun, 5 Nov 2023 00:14:48 +0100 Subject: [PATCH 5/7] switch docker image location --- README.md | 2 +- doc_docker.md | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 81d692c..bbe55cb 100755 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ There is a more in-depth installation video here: A template to build an Android client for your LibreSpeed installation is available [here](https://github.com/librespeed/speedtest-android). ## Docker -A docker image is available on the [Docker Hub](https://registry.hub.docker.com/r/adolfintel/speedtest), check our [docker documentation](doc_docker.md) for more info about it +A docker image is available on [GitHub](https://github.com/librespeed/speedtest/pkgs/container/speedtest), check our [docker documentation](doc_docker.md) for more info about it. ## Go backend A Go implementation is available in the [`speedtest-go`](https://github.com/librespeed/speedtest-go) repo, maintained by [Maddie Zhan](https://github.com/maddie). diff --git a/doc_docker.md b/doc_docker.md index 6e377a2..2a6e5e2 100755 --- a/doc_docker.md +++ b/doc_docker.md @@ -1,13 +1,13 @@ -A docker version of LibreSpeed is available on docker hub: [https://hub.docker.com/r/adolfintel/speedtest/](https://hub.docker.com/r/adolfintel/speedtest/) +A docker version of LibreSpeed is available here: [GitHub Packages](https://github.com/librespeed/speedtest/pkgs/container/speedtest) -## Downloading from Docker hub -To download LibreSpeed from the docker hub, use this command: +## Downloading docker image +To download LibreSpeed from the docker repo, use this command: ``` -docker pull adolfintel/speedtest +docker pull ghcr.io/librespeed/speedtest ``` -You will now have a new docker image called `adolfintel/speedtest`. +You will now have a new docker image called `librespeed/speedtest`. ## Docker Compose @@ -18,7 +18,7 @@ version: '3.7' services: speedtest: container_name: speedtest - image: adolfintel/speedtest + image: ghcr.io/librespeed/speedtest:latest restart: always environment: MODE: standalone @@ -67,13 +67,13 @@ So if you want your data to be persisted over image updates, you have to mount a This command starts LibreSpeed in standalone mode, with the default settings, on port 80: ``` -docker run -e MODE=standalone -p 80:80 -it adolfintel/speedtest +docker run -e MODE=standalone -p 80:80 -it ghcr.io/librespeed/speedtest ``` This command starts LibreSpeed in standalone mode, with telemetry, ID obfuscation and a stats password, on port 86: ``` -docker run -e MODE=standalone -e TELEMETRY=true -e ENABLE_ID_OBFUSCATION=true -e PASSWORD="yourPasswordHere" -e WEBPORT=86 -p 86:86 -v $PWD/db-dir/:/database -it adolfintel/speedtest +docker run -e MODE=standalone -e TELEMETRY=true -e ENABLE_ID_OBFUSCATION=true -e PASSWORD="yourPasswordHere" -e WEBPORT=86 -p 86:86 -v $PWD/db-dir/:/database -it ghcr.io/librespeed/speedtest ``` ## Multiple Points of Test @@ -90,7 +90,7 @@ Here's a list of additional environment variables available in this mode: ###### Example: This command starts LibreSpeed in backend mode, with the default settings, on port 80: ``` -docker run -e MODE=backend -p 80:80 -it adolfintel/speedtest +docker run -e MODE=backend -p 80:80 -it ghcr.io/librespeed/speedtest ``` ### Frontend mode @@ -137,5 +137,5 @@ Here's a list of additional environment variables available in this mode: ###### Example This command starts LibreSpeed in frontend mode, with a given `servers.json` file, and with telemetry, ID obfuscation, and a stats password: ``` -docker run -e MODE=frontend -e TELEMETRY=true -e ENABLE_ID_OBFUSCATION=true -e PASSWORD="yourPasswordHere" -v $(pwd)/servers.json:/servers.json -p 80:80 -it adolfintel/speedtest +docker run -e MODE=frontend -e TELEMETRY=true -e ENABLE_ID_OBFUSCATION=true -e PASSWORD="yourPasswordHere" -v $(pwd)/servers.json:/servers.json -p 80:80 -it ghcr.io/librespeed/speedtest ``` From e468c3d0689b7e5564b55247069e58f070430f29 Mon Sep 17 00:00:00 2001 From: Stefan Stidl Date: Sun, 5 Nov 2023 00:20:39 +0100 Subject: [PATCH 6/7] without image signing --- .github/workflows/docker-publish.yml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 2bf09c4..7e7266c 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -86,18 +86,3 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max - - # Sign the resulting Docker image digest except on PRs. - # This will only write to the public Rekor transparency log when the Docker - # repository is public to avoid leaking data. If you would like to publish - # transparency data even for private images, pass --force to cosign below. - # https://github.com/sigstore/cosign - - name: Sign the published Docker image - if: ${{ github.event_name != 'pull_request' }} - env: - # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable - TAGS: ${{ steps.meta.outputs.tags }} - DIGEST: ${{ steps.build-and-push.outputs.digest }} - # This step uses the identity token to provision an ephemeral certificate - # against the sigstore community Fulcio instance. - run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} From b1aa63259c9078b69302257bc0552fa940cf5ac8 Mon Sep 17 00:00:00 2001 From: Stefan Stidl Date: Sun, 5 Nov 2023 00:35:46 +0100 Subject: [PATCH 7/7] remove signing --- .github/workflows/docker-publish.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 7e7266c..0416c2d 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -35,14 +35,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - # Install the cosign tool except on PR - # https://github.com/sigstore/cosign-installer - - name: Install cosign - if: github.event_name != 'pull_request' - uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1 - with: - cosign-release: "v2.1.1" - # Set up BuildKit Docker container builder to be able to build # multi-platform images and export cache # https://github.com/docker/setup-buildx-action