Skip to content

Commit

Permalink
Merge pull request #10 from Jarvl/fix-prod-build
Browse files Browse the repository at this point in the history
Fix prod build
  • Loading branch information
Jarvl authored Feb 21, 2024
2 parents fd0999c + cbfec92 commit 35553f2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
44 changes: 23 additions & 21 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,44 @@ 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:
registry: ${{ secrets.REGISTRY }}
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 }}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 35553f2

Please sign in to comment.