Skip to content

Commit

Permalink
Build the app outside of Docker so we can cache the data in CI
Browse files Browse the repository at this point in the history
Refs: #28
  • Loading branch information
erkannt committed Jul 3, 2024
1 parent 89d0ba1 commit 3bc32c0
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 22 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/.dev/
/.git/
/.github/
/dist/
/node_modules/
/src/.observablehq/
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
Expand Down
18 changes: 1 addition & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3bc32c0

Please sign in to comment.