From cf3ef70aa46b4ce4915c45b7141285260f09c146 Mon Sep 17 00:00:00 2001 From: Leonard Jonathan Oh Date: Mon, 22 Apr 2024 12:25:22 +0000 Subject: [PATCH] Enhancement: Add ubuntu variants --- .github/workflows/ci-master-pr.yml | 687 +++++++++++++++++++++++++++++ README.md | 31 ++ generate/definitions/VARIANTS.ps1 | 2 + generate/templates/Dockerfile.ps1 | 22 +- variants/16.04-ci/Dockerfile | 30 ++ variants/18.04-ci/Dockerfile | 30 ++ variants/20.04-ci/Dockerfile | 30 ++ variants/22.04-ci/Dockerfile | 30 ++ variants/24.04-ci/Dockerfile | 30 ++ 9 files changed, 885 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/ci-master-pr.yml create mode 100644 README.md create mode 100644 variants/16.04-ci/Dockerfile create mode 100644 variants/18.04-ci/Dockerfile create mode 100644 variants/20.04-ci/Dockerfile create mode 100644 variants/22.04-ci/Dockerfile create mode 100644 variants/24.04-ci/Dockerfile diff --git a/.github/workflows/ci-master-pr.yml b/.github/workflows/ci-master-pr.yml new file mode 100644 index 0000000..f0d025b --- /dev/null +++ b/.github/workflows/ci-master-pr.yml @@ -0,0 +1,687 @@ +name: ci-master-pr + +on: + push: + branches: + - master + tags: + - '**' + pull_request: + branches: + - master + merge_group: +jobs: + test-nogitdiff: + runs-on: ubuntu-latest + container: + image: mcr.microsoft.com/powershell:lts-7.2-alpine-3.17 + steps: + - run: | + apk add --no-cache git + - uses: actions/checkout@v3 + - name: Ignore git permissions + run: | + git config --global --add safe.directory "$( pwd )" + - name: Generate variants + run: | + pwsh -Command ' + $ErrorActionPreference = "Stop" + Install-Module -Name Generate-DockerImageVariants -Force -Scope CurrentUser -Verbose + Generate-DockerImageVariants . + ' + - name: Test - no git diff + run: | + git diff --exit-code + + build-24-04: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Display system info (linux) + run: | + set -e + hostname + whoami + cat /etc/*release + lscpu + free + df -h + pwd + docker info + docker version + + # See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + + - name: Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-24.04-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx-24.04- + ${{ runner.os }}-buildx- + + - name: Login to Docker Hub registry + # Run on master and tags + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + + # This step generates the docker tags + - name: Prepare + id: prep-24-04-ci + run: | + set -e + + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' + REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) + + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + VARIANT="24.04-ci" + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" + + # Pass variables to next step + echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_OUTPUT + echo "VARIANT=$VARIANT" >> $GITHUB_OUTPUT + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_OUTPUT + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_OUTPUT + + - name: 24.04-ci - Build (PRs) + # Run only on pull requests + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v5 + with: + context: variants/24.04-ci + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x + push: false + tags: | + ${{ github.repository }}:${{ steps.prep-24-04-ci.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-24-04-ci.outputs.REF_SHA_VARIANT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + - name: 24.04-ci - Build and push (master) + # Run only on master + if: github.ref == 'refs/heads/master' + uses: docker/build-push-action@v5 + with: + context: variants/24.04-ci + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x + push: true + tags: | + ${{ github.repository }}:${{ steps.prep-24-04-ci.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-24-04-ci.outputs.REF_SHA_VARIANT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + - name: 24.04-ci - Build and push (release) + if: startsWith(github.ref, 'refs/tags/') + uses: docker/build-push-action@v5 + with: + context: variants/24.04-ci + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x + push: true + tags: | + ${{ github.repository }}:${{ steps.prep-24-04-ci.outputs.VARIANT }} + ${{ github.repository }}:${{ steps.prep-24-04-ci.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-24-04-ci.outputs.REF_SHA_VARIANT }} + ${{ github.repository }}:latest + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + build-22-04: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Display system info (linux) + run: | + set -e + hostname + whoami + cat /etc/*release + lscpu + free + df -h + pwd + docker info + docker version + + # See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + + - name: Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-22.04-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx-22.04- + ${{ runner.os }}-buildx- + + - name: Login to Docker Hub registry + # Run on master and tags + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + + # This step generates the docker tags + - name: Prepare + id: prep-22-04-ci + run: | + set -e + + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' + REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) + + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + VARIANT="22.04-ci" + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" + + # Pass variables to next step + echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_OUTPUT + echo "VARIANT=$VARIANT" >> $GITHUB_OUTPUT + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_OUTPUT + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_OUTPUT + + - name: 22.04-ci - Build (PRs) + # Run only on pull requests + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v5 + with: + context: variants/22.04-ci + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x + push: false + tags: | + ${{ github.repository }}:${{ steps.prep-22-04-ci.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-22-04-ci.outputs.REF_SHA_VARIANT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + - name: 22.04-ci - Build and push (master) + # Run only on master + if: github.ref == 'refs/heads/master' + uses: docker/build-push-action@v5 + with: + context: variants/22.04-ci + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x + push: true + tags: | + ${{ github.repository }}:${{ steps.prep-22-04-ci.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-22-04-ci.outputs.REF_SHA_VARIANT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + - name: 22.04-ci - Build and push (release) + if: startsWith(github.ref, 'refs/tags/') + uses: docker/build-push-action@v5 + with: + context: variants/22.04-ci + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x + push: true + tags: | + ${{ github.repository }}:${{ steps.prep-22-04-ci.outputs.VARIANT }} + ${{ github.repository }}:${{ steps.prep-22-04-ci.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-22-04-ci.outputs.REF_SHA_VARIANT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + build-20-04: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Display system info (linux) + run: | + set -e + hostname + whoami + cat /etc/*release + lscpu + free + df -h + pwd + docker info + docker version + + # See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + + - name: Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-20.04-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx-20.04- + ${{ runner.os }}-buildx- + + - name: Login to Docker Hub registry + # Run on master and tags + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + + # This step generates the docker tags + - name: Prepare + id: prep-20-04-ci + run: | + set -e + + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' + REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) + + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + VARIANT="20.04-ci" + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" + + # Pass variables to next step + echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_OUTPUT + echo "VARIANT=$VARIANT" >> $GITHUB_OUTPUT + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_OUTPUT + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_OUTPUT + + - name: 20.04-ci - Build (PRs) + # Run only on pull requests + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v5 + with: + context: variants/20.04-ci + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x + push: false + tags: | + ${{ github.repository }}:${{ steps.prep-20-04-ci.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-20-04-ci.outputs.REF_SHA_VARIANT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + - name: 20.04-ci - Build and push (master) + # Run only on master + if: github.ref == 'refs/heads/master' + uses: docker/build-push-action@v5 + with: + context: variants/20.04-ci + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x + push: true + tags: | + ${{ github.repository }}:${{ steps.prep-20-04-ci.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-20-04-ci.outputs.REF_SHA_VARIANT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + - name: 20.04-ci - Build and push (release) + if: startsWith(github.ref, 'refs/tags/') + uses: docker/build-push-action@v5 + with: + context: variants/20.04-ci + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x + push: true + tags: | + ${{ github.repository }}:${{ steps.prep-20-04-ci.outputs.VARIANT }} + ${{ github.repository }}:${{ steps.prep-20-04-ci.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-20-04-ci.outputs.REF_SHA_VARIANT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + build-18-04: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Display system info (linux) + run: | + set -e + hostname + whoami + cat /etc/*release + lscpu + free + df -h + pwd + docker info + docker version + + # See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + + - name: Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-18.04-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx-18.04- + ${{ runner.os }}-buildx- + + - name: Login to Docker Hub registry + # Run on master and tags + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + + # This step generates the docker tags + - name: Prepare + id: prep-18-04-ci + run: | + set -e + + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' + REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) + + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + VARIANT="18.04-ci" + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" + + # Pass variables to next step + echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_OUTPUT + echo "VARIANT=$VARIANT" >> $GITHUB_OUTPUT + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_OUTPUT + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_OUTPUT + + - name: 18.04-ci - Build (PRs) + # Run only on pull requests + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v5 + with: + context: variants/18.04-ci + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x + push: false + tags: | + ${{ github.repository }}:${{ steps.prep-18-04-ci.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-18-04-ci.outputs.REF_SHA_VARIANT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + - name: 18.04-ci - Build and push (master) + # Run only on master + if: github.ref == 'refs/heads/master' + uses: docker/build-push-action@v5 + with: + context: variants/18.04-ci + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x + push: true + tags: | + ${{ github.repository }}:${{ steps.prep-18-04-ci.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-18-04-ci.outputs.REF_SHA_VARIANT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + - name: 18.04-ci - Build and push (release) + if: startsWith(github.ref, 'refs/tags/') + uses: docker/build-push-action@v5 + with: + context: variants/18.04-ci + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x + push: true + tags: | + ${{ github.repository }}:${{ steps.prep-18-04-ci.outputs.VARIANT }} + ${{ github.repository }}:${{ steps.prep-18-04-ci.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-18-04-ci.outputs.REF_SHA_VARIANT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + build-16-04: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Display system info (linux) + run: | + set -e + hostname + whoami + cat /etc/*release + lscpu + free + df -h + pwd + docker info + docker version + + # See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + + - name: Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-16.04-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx-16.04- + ${{ runner.os }}-buildx- + + - name: Login to Docker Hub registry + # Run on master and tags + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + + # This step generates the docker tags + - name: Prepare + id: prep-16-04-ci + run: | + set -e + + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' + REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) + + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + VARIANT="16.04-ci" + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" + + # Pass variables to next step + echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_OUTPUT + echo "VARIANT=$VARIANT" >> $GITHUB_OUTPUT + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_OUTPUT + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_OUTPUT + + - name: 16.04-ci - Build (PRs) + # Run only on pull requests + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v5 + with: + context: variants/16.04-ci + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x + push: false + tags: | + ${{ github.repository }}:${{ steps.prep-16-04-ci.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-16-04-ci.outputs.REF_SHA_VARIANT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + - name: 16.04-ci - Build and push (master) + # Run only on master + if: github.ref == 'refs/heads/master' + uses: docker/build-push-action@v5 + with: + context: variants/16.04-ci + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x + push: true + tags: | + ${{ github.repository }}:${{ steps.prep-16-04-ci.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-16-04-ci.outputs.REF_SHA_VARIANT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + - name: 16.04-ci - Build and push (release) + if: startsWith(github.ref, 'refs/tags/') + uses: docker/build-push-action@v5 + with: + context: variants/16.04-ci + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x + push: true + tags: | + ${{ github.repository }}:${{ steps.prep-16-04-ci.outputs.VARIANT }} + ${{ github.repository }}:${{ steps.prep-16-04-ci.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-16-04-ci.outputs.REF_SHA_VARIANT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + update-draft-release: + needs: + - build-24-04 + - build-22-04 + - build-20-04 + - build-18-04 + - build-16-04 + if: github.ref == 'refs/heads/master' + runs-on: ubuntu-latest + steps: + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + with: + config-name: release-drafter.yml + publish: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish-draft-release: + needs: + - build-24-04 + - build-22-04 + - build-20-04 + - build-18-04 + - build-16-04 + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + with: + config-name: release-drafter.yml + publish: true + name: ${{ github.ref_name }} # E.g. 'master' or 'v1.2.3' + tag: ${{ github.ref_name }} # E.g. 'master' or 'v1.2.3' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + update-dockerhub-description: + needs: + - build-24-04 + - build-22-04 + - build-20-04 + - build-18-04 + - build-16-04 + if: github.ref == 'refs/heads/master' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Docker Hub Description + uses: peter-evans/dockerhub-description@v3 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + repository: ${{ github.repository }} + short-description: ${{ github.event.repository.description }} diff --git a/README.md b/README.md new file mode 100644 index 0000000..75bf080 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# docker-ubuntu + +[![github-actions](https://github.com/theohbrothers/docker-ubuntu/actions/workflows/ci-master-pr.yml/badge.svg?branch=master)](https://github.com/theohbrothers/docker-ubuntu/actions/workflows/ci-master-pr.yml) +[![github-release](https://img.shields.io/github/v/release/theohbrothers/docker-ubuntu?style=flat-square)](https://github.com/theohbrothers/docker-ubuntu/releases/) +[![docker-image-size](https://img.shields.io/docker/image-size/theohbrothers/docker-ubuntu/latest)](https://hub.docker.com/r/theohbrothers/docker-ubuntu) + +Dockerized ubuntu with useful tools. + +## Tags + +| Tag | Dockerfile Build Context | +|:-------:|:---------:| +| `:24.04-ci`, `:latest` | [View](variants/24.04-ci) | +| `:22.04-ci` | [View](variants/22.04-ci) | +| `:20.04-ci` | [View](variants/20.04-ci) | +| `:18.04-ci` | [View](variants/18.04-ci) | +| `:16.04-ci` | [View](variants/16.04-ci) | + +## Development + +Requires Windows `powershell` or [`pwsh`](https://github.com/PowerShell/PowerShell). + +```powershell +# Install Generate-DockerImageVariants module: https://github.com/theohbrothers/Generate-DockerImageVariants +Install-Module -Name Generate-DockerImageVariants -Repository PSGallery -Scope CurrentUser -Force -Verbose + +# Edit ./generate templates + +# Generate the variants +Generate-DockerImageVariants . +``` diff --git a/generate/definitions/VARIANTS.ps1 b/generate/definitions/VARIANTS.ps1 index fb97f48..354d1c4 100644 --- a/generate/definitions/VARIANTS.ps1 +++ b/generate/definitions/VARIANTS.ps1 @@ -1,7 +1,9 @@ $local:VARIANTS_DISTRO_VERSIONS = @( + '24.04' '22.04' '20.04' '18.04' + '16.04' ) # Docker image variants' definitions $local:VARIANTS_MATRIX = @( diff --git a/generate/templates/Dockerfile.ps1 b/generate/templates/Dockerfile.ps1 index 31a1491..be256ce 100644 --- a/generate/templates/Dockerfile.ps1 +++ b/generate/templates/Dockerfile.ps1 @@ -4,10 +4,12 @@ FROM $( $VARIANT['_metadata']['distro'] ):$( $VARIANT['_metadata']['distro_versi RUN set -eux; \ apt-get update; \ apt-get install --no-install-recommends -y \ - ca-certificates \ - # dnsutils iproute2 netcat net-tools \ - # rsync \ - wget; + ca-certificates \ + # dnsutils iproute2 netcat net-tools \ + # rsync \ + wget; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; "@ @@ -21,7 +23,9 @@ $VARIANT['_metadata']['components'] | % { @" RUN set -eux; \ apt-get update; \ - apt-get install --no-install-recommends -y bats + apt-get install --no-install-recommends -y bats; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; "@ @@ -31,7 +35,9 @@ RUN set -eux; \ @" RUN set -eux; \ apt-get update; \ - apt-get install --no-install-recommends -y curl + apt-get install --no-install-recommends -y curl; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; "@ @@ -41,7 +47,9 @@ RUN set -eux; \ @" RUN set -eux; \ apt-get update; \ - apt-get install --no-install-recommends -y jq + apt-get install --no-install-recommends -y jq; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; "@ diff --git a/variants/16.04-ci/Dockerfile b/variants/16.04-ci/Dockerfile new file mode 100644 index 0000000..325bce7 --- /dev/null +++ b/variants/16.04-ci/Dockerfile @@ -0,0 +1,30 @@ +FROM ubuntu:16.04 + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y \ + ca-certificates \ + # dnsutils iproute2 netcat net-tools \ + # rsync \ + wget; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y bats; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y curl; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y jq; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + diff --git a/variants/18.04-ci/Dockerfile b/variants/18.04-ci/Dockerfile new file mode 100644 index 0000000..0d74789 --- /dev/null +++ b/variants/18.04-ci/Dockerfile @@ -0,0 +1,30 @@ +FROM ubuntu:18.04 + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y \ + ca-certificates \ + # dnsutils iproute2 netcat net-tools \ + # rsync \ + wget; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y bats; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y curl; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y jq; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + diff --git a/variants/20.04-ci/Dockerfile b/variants/20.04-ci/Dockerfile new file mode 100644 index 0000000..4576daa --- /dev/null +++ b/variants/20.04-ci/Dockerfile @@ -0,0 +1,30 @@ +FROM ubuntu:20.04 + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y \ + ca-certificates \ + # dnsutils iproute2 netcat net-tools \ + # rsync \ + wget; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y bats; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y curl; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y jq; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + diff --git a/variants/22.04-ci/Dockerfile b/variants/22.04-ci/Dockerfile new file mode 100644 index 0000000..4cb8afe --- /dev/null +++ b/variants/22.04-ci/Dockerfile @@ -0,0 +1,30 @@ +FROM ubuntu:22.04 + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y \ + ca-certificates \ + # dnsutils iproute2 netcat net-tools \ + # rsync \ + wget; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y bats; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y curl; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y jq; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + diff --git a/variants/24.04-ci/Dockerfile b/variants/24.04-ci/Dockerfile new file mode 100644 index 0000000..e5a1655 --- /dev/null +++ b/variants/24.04-ci/Dockerfile @@ -0,0 +1,30 @@ +FROM ubuntu:24.04 + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y \ + ca-certificates \ + # dnsutils iproute2 netcat net-tools \ + # rsync \ + wget; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y bats; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y curl; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y jq; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; +