From 60b67ee7587fa052635621fe7423fa240a94b88a Mon Sep 17 00:00:00 2001 From: Donkie Date: Sun, 17 Dec 2023 22:53:17 +0100 Subject: [PATCH] Dockerfile no longer builds client This proved to be extremely slow on emulated hardware to build e.g. the linux/arm/v7 image. Since the built client is architecture agnostic, it's instead now built on the native hardware and inserted into the docker image. --- .github/workflows/ci.yml | 65 ++++++++++++++++++++++++++++++++++++++-- Dockerfile | 11 +------ 2 files changed, 63 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f1d3d4..e4bd8cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,14 +35,53 @@ jobs: - name: Run pre-commit run: pre-commit run --all-files # - # Build native image for integration tests + # Build the Spoolman client for baking into the docker images + # This is done on native hardware to speed things up, vite is very slow on emulated hardware # - build-amd64: + build-client: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 + - name: Install node + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Install dependencies + run: | + cd client + npm ci + + - name: Build + run: | + cd client + rm -f .env && echo "VITE_APIURL=/api/v1" > .env.production + npm run build + npm run build.zip + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: client + path: client/dist + # + # Build native image for integration tests + # + build-amd64: + needs: [build-client] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Download client + uses: actions/download-artifact@v3 + with: + name: client + path: client/dist + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -158,11 +197,18 @@ jobs: # build-arm64: if: ${{ github.event_name != 'pull_request' }} + needs: [build-client] runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 + - name: Download client + uses: actions/download-artifact@v3 + with: + name: client + path: client/dist + - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -190,11 +236,18 @@ jobs: # build-armv7: if: ${{ github.event_name != 'pull_request' }} + needs: [build-client] runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 + - name: Download client + uses: actions/download-artifact@v3 + with: + name: client + path: client/dist + - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -221,12 +274,18 @@ jobs: # release: if: ${{ github.event_name != 'pull_request' }} - needs: [test, build-amd64, build-arm64, build-armv7, style] + needs: [test, build-amd64, build-arm64, build-armv7, style, build-client] runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 + - name: Download client + uses: actions/download-artifact@v3 + with: + name: client + path: client/dist + - name: Set up QEMU uses: docker/setup-qemu-action@v2 diff --git a/Dockerfile b/Dockerfile index 919a02b..e0d7f6c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,3 @@ -FROM node:20-alpine as client-builder - -COPY ./client /client -WORKDIR /client -RUN npm ci - -RUN rm -f .env && echo "VITE_APIURL=/api/v1" > .env.production -RUN npm run build - FROM python:3.11-alpine as python-builder RUN apk add --no-cache g++ python3-dev libpq-dev libstdc++ @@ -49,7 +40,7 @@ RUN adduser -D app \ USER app # Copy built client -COPY --chown=app:app --from=client-builder /client/dist /home/app/spoolman/client/dist +COPY --chown=app:app ./client/dist /home/app/spoolman/client/dist # Copy built app COPY --chown=app:app --from=python-builder /home/app/spoolman /home/app/spoolman