|
| 1 | +# syntax=docker/dockerfile:1.7 |
| 2 | +# |
| 3 | +# Builds the Gatsby site in ./website (monorepo workspace) and serves it via nginx. |
| 4 | +# |
| 5 | +# Build-time: |
| 6 | +# docker build -f Dockerfile.nivo-website --build-arg SITE_URL=http://localhost:8080 -t nivo-website:dev . |
| 7 | +# |
| 8 | +# Run: |
| 9 | +# docker run --rm -p 8080:80 nivo-website:dev |
| 10 | +# |
| 11 | +FROM node:22-bookworm-slim AS builder |
| 12 | + |
| 13 | +WORKDIR /app |
| 14 | + |
| 15 | +# Avoid downloading large E2E/browser binaries during image build. |
| 16 | +ENV CYPRESS_INSTALL_BINARY=0 |
| 17 | +ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 |
| 18 | +ENV PUPPETEER_SKIP_DOWNLOAD=1 |
| 19 | +ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 |
| 20 | + |
| 21 | +# Use the repo's pinned pnpm version via corepack. |
| 22 | +ENV PNPM_HOME=/pnpm |
| 23 | +ENV PATH="$PNPM_HOME:$PATH" |
| 24 | +RUN corepack enable && corepack prepare pnpm@10.11.0 --activate |
| 25 | + |
| 26 | +# Copy only what's needed to build the website. |
| 27 | +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./ |
| 28 | +COPY tsconfig*.json babel.config.js lerna.json eslint.config.mjs ./ |
| 29 | +COPY Makefile ./Makefile |
| 30 | +COPY conf ./conf |
| 31 | +COPY scripts ./scripts |
| 32 | +COPY packages ./packages |
| 33 | +COPY storybook ./storybook |
| 34 | +COPY website ./website |
| 35 | + |
| 36 | +RUN pnpm install --frozen-lockfile |
| 37 | + |
| 38 | +# The website depends on workspace packages, so build them first. |
| 39 | +RUN pnpm run pkgs:types:check && pnpm run pkgs:build |
| 40 | + |
| 41 | +# Gatsby uses SITE_URL during build (see website/gatsby-config.ts). |
| 42 | +ARG SITE_URL=http://localhost:8080 |
| 43 | +ENV SITE_URL="$SITE_URL" |
| 44 | + |
| 45 | +# Client-side API base URL for the "HTTP API" demo pages (Gatsby inlines GATSBY_* at build time). |
| 46 | +# Keep WITHOUT a trailing slash. |
| 47 | +# Default to the historical render API (override to use your own). |
| 48 | +ARG GATSBY_NIVO_API_URL=https://nivo-api.herokuapp.com/nivo |
| 49 | +ENV GATSBY_NIVO_API_URL="$GATSBY_NIVO_API_URL" |
| 50 | + |
| 51 | +# Client-side Storybook base URL (also inlined by Gatsby). |
| 52 | +# Keep WITHOUT a trailing slash unless you're using a path-only URL like /storybook/. |
| 53 | +ARG GATSBY_STORYBOOK_URL=/storybook/ |
| 54 | +ENV GATSBY_STORYBOOK_URL="$GATSBY_STORYBOOK_URL" |
| 55 | + |
| 56 | +RUN pnpm -C website build |
| 57 | +RUN pnpm --filter storybook build |
| 58 | + |
| 59 | + |
| 60 | +FROM nginx:1.27-alpine AS runtime |
| 61 | + |
| 62 | +COPY --from=builder /app/website/public /usr/share/nginx/html |
| 63 | +COPY --from=builder /app/storybook/storybook-static /usr/share/nginx/html/storybook |
| 64 | + |
| 65 | +# Default to the website-only nginx config; use NGINX_CONF to include an API proxy. |
| 66 | +ARG NGINX_CONF=deploy/nginx.website.conf |
| 67 | +COPY ${NGINX_CONF} /etc/nginx/conf.d/default.conf |
| 68 | + |
| 69 | +EXPOSE 80 |
0 commit comments