From d3edc9839e4f485f7a89aec6c50bff648204d618 Mon Sep 17 00:00:00 2001 From: Paul Voss Date: Sun, 12 Feb 2023 11:08:10 +0100 Subject: [PATCH 1/5] Add buildx pipeline for tag 'latest' --- .github/workflows/image-latest.yml | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/image-latest.yml diff --git a/.github/workflows/image-latest.yml b/.github/workflows/image-latest.yml new file mode 100644 index 0000000..05fbd28 --- /dev/null +++ b/.github/workflows/image-latest.yml @@ -0,0 +1,46 @@ +name: Build latest image + +on: + # Runs on pushes targeting the default branch + push: + branches: ["buildx"] # replace with main + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Container Registry +permissions: + contents: read + packages: write + +# Allow one concurrent deployment +concurrency: + group: "image-latest" + cancel-in-progress: true + +env: + DEPLOY_TAG: latest + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ghcr.io/${{ github.repository }}:${{ env.DEPLOY_TAG }} From e48c58d0c07d8b6e0e29ab63f64f0fd5e00dc872 Mon Sep 17 00:00:00 2001 From: Paul Voss Date: Sun, 12 Feb 2023 11:50:11 +0100 Subject: [PATCH 2/5] Use docker/metadata-action to generate image tags --- .github/workflows/image-latest.yml | 31 +++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/workflows/image-latest.yml b/.github/workflows/image-latest.yml index 05fbd28..af02b20 100644 --- a/.github/workflows/image-latest.yml +++ b/.github/workflows/image-latest.yml @@ -1,9 +1,10 @@ -name: Build latest image +name: Build docker image on: # Runs on pushes targeting the default branch push: - branches: ["buildx"] # replace with main + branches: ["buildx","buildx-semver", "main"] # replace with ["main"] + tags: ['*'] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -13,20 +14,24 @@ permissions: contents: read packages: write -# Allow one concurrent deployment -concurrency: - group: "image-latest" - cancel-in-progress: true - -env: - DEPLOY_TAG: latest - jobs: docker: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 + - name: Generate Docker metadata + id: meta + uses: docker/metadata-action@v3 + with: + images: | + ghcr.io/${{ github.repository }} + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + flavor: | + latest=true - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx @@ -40,7 +45,7 @@ jobs: - name: Build and push uses: docker/build-push-action@v4 with: - context: . - platforms: linux/amd64,linux/arm64 push: true - tags: ghcr.io/${{ github.repository }}:${{ env.DEPLOY_TAG }} + platforms: linux/amd64,linux/arm64 + labels: ${{ steps.meta.outputs.labels }} + tags: ${{ steps.meta.outputs.tags }} From 36231cad7f0ada88ce90e41a90571d3b49569b4d Mon Sep 17 00:00:00 2001 From: Paul Voss Date: Sun, 12 Feb 2023 12:16:10 +0100 Subject: [PATCH 3/5] Build docker image from local source repo --- .dockerignore | 2 ++ Dockerfile | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..80bf43b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.git* +docker-compose.yml diff --git a/Dockerfile b/Dockerfile index 55e0164..58b168c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,6 @@ FROM node:16-alpine -RUN apk add git -RUN git clone https://github.com/Metastem/wikiless.git WORKDIR /wikiless +COPY . /wikiless RUN npm install --no-optional COPY config.js.template config.js CMD npm start From a54e98953acc4e894474978fb8518949a5d6d06e Mon Sep 17 00:00:00 2001 From: Paul Voss Date: Sun, 12 Feb 2023 12:19:30 +0100 Subject: [PATCH 4/5] Bump docker/metadata-action to v4 --- .github/workflows/image-latest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/image-latest.yml b/.github/workflows/image-latest.yml index af02b20..5ffd03f 100644 --- a/.github/workflows/image-latest.yml +++ b/.github/workflows/image-latest.yml @@ -22,7 +22,7 @@ jobs: uses: actions/checkout@v3 - name: Generate Docker metadata id: meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v4 with: images: | ghcr.io/${{ github.repository }} From b3ce743d224f114785a5a61c3f8fe0efce130c44 Mon Sep 17 00:00:00 2001 From: Paul Voss Date: Sun, 12 Feb 2023 12:26:54 +0100 Subject: [PATCH 5/5] Rename image-latest github action --- .github/workflows/{image-latest.yml => build-image.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{image-latest.yml => build-image.yml} (100%) diff --git a/.github/workflows/image-latest.yml b/.github/workflows/build-image.yml similarity index 100% rename from .github/workflows/image-latest.yml rename to .github/workflows/build-image.yml