diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 74957608f..7ecbafa7e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,14 +44,48 @@ jobs: locale: "US" level: error + - uses: docker/setup-buildx-action@v2 + + - uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Build and cache base image layers + uses: docker/build-push-action@v4 + with: + target: base + 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 + - name: Linting - run: docker build --target lint . + uses: docker/build-push-action@v4 + with: + target: lint + cache-from: type=local,src=/tmp/.buildx-cache - name: Mocks check - run: docker build --target mocks . + uses: docker/build-push-action@v4 + with: + target: mocks + cache-from: type=local,src=/tmp/.buildx-cache - name: Build test image - run: docker build --target test -t test-container . + uses: docker/build-push-action@v4 + with: + target: tests + tags: test-container + cache-from: type=local,src=/tmp/.buildx-cache - name: Run tests in test container run: | @@ -61,7 +95,12 @@ jobs: test-container - name: Build final image - run: docker build -t final-image . + uses: docker/build-push-action@v4 + with: + target: tests + tags: final-image + push: false + cache-from: type=local,src=/tmp/.buildx-cache codeql: runs-on: ubuntu-latest