Files
calctext/Dockerfile
C. Cassel 1e640aa0c8 fix: use base URL for Supabase client, nginx proxies /rest/v1/ and /auth/v1/
The Supabase JS client auto-derives API paths from the base URL:
- REST: ${url}/rest/v1/
- Auth: ${url}/auth/v1/

Nginx now proxies these standard paths to the correct backend services.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 16:45:36 -04:00

64 lines
2.3 KiB
Docker

# Stage 1 — Build WASM from Rust
FROM rust:1.85-bookworm AS wasm-builder
# Install wasm-pack via pre-built binary (much faster than cargo install)
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
WORKDIR /app
# Copy workspace Cargo.toml
COPY Cargo.toml ./
# Copy the crates we actually need to compile
COPY calcpad-engine/ calcpad-engine/
COPY calcpad-wasm/ calcpad-wasm/
# Create stub Cargo.toml + src for workspace members we don't need to build.
# The workspace requires all members to exist, but we never compile these.
RUN mkdir -p calcpad-cli/src && \
printf '[package]\nname = "calcpad-cli"\nversion = "0.1.0"\nedition = "2021"\n\n[[bin]]\nname = "calcpad"\npath = "src/main.rs"\n\n[dependencies]\ncalcpad-engine = { path = "../calcpad-engine" }\n' > calcpad-cli/Cargo.toml && \
echo 'fn main() {}' > calcpad-cli/src/main.rs && \
mkdir -p calcpad-windows/src && \
printf '[package]\nname = "calcpad-windows"\nversion = "0.1.0"\nedition = "2021"\n\n[[bin]]\nname = "calcpad-win"\npath = "src/main.rs"\n' > calcpad-windows/Cargo.toml && \
echo 'fn main() {}' > calcpad-windows/src/main.rs
# Build WASM
RUN wasm-pack build calcpad-wasm --target web --release
# Stage 2 — Build frontend with Vite
FROM node:22-slim AS web-builder
WORKDIR /app/calcpad-web
# Build-time env vars for Vite (inlined at build time)
ARG VITE_SUPABASE_URL
ARG VITE_SUPABASE_ANON_KEY
ARG VITE_COLLAB_WS_URL
ENV VITE_SUPABASE_URL=$VITE_SUPABASE_URL
ENV VITE_SUPABASE_ANON_KEY=$VITE_SUPABASE_ANON_KEY
ENV VITE_COLLAB_WS_URL=$VITE_COLLAB_WS_URL
# Install dependencies first (layer caching)
COPY calcpad-web/package.json calcpad-web/package-lock.json* ./
RUN npm install
# Copy web source
COPY calcpad-web/ ./
# Copy WASM output into public/wasm/ so Vite includes it in the build
COPY --from=wasm-builder /app/calcpad-wasm/pkg/calcpad_wasm.js public/wasm/calcpad_wasm.js
COPY --from=wasm-builder /app/calcpad-wasm/pkg/calcpad_wasm_bg.wasm public/wasm/calcpad_wasm_bg.wasm
# Build (skip tsc type-check — that belongs in CI, not Docker)
RUN npx vite build
# Stage 3 — Serve with nginx
FROM nginx:1.27-alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=web-builder /app/calcpad-web/dist /usr/share/nginx/html
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]