SimulationEmbed React island with click-to-activate iframes, theme sync via postMessage/MutationObserver, and graceful fallback when SpiceBook is unavailable. 12 simulations across 6 books (555 timer, op-amp, semiconductor, formulas, communications, sensor). Books without simulations render no extra markup. client:visible hydration defers JS cost until scrolled into view.
38 lines
1000 B
Docker
38 lines
1000 B
Docker
# Build stage
|
|
FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim AS base
|
|
WORKDIR /app
|
|
|
|
# Install Node.js
|
|
RUN apt-get update && apt-get install -y curl && \
|
|
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
|
|
apt-get install -y nodejs && \
|
|
apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
|
|
# Development target
|
|
FROM base AS development
|
|
WORKDIR /app
|
|
COPY package*.json ./
|
|
RUN npm install
|
|
COPY . .
|
|
EXPOSE 4321
|
|
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
|
|
|
|
# Build stage for production
|
|
FROM base AS builder
|
|
WORKDIR /app
|
|
ARG SITE_URL=https://forrest.warehack.ing
|
|
ARG PUBLIC_SPICEBOOK_URL=https://spicebook.warehack.ing
|
|
ENV SITE_URL=${SITE_URL}
|
|
ENV PUBLIC_SPICEBOOK_URL=${PUBLIC_SPICEBOOK_URL}
|
|
COPY package*.json ./
|
|
RUN npm ci
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
# Production target - serve static files with Caddy
|
|
FROM caddy:alpine AS production
|
|
COPY --from=builder /app/dist /srv
|
|
COPY Caddyfile /etc/caddy/Caddyfile
|
|
EXPOSE 4321
|
|
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile"]
|