From 854767cfad9ee9365fdc4fd1c08b4a5a081cc5bc Mon Sep 17 00:00:00 2001 From: Hugh Nimmo-Smith Date: Tue, 7 May 2024 16:16:50 +0100 Subject: [PATCH] Use Node.js 20 and publish docker images --- .github/workflows/ci.yml | 46 ++++++++++++++++++++++++++++++++++++++++ .nvmrc | 2 +- Dockerfile | 4 ++-- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70981b4..4252ec2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,10 +5,16 @@ on: pull_request: branches: [main] +env: + IMAGE_NAME: ${{ github.repository }} + REGISTRY: ghcr.io + jobs: test: name: 'Test' runs-on: ubuntu-latest + permissions: + contents: read steps: - name: Checkout uses: actions/checkout@v4 @@ -31,6 +37,8 @@ jobs: build: name: 'Build' runs-on: ubuntu-latest + permissions: + contents: read steps: - name: Checkout uses: actions/checkout@v4 @@ -52,11 +60,49 @@ jobs: - name: Docker build run: docker build . + docker: + name: 'Docker publish' + needs: [test, build] + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 + deploy-demo: name: Deploy demo site if: github.event_name == 'push' && github.ref == 'refs/heads/main' needs: [test, build] runs-on: ubuntu-latest + permissions: + contents: read + pages: write steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.nvmrc b/.nvmrc index 3c03207..209e3ef 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -18 +20 diff --git a/Dockerfile b/Dockerfile index f5b8ebf..1f94f73 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:18-alpine as builder +FROM --platform=${BUILDPLATFORM} node:20-alpine as builder ARG DEFAULT_HOMESERVER @@ -13,6 +13,6 @@ COPY tsconfig.json webpack.config.js webpack.parts.js ./ ENV DEFAULT_HOMESERVER ${DEFAULT_HOMESERVER} RUN yarn build -FROM nginxinc/nginx-unprivileged:1.21-alpine +FROM --platform=${TARGETPLATFORM} nginxinc/nginx-unprivileged:1-alpine COPY --from=builder /files-sdk-demo/dist /usr/share/nginx/html