From 9b2b785deaa87c94f1ec2254b91c1ed8993a72f3 Mon Sep 17 00:00:00 2001 From: Wentao Kuang Date: Tue, 1 Oct 2024 12:30:13 +1300 Subject: [PATCH] fix(cli): Install server package in the cli container to inlcude lerc. (#3353) ### Motivation The [cli container](https://github.com/linz/basemaps-config/actions/runs/11096451992/job/30827033370?pr=984) requires lerc to be installed which come from server. ` node:internal/modules/cjs/loader:1228 throw err; ^ Error: Cannot find module 'lerc' Require stack: - /app/index.cjs at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15) at Module._load (node:internal/modules/cjs/loader:1051:27) at Module.require (node:internal/modules/cjs/loader:1311:19) at require (node:internal/modules/helpers:179:18) at Object. (/app/index.cjs:190419:27) at Module._compile (node:internal/modules/cjs/loader:1469:14) at Module._extensions..js (node:internal/modules/cjs/loader:1548:10) at Module.load (node:internal/modules/cjs/loader:1288:32) at Module._load (node:internal/modules/cjs/loader:1104:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:[174](https://github.com/linz/basemaps-config/actions/runs/11096451992/job/30827033370?pr=984#step:6:175):12) { code: 'MODULE_NOT_FOUND', requireStack: [ '/app/index.cjs' ] } ` ### Modifications Install serve package in the cli container. ### Verification Container fixed after install server package, add smoke test in the container ci/cd for validation --- .github/workflows/containers.yml | 28 +++++++++++++++++++++++++++- packages/cli/Dockerfile | 3 ++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml index baee7a851..3e694aa3b 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -56,6 +56,19 @@ jobs: - name: Log in to registry run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + - name: '@basemaps/cli - Build and export to Docker' + uses: docker/build-push-action@v5 + with: + context: packages/cli + load: true + tags: | + ghcr.io/linz/basemaps/cli:latest + ghcr.io/linz/basemaps/cli:${{ steps.version.outputs.version }} + + - name: '@basemaps/cli - Test' + run: | + docker run --rm ghcr.io/linz/basemaps/cli:${{ steps.version.outputs.version }} --help + - name: '@basemaps/cli - Build and push' uses: docker/build-push-action@v5 with: @@ -77,9 +90,21 @@ jobs: ghcr.io/linz/basemaps/cli:${{ steps.version.outputs.version_major }} ghcr.io/linz/basemaps/cli:${{ steps.version.outputs.version_major_minor }} ghcr.io/linz/basemaps/cli:${{ steps.version.outputs.version }} - push: ${{github.ref == 'refs/heads/master' && startsWith(github.event.head_commit.message, 'release:')}} + - name: '@basemaps/server - Build and export to Docker' + uses: docker/build-push-action@v5 + with: + context: packages/server + load: true + tags: | + ghcr.io/linz/basemaps/server:latest + ghcr.io/linz/basemaps/server:${{ steps.version.outputs.version }} + + - name: '@basemaps/server - Test' + run: | + docker run --rm ghcr.io/linz/basemaps/server:${{ steps.version.outputs.version }} --version + - name: '@basemaps/server - Build and push' uses: docker/build-push-action@v5 with: @@ -102,3 +127,4 @@ jobs: ghcr.io/linz/basemaps/server:${{ steps.version.outputs.version_major_minor }} ghcr.io/linz/basemaps/server:${{ steps.version.outputs.version }} push: ${{github.ref == 'refs/heads/master' && startsWith(github.event.head_commit.message, 'release:')}} + diff --git a/packages/cli/Dockerfile b/packages/cli/Dockerfile index 3ba8ea493..c436f6e51 100644 --- a/packages/cli/Dockerfile +++ b/packages/cli/Dockerfile @@ -21,11 +21,12 @@ RUN npm install sharp@0.33.0 COPY ./basemaps-landing*.tgz /app/ COPY ./basemaps-cogify*.tgz /app/ COPY ./basemaps-smoke*.tgz /app/ +COPY ./basemaps-server*.tgz /app/ # Copy the static files for v1/health check COPY ./static/ /app/static/ -RUN npm install ./basemaps-landing*.tgz ./basemaps-cogify*.tgz ./basemaps-smoke*.tgz +RUN npm install ./basemaps-landing*.tgz ./basemaps-cogify*.tgz ./basemaps-smoke*.tgz ./basemaps-server*.tgz COPY dist/index.cjs /app/