diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 2b3a4c6..c8de5ac 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -44,6 +44,14 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + # 👆 This is needed ARM emulation on AMD64 runner + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + # 👆 This is need for QEMU to work + - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: @@ -51,11 +59,15 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Set lowercase repository name + run: | + echo "LOWERCASE_REPO=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + - name: Extract metadata for Docker id: meta uses: docker/metadata-action@v5 with: - images: ghcr.io/${{ github.repository }} + images: ghcr.io/${{ env.LOWERCASE_REPO }} - name: Build and push uses: docker/build-push-action@v6 @@ -65,6 +77,6 @@ jobs: file: ./docker/Dockerfile push: true tags: | - ghcr.io/${{ github.repository }}:latest - ghcr.io/${{ github.repository }}:${{ github.sha }} + ghcr.io/${{ env.LOWERCASE_REPO }}:latest + ghcr.io/${{ env.LOWERCASE_REPO }}:${{ github.sha }} labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index e9230f5..27a28d5 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,8 +1,17 @@ # Using 18 alpine because supports arm/v8 and arm/v8 needed for silicon chips -FROM node:18-alpine -RUN apk add --no-cache bash + +# Builder stage with build tools - especially for node-gyp in arm64 +FROM node:18-alpine AS builder +RUN apk add --no-cache bash python3 make g++ WORKDIR /app ADD ./ . RUN npm install RUN npm run build + +# Runtime stage - minimal +FROM node:18-alpine +RUN apk add --no-cache bash +WORKDIR /app +ADD ./ . +COPY --from=builder /app/node_modules /app/node_modules CMD ["npm", "start"] \ No newline at end of file