From 79c3d885b092bcd5e453564f9a7cae8c6667d445 Mon Sep 17 00:00:00 2001 From: Vio Date: Thu, 2 Nov 2023 23:06:50 +0100 Subject: [PATCH] build: Run build task inside Docker --- .dockerignore | 1 + .github/workflows/ci.yaml | 30 +----------------------------- Dockerfile | 18 ++++++++++++++++++ package.json | 1 + 4 files changed, 21 insertions(+), 29 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..3c3629e6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 40d8586f..c0c9a9f4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,32 +13,4 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Cache node modules - uses: actions/cache@v2 - env: - cache-name: cache-node-modules - with: - path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node-version }} - - - run: npm ci - - - run: npm run build --if-present - env: - RELATIVE_CI_KEY: ${{ secrets.RELATIVE_CI_KEY }} - DEBUG: ${{ secrets.DEBUG }} - - - name: Upload artifacts - uses: actions/upload-artifact@v2 - with: - name: artifacts - path: artifacts + - run: npm run container-build diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..23a823ef --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +from node:16 as base + +ARG CI=true +ARG SERVICE="github-action-docker" +ARG REPOSITORY +ARG BRANCH +ARG PR +ARG BUILD +ARG BUILD_URL +ARG SHA + +COPY . /app +WORKDIR /app + +from base as build + +RUN npm install +RUN DEBUG=relative-ci:* npm run build diff --git a/package.json b/package.json index 35e693c4..b639930a 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "start": "webpack-dev-server", "build": "webpack --mode production --json artifacts/webpack-stats.json", + "container-build": "docker build . --no-cache-filter=build --progress=plain", "test": "echo \"Error: no test specified\" && exit 0" }, "keywords": [],