587ff2cf47
Publish snapshot / snapshot (push) Failing after 1m58s
Publishing infrastructure - Three Gitea workflows: ci.yml (PRs, non-main pushes), publish-snapshot.yml (main -> Gitea under dist-tag @main) and release.yml (tags -> Gitea + npmjs) - Tag-driven releases as <package-dir>-v<version>; the manifest stays the source of truth and release.yml refuses to run if tag and manifest disagree - Every publish is idempotent: each step checks the registry first, so a run that fails on the second registry can simply be re-run - Hard coverage gate (85% branches) shared by CI, the pre-push hook and local runs, since the thresholds live in vitest.config.ts rather than a CI flag - README.PUBLISH.md documents the whole mechanism Toolchain - TypeScript 7 native compiler; drop tsgo and ts-node, use tsx for dev runs - Biome 1.9 -> 2.x, Vitest 1 -> 4, zod 3 -> 4, inquirer 8 -> 14, pnpm 11.17.0 - Replace inquirer-checkbox-plus-prompt, which is peer-capped at inquirer <9, with enquirer's AutoComplete; the CubeSelection contract is unchanged - Stand in for zod 4's removed z.AnyZodObject with a local AnyObjectSchema Repo hygiene - Stop tracking dist/; ignore coverage/, *.tsbuildinfo, .npmrc* and release.json - Drop package-lock.json in favour of pnpm-lock.yaml Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
TypeStack Install Cube
Deploys a Node.js/TypeScript application from a Git repository as a systemd service with Docker Compose and PM2 support.
Features
- Clones Git repository
- Installs dependencies with Yarn
- Builds the application
- Starts Docker Compose services
- Creates a systemd service for automatic startup
- Configures PM2 for process management
- Automatic restart on failure
Requirements
- Git (for cloning repository)
- Yarn (for dependency management)
- Docker and Docker Compose
- PM2 (for process management)
- Node.js/NVM installed
- SSH key access to the repository (if using private repos)
Configuration Parameters
Required
- USER: System user to run the application (default:
teclabmin) - REPO: Git repository URL (default:
git@github.com:bennidi/teclab-flintstone.git) - APP: Application name/directory name (default:
flintstone)
Optional
- ENV: Application environment (default:
production) - AUTOSTART: Enable and start service immediately (default:
True) - NODE_PATH: Path to Node.js binaries (default:
/home/teclabmin/.nvm/versions/node/v21.7.3/bin)
Example Usage
Basic Configuration
{
"USER": "myuser",
"REPO": "git@github.com:myorg/myapp.git",
"APP": "myapp"
}
Advanced Configuration
{
"USER": "appuser",
"REPO": "git@github.com:myorg/myapp.git",
"APP": "myapp",
"ENV": "staging",
"AUTOSTART": false,
"NODE_PATH": "/home/appuser/.nvm/versions/node/v20.0.0/bin"
}
What This Cube Does
- Clone Repository: Clones the specified Git repository to
/home/<USER>/<APP> - Install Dependencies: Runs
yarn installto install all dependencies - Build Application: Runs
yarn buildto compile the application - Start Docker Services: Runs
docker compose up -dto start containerized services - Create Startup Script: Creates
/home/<USER>/<APP>.service.shthat:- Starts Docker Compose services
- Starts PM2 with ecosystem.config.js
- Create Systemd Service: Creates
/etc/systemd/system/<APP>.servicethat:- Runs after Docker service
- Uses the specified user
- Configures proper environment (HOME, PATH)
- Auto-restarts on failure
- Enable & Start Service: Enables and starts the service (if AUTOSTART=True)
Service Management
Check service status
sudo systemctl status <APP>
Start the service
sudo systemctl start <APP>
Stop the service
sudo systemctl stop <APP>
Restart the service
sudo systemctl restart <APP>
View service logs
sudo journalctl -u <APP> -f
Disable autostart
sudo systemctl disable <APP>
File Structure
After deployment:
/home/<USER>/
├── <APP>/ # Application directory
│ ├── ecosystem.config.js # PM2 configuration
│ ├── docker-compose.yml # Docker services
│ └── ... # Application files
├── <APP>.service.sh # Startup script
/etc/systemd/system/
└── <APP>.service # Systemd service file
Troubleshooting
Service fails to start
-
Check service logs:
sudo journalctl -u <APP> -n 50 -
Verify Docker is running:
sudo systemctl status docker -
Check if Node.js path is correct:
which node which pm2
Repository clone fails
- Ensure SSH keys are properly configured for the user
- Test SSH access:
ssh -T git@github.com - Check repository URL is correct
Docker Compose fails
- Verify Docker is installed and running
- Check docker-compose.yml exists in the application directory
- Ensure user has Docker permissions:
sudo usermod -aG docker <USER>
PM2 not starting
- Verify PM2 is installed:
pm2 --version - Check ecosystem.config.js exists
- Verify NODE_PATH includes PM2 binary location
Notes
- The service type is set to
forkingto support PM2's daemon mode - Service will auto-restart on failure with a 5-second delay
- Maximum 5 restart attempts in the burst period
- The service waits for Docker to be ready before starting
- Environment variables can be configured in the ecosystem.config.js file