name: devel-docker on: pull_request: paths: - docker/**/Dockerfile - scripts/ci/**/*.sh - .github/workflows/devel.docker.yml push: branches: - master - staging - trying paths: - docker/**/Dockerfile - scripts/ci/**/*.sh - .github/workflows/devel.docker.yml env: DOCKER_IMAGE: localhost:5000/github.com/static-web-server/static-web-server jobs: docker-alpine: name: Docker test (alpine) strategy: matrix: arch: - linux/amd64 - linux/386 - linux/arm64 - linux/arm/v7 - linux/arm/v6 runs-on: ubuntu-22.04 services: registry: image: registry:2 ports: - 5000:5000 steps: - name: Dependencies run: | sudo apt-get install jq - name: Checkout uses: actions/checkout@v3 with: fetch-depth: 1 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache key: static-web-server-${{ matrix.arch }}-alpine-buildx-${{ github.sha }} restore-keys: | static-web-server-${{ matrix.arch }}-alpine-buildx- - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Docker meta alpine id: meta_alpine uses: docker/metadata-action@v4 with: images: ${{ env.DOCKER_IMAGE }} flavor: | latest=false suffix=-alpine tags: | type=schedule type=ref,event=branch type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} type=sha - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 with: driver-opts: network=host - name: Prepare Docker envs shell: bash env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | scripts/ci/get_latest_release.sh cat /tmp/version >> $GITHUB_ENV cat /tmp/version echo "SERVER_DOCKERFILE=./docker/alpine/Dockerfile" >> $GITHUB_ENV - name: Build and export to Docker client uses: docker/build-push-action@v4 with: context: . platforms: ${{ matrix.arch }} file: ${{ env.SERVER_DOCKERFILE }} load: true tags: ${{ steps.meta_alpine.outputs.tags }} labels: ${{ steps.meta_alpine.outputs.labels }} build-args: | SERVER_VERSION=${{ env.SERVER_VERSION }} - name: Build and push to local registry uses: docker/build-push-action@v4 with: context: . platforms: ${{ matrix.arch }} file: ${{ env.SERVER_DOCKERFILE }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta_alpine.outputs.tags }} labels: ${{ steps.meta_alpine.outputs.labels }} build-args: | SERVER_VERSION=${{ env.SERVER_VERSION }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Inspect image run: | docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta_alpine.outputs.version }} - name: Check manifest if: github.event_name != 'pull_request' run: | docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta_alpine.outputs.version }} - # 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 docker-debian: name: Docker test (debian) strategy: matrix: arch: - linux/amd64 - linux/386 - linux/arm64 - linux/arm/v7 - linux/arm/v6 - linux/ppc64le - linux/s390x runs-on: ubuntu-22.04 services: registry: image: registry:2 ports: - 5000:5000 steps: - name: Dependencies run: | sudo apt-get install jq - name: Checkout uses: actions/checkout@v3 with: fetch-depth: 1 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache key: static-web-server-${{ matrix.arch }}-debian-buildx-${{ github.sha }} restore-keys: | static-web-server-${{ matrix.arch }}-debian-buildx- - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Docker meta debian id: meta_debian uses: docker/metadata-action@v4 with: images: ${{ env.DOCKER_IMAGE }} flavor: | latest=false suffix=-debian tags: | type=schedule type=ref,event=branch type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} type=sha - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 with: driver-opts: network=host - name: Prepare Docker envs shell: bash env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | scripts/ci/get_latest_release.sh cat /tmp/version >> $GITHUB_ENV cat /tmp/version echo "SERVER_DOCKERFILE=./docker/debian/Dockerfile" >> $GITHUB_ENV - name: Build and export to Docker client uses: docker/build-push-action@v4 with: context: . platforms: ${{ matrix.arch }} file: ${{ env.SERVER_DOCKERFILE }} load: true tags: ${{ steps.meta_debian.outputs.tags }} labels: ${{ steps.meta_debian.outputs.labels }} build-args: | SERVER_VERSION=${{ env.SERVER_VERSION }} - name: Build and push to local registry uses: docker/build-push-action@v4 with: context: . platforms: ${{ matrix.arch }} file: ${{ env.SERVER_DOCKERFILE }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta_debian.outputs.tags }} labels: ${{ steps.meta_debian.outputs.labels }} build-args: | SERVER_VERSION=${{ env.SERVER_VERSION }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Inspect image run: | docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta_debian.outputs.version }} - name: Check manifest if: github.event_name != 'pull_request' run: | docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta_debian.outputs.version }} - # 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