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>
2.5 KiB
2.5 KiB
Web-App Deployment Guide
Overview
This setup allows each machine to build the web-app with its own specific configuration:
- Machine-specific
.envfiles - Machine-specific images in the
publicfolder
Structure
.
├── web-app/ # Shared web-app source code
│ ├── package.json
│ ├── index.html
│ └── public/ # Images will be copied here during build
├── machine-specific/
│ ├── machine1/
│ │ ├── env/.env # Machine1's environment file
│ │ └── images/ # Machine1's images
│ │ ├── logo.png
│ │ └── banner.jpg
│ └── machine2/
│ ├── env/.env # Machine2's environment file
│ └── images/ # Machine2's images
│ ├── logo.png
│ └── banner.jpg
└── build-helper.nix # Build script available on target machines
How It Works
1. Krops Deployment (krops.nix)
When you deploy with krops, it copies to each target machine:
web-app→/var/src/web-app(shared source code)machine-specific/{name}/env/.env→/var/src/web-app-env(machine-specific .env)machine-specific/{name}/images/→/var/src/web-app-images/(machine-specific images)
2. Building on Target Machine
After deployment, SSH into the target machine and run:
build-web-app
This script:
- Copies the machine-specific
.envfile to the web-app directory - Copies the machine-specific images to
web-app/public/ - Runs
npm run buildto build the web-app
The build output will be in /var/src/web-app/dist/
Usage
Deploy to a single machine:
nix-build ./krops.nix -A machine1 && ./result
Deploy to all machines:
nix-build ./krops.nix -A all && ./result
Build the web-app on target machine:
ssh root@machine1.example.com
build-web-app
Customization
Add a new machine:
- Create directories:
machine-specific/machine3/env/andmachine-specific/machine3/images/ - Add
.envfile and images for machine3 - Create
config/machine3/configuration.nix - Add machine3 target in
krops.nix
Update environment variables:
Edit the appropriate .env file in machine-specific/{machine-name}/env/.env
Update images:
Replace files in machine-specific/{machine-name}/images/
After making changes, redeploy with krops.