puffin-app/Dockerfile
Matt 04bfef4391
All checks were successful
Build and Push Docker Images / docker (push) Successful in 46s
Fix frontend runtime environment configuration
CRITICAL FIX:
- Frontend now loads environment variables at runtime instead of build time
- This allows changing configuration without rebuilding the Docker image

CHANGES:
- Add env-config.js script loader to index.html
- Update env.sh to use correct path for serve (/app/dist)
- Update Dockerfile to run env.sh before starting serve
- Add VITE_STRIPE_PUBLISHABLE_KEY to docker-compose environment

HOW IT WORKS:
1. env.sh reads VITE_* variables from container environment
2. Generates /app/dist/env-config.js with window.env object
3. index.html loads env-config.js before React app
4. src/utils/config.ts reads from window.env at runtime

This fixes the "Missing required environment variable: WREN_API_TOKEN" error
because the frontend can now access environment variables passed to the container.

🔒 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 12:30:29 +01:00

34 lines
691 B
Docker

# Build Stage
FROM node:20-alpine AS build
WORKDIR /app
# Copy package files and install dependencies
COPY package*.json ./
RUN npm ci
# Copy the rest of the app and build it
COPY . .
RUN npm run build
# Production Stage - Simple HTTP server
FROM node:20-alpine
WORKDIR /app
# Install serve package globally for serving static files
RUN npm install -g serve
# Copy the built app from the build stage
COPY --from=build /app/dist ./dist
# Copy the env.sh script for runtime configuration
COPY env.sh /app/env.sh
RUN chmod +x /app/env.sh
# Expose port 3000
EXPOSE 3000
# Use env.sh to generate runtime config, then start serve
CMD ["/app/env.sh", "serve", "-s", "dist", "-l", "3000"]