From 3bc32c02b4763e62e99a1ec99953482a5741dc82 Mon Sep 17 00:00:00 2001 From: Daniel Haarhoff Date: Wed, 3 Jul 2024 11:21:55 +0100 Subject: [PATCH] Build the app outside of Docker so we can cache the data in CI Refs: #28 --- .dockerignore | 1 - .github/workflows/ci.yml | 3 --- Dockerfile | 18 +----------------- Makefile | 3 ++- package-lock.json | 1 + 5 files changed, 4 insertions(+), 22 deletions(-) diff --git a/.dockerignore b/.dockerignore index 053478f..1551a21 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,5 @@ /.dev/ /.git/ /.github/ -/dist/ /node_modules/ /src/.observablehq/ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2085039..d5b42c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,10 +55,7 @@ jobs: outputs: type=docker,dest=/tmp/image.tar cache-from: type=gha,ignore-error=true cache-to: type=gha,mode=max,ignore-error=true - no-cache-filters: build target: prod - secrets: | - PREREVIEW_REVIEWS_DATA_TOKEN=${{ secrets.PREREVIEW_REVIEWS_DATA_TOKEN }} - name: 'Upload build' uses: actions/upload-artifact@v4.3.3 diff --git a/Dockerfile b/Dockerfile index 7914487..0bebb4f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,4 @@ -FROM node:20.13.1-alpine3.18 AS builder -WORKDIR /app -ENV OBSERVABLE_TELEMETRY_DISABLE=1 - -COPY package.json \ - package-lock.json \ - ./ -RUN npm ci --ignore-scripts --production -COPY observablehq.config.js observablehq.config.js -COPY src/ src/ - -FROM builder AS build -RUN --mount=type=secret,id=PREREVIEW_REVIEWS_DATA_TOKEN \ - PREREVIEW_REVIEWS_DATA_TOKEN=$(cat /run/secrets/PREREVIEW_REVIEWS_DATA_TOKEN) \ - npx observable build - FROM caddy:2.8.4-alpine AS prod COPY Caddyfile /etc/caddy/Caddyfile -COPY --from=build /app/dist /usr/share/caddy +COPY dist/ /usr/share/caddy EXPOSE 80 diff --git a/Makefile b/Makefile index 0c10f7e..e8e581d 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,8 @@ start: .env node_modules npx @dotenvx/dotenvx run -- npx observable preview build-image: .env node_modules - npx @dotenvx/dotenvx run -- docker build --target prod --tag ${IMAGE_TAG} . + npx @dotenvx/dotenvx run -- npx observable build + docker build --target prod --tag ${IMAGE_TAG} . check: format lint typecheck diff --git a/package-lock.json b/package-lock.json index 6fad6b7..e96feaf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -339,6 +339,7 @@ }, "node_modules/@clack/prompts/node_modules/is-unicode-supported": { "version": "1.3.0", + "extraneous": true, "inBundle": true, "license": "MIT", "engines": {