diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index a47b98f..5b74e49 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -4,15 +4,26 @@ on: branches: - main -env: - IMAGE_TAG: latest-arm64 - jobs: build-and-deploy: + strategy: + matrix: + bot-phrases-file: [default.js, dracula.js] + include: + - bot-phrases-file: default.js + image-suffix: "" + - bot-phrases-file: dracula.js + image-suffix: -dracula runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to container registry uses: docker/login-action@v3 with: @@ -20,26 +31,17 @@ jobs: username: ${{ secrets.REGISTRY_USER }} password: ${{ secrets.REGISTRY_PASSWORD }} - - name: Setup node.js - uses: actions/setup-node@v2 - with: - node-version: '14.15.3' - - - name: Install dependencies - run: npm install - - - name: Build application - run: npm run build - # See: https://github.com/orgs/community/discussions/25768#discussioncomment-3249186 - name: Set lowercase image name env var run: | echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} - - name: Build and push image - run: | - docker buildx build --platform linux/arm64 --target release -t "${{ secrets.REGISTRY }}/$IMAGE_NAME:$IMAGE_TAG" --push . - - - name: Build and push dracula image - run: | - docker buildx build --build-arg BOT_PHRASES_URL=${{ secrets.DRACULA_URL }}" --platform linux/arm64 --target release -t "${{ secrets.REGISTRY }}/$IMAGE_NAME-dracula:$IMAGE_TAG" --push . + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/arm64/v8 + push: true + tags: ${{ secrets.REGISTRY }}/${{ env.IMAGE_NAME }}${{ matrix.image-suffix }}:latest + build-args: | + BOT_PHRASES_URL=https://static.glob.casa/basic-chess-ai/bot-phrases/${{ matrix.bot-phrases-file }} diff --git a/Dockerfile b/Dockerfile index 2ba71f0..8b8d6e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ RUN npm install COPY . . RUN npm run build -FROM nginx:stable-alpine AS release +FROM nginx:stable-alpine ARG BOT_PHRASES_URL="" COPY --from=builder /app/public /usr/share/nginx/html -RUN test -n "$BOT_PHRASES_URL" && curl -o /usr/share/nginx/html/js/botPhrases.js "$BOT_PHRASES_URL" +RUN curl -o /usr/share/nginx/html/js/botPhrases.js $BOT_PHRASES_URL