krops-multi-deploy/build-helper.nix
padreug a84ebea315 Add web-app with machine-specific builds
Implements per-machine customization for web-app deployment:
- Shared web-app source code deployed to all machines
- Machine-specific .env files and images
- Build helper script to assemble and build on target machines

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-30 11:15:31 +02:00

29 lines
No EOL
743 B
Nix

# Helper script for building the web-app on target machines
# This can be imported into the machine's configuration.nix
{ pkgs }:
pkgs.writeShellScriptBin "build-web-app" ''
set -e
# Web-app sources are deployed to /var/src by krops
WEB_APP_DIR="/var/src/web-app"
ENV_FILE="/var/src/web-app-env"
IMAGES_DIR="/var/src/web-app-images"
cd "$WEB_APP_DIR"
# Copy machine-specific .env file
echo "Copying machine-specific .env file..."
cp "$ENV_FILE" .env
# Copy machine-specific images to public folder
echo "Copying machine-specific images..."
cp -r "$IMAGES_DIR"/* public/
# Build the web-app
echo "Building web-app..."
${pkgs.nodejs}/bin/npm run build
echo "Build complete! Output in $WEB_APP_DIR/dist"
''