diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..e24b65f --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,52 @@ +name: Build and publish Docker image + +on: + release: + types: [published] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: docker-publish-${{ github.ref }} + cancel-in-progress: false + +jobs: + build-and-push: + name: Build and push moepchi/webspeak3 + runs-on: ubuntu-latest + timeout-minutes: 30 + + steps: + - name: Check out repository + uses: actions/checkout@v5 + with: + submodules: recursive + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Determine image tags + id: tags + run: | + TAGS="moepchi/webspeak3:latest" + if [ "${{ github.event_name }}" = "release" ]; then + TAGS="$TAGS,moepchi/webspeak3:${{ github.event.release.tag_name }}" + fi + echo "tags=$TAGS" >> "$GITHUB_OUTPUT" + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ steps.tags.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index faf8ca2..fda039e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,15 @@ FROM node:22-bookworm-slim AS web-builder WORKDIR /src/web COPY web/package*.json ./ RUN npm ci +# Vite 8 pulls in Rolldown, which ships its bundler as a platform-specific +# optional dependency (@rolldown/binding-linux-x64-gnu here). `npm ci` +# intermittently fails to install it due to a long-standing npm bug +# (https://github.com/npm/cli/issues/4828) without raising a non-zero exit +# code, so `vite build` only fails later with a confusing MODULE_NOT_FOUND. +# Verify the binding actually loaded and self-heal via the workaround from +# npm's own error message before wasting a full build on a broken install. +RUN node -e "require('@rolldown/binding-linux-x64-gnu')" \ + || (rm -rf node_modules package-lock.json && npm install) COPY web/ ./ # tsc -b currently fails on pre-existing type errors unrelated to this build; # vite build alone is enough to produce the production bundle.