diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index fdbc55c..06e7657 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -27,6 +27,7 @@ jobs: ISHOCON_APP_LANG: ${{ matrix.language }} UNAME: ${{ secrets.DOCKER_HUB_USERNAME }} steps: + - run: echo "DATE=$(date +%Y%m%d)" >> $GITHUB_ENV - uses: actions/checkout@v4 - name: Replace base image in docker-compose.yml with github actor name run: | @@ -40,10 +41,50 @@ jobs: with: username: ${{ env.UNAME }} password: ${{ secrets.DOCKER_HUB_TOKEN }} - - name: Build images + - name: Cache docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - name: Build bench image + uses: docker/build-push-action@v5 + with: + context: . + file: ./docker/benchmarker/Dockerfile + tags: ${{ env.UNAME }}/ishocon2-bench:latest,${{ env.UNAME }}/ishocon2-bench:${{ env.DATE }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + - name: Build base image + uses: docker/build-push-action@v5 + with: + context: . + file: ./docker/app/base/Dockerfile + tags: ${{ env.UNAME }}/ishocon2-app-base:latest,${{ env.UNAME }}/ishocon2-app-base:${{ env.DATE }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + - name: Build app image + uses: docker/build-push-action@v5 + with: + context: . + push: true + file: ./docker/app/${{ env.ISHOCON_APP_LANG }}/Dockerfile + tags: ${{ env.UNAME }}/ishocon2-app-${{ env.ISHOCON_APP_LANG }}:latest,${{ env.UNAME }}/ishocon2-app-${{ env.ISHOCON_APP_LANG }}:${{ env.DATE }} + build-args: BASE_IMAGE=${{ env.UNAME }}/ishocon2-app-base:latest + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + - name: Move new cache to the place where to be cached run: | - make pull || true - make build + echo "Temporary fix for cleaning up old cache." + echo "See isssues: + - https://github.com/docker/build-push-action/issues/252 + - https://github.com/moby/buildkit/issues/1896 + " + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + - name: Build images + run: make build timeout-minutes: 20 - run: make up bench-with-db-init timeout-minutes: 10