Really huge mass update; Getting everything up-to-spec and implementing a wide range of features
This commit is contained in:
@@ -49,6 +49,8 @@ Per-repo settings, one per user per repo. A repo can only be configured by one u
|
||||
- inactivityHours (float, default 12, range 0.5–72)
|
||||
- port (int, default 3000 — the port the app listens on inside the EC2 instance)
|
||||
- envVars (JSON key-value)
|
||||
- preinstallTools (string[] — selected runtime/tooling bootstrap options: `docker`, `node`, `python`, `go`, `lua`, `build-essential`)
|
||||
- nodeVersion (string, nullable — used when `node` is selected; default `lts/*`; `.nvmrc` in the repo wins during deploy)
|
||||
- useDockerCompose (bool)
|
||||
- composeFilePath (string, nullable — path within repo, default `docker-compose.yml`)
|
||||
- aptPackages (string[])
|
||||
@@ -90,7 +92,7 @@ Tracks which PRs have already received a "no previews configured" comment to avo
|
||||
### AdminSettings
|
||||
Single row global config (seeded on first run).
|
||||
- id
|
||||
- defaultInstanceType (string, default `t2.medium`)
|
||||
- defaultInstanceType (string, default `t3.medium`)
|
||||
- maxConcurrentInstancesPerUser (int, default 5)
|
||||
- logSizeLimitBytes (int, default 1048576 — 1MB)
|
||||
- previewRetentionDays (int, default 30 — STOPPED/FAILED records older than this are purged)
|
||||
@@ -185,18 +187,9 @@ pp:previewId = <Preview.id>
|
||||
```bash
|
||||
#!/bin/bash
|
||||
apt-get update -y
|
||||
apt-get install -y curl git unzip build-essential
|
||||
# Docker
|
||||
curl -fsSL https://get.docker.com | sh
|
||||
systemctl enable docker
|
||||
# Docker Compose v2 (plugin)
|
||||
apt-get install -y docker-compose-plugin
|
||||
# NVM + Node LTS
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
|
||||
export NVM_DIR="/root/.nvm" && source "$NVM_DIR/nvm.sh"
|
||||
nvm install --lts
|
||||
nvm alias default lts/*
|
||||
apt-get install -y ca-certificates curl git unzip
|
||||
```
|
||||
- Repo-selected preinstall tools are installed over SSH after clone: Docker + Compose, Node via nvm, Python, Go, Lua, build tools, and custom apt packages.
|
||||
- All instance tags as above.
|
||||
4. Poll `DescribeInstances` until status = `running` and the instance has a public IP.
|
||||
5. Poll TCP port 22 until it accepts connections (max 5 minutes, then fail).
|
||||
@@ -219,33 +212,32 @@ Set Preview status to `PROVISIONING`.
|
||||
1. Check `AdminSettings.maxConcurrentInstancesPerUser` — count PROVISIONING + BUILDING + RUNNING previews for this user. If at limit: post a Gitea comment on the PR explaining the limit is reached, mark job FAILED, stop.
|
||||
2. **Provision EC2** — as described above.
|
||||
3. SSH in. All subsequent commands run over SSH.
|
||||
4. **Install apt packages** (if any): `sudo apt-get install -y <aptPackages>`. Only runs on first provision.
|
||||
5. **Clone repo:**
|
||||
4. **Clone repo:**
|
||||
- Normal PR: `git clone https://<giteaUsername>:<PAT>@<giteaInstanceUrl>/<owner>/<repo>.git /opt/app`
|
||||
- Fork PR: clone from the fork's URL (`payload.pull_request.head.repo.clone_url`, injecting PAT auth).
|
||||
- `cd /opt/app && git fetch origin pull/<prNumber>/head:pp-pr && git checkout pp-pr`
|
||||
6. **Detect Node version:** Check for `/opt/app/.nvmrc`. If present: `nvm install && nvm use`. Otherwise: `nvm use default`.
|
||||
7. **Write `.env`:** Write `/opt/app/.env` from `RepoConfig.envVars`.
|
||||
8. **Setup commands** (if any): run each in order. Only runs on first provision.
|
||||
9. Set Preview status to `BUILDING`.
|
||||
10. **Build commands:** run each in order.
|
||||
11. **Post-build commands** (if any): run each in order.
|
||||
12. **Start:**
|
||||
- Docker Compose: `cd /opt/app && docker compose -f <composeFilePath> up -d --build --force-recreate`
|
||||
5. **Install selected preinstall tools and apt packages:** Docker + Compose, Node (using `.nvmrc` if present, otherwise `RepoConfig.nodeVersion`), Python, Go, Lua, build tools, and custom `RepoConfig.aptPackages`.
|
||||
6. **Write `.env`:** Write `/opt/app/.env` from `RepoConfig.envVars`.
|
||||
7. **Setup commands** (if any): run each in order. Only runs on first provision.
|
||||
8. Set Preview status to `BUILDING`.
|
||||
9. **Build commands:** run each in order.
|
||||
10. **Post-build commands** (if any): run each in order.
|
||||
11. **Start:**
|
||||
- Docker Compose: `cd /opt/app && sudo docker compose -f <composeFilePath> up -d --build --force-recreate`
|
||||
- Non-compose: run `runCommand` in background via `nohup ... > /opt/app/pp.log 2>&1 &`, capture PID → save to `Preview.pid`.
|
||||
13. Set Preview status to `RUNNING`. Store `instanceIp`, `port`, `commitSha`, `lastActivityAt = now`.
|
||||
14. **Comment on PR** — post initial status comment (see PR Commenting section). Store the comment ID in `Preview.giteaCommentId`.
|
||||
12. Set Preview status to `RUNNING`. Store `instanceIp`, `port`, `commitSha`, `lastActivityAt = now`.
|
||||
13. **Comment on PR** — post initial status comment (see PR Commenting section). Store the comment ID in `Preview.giteaCommentId`.
|
||||
|
||||
#### Subsequent push (synchronize / existing RUNNING or FAILED Preview)
|
||||
1. SSH into existing instance using `Preview.instanceIp` and decrypted `Preview.sshPrivateKey`.
|
||||
2. **Stop current process:**
|
||||
- Non-compose: `kill <Preview.pid>` (SIGTERM, wait 5s, SIGKILL if still running).
|
||||
- Docker Compose: `cd /opt/app && docker compose -f <composeFilePath> down`.
|
||||
- Docker Compose: `cd /opt/app && sudo docker compose -f <composeFilePath> down`.
|
||||
3. **Pull latest:**
|
||||
```bash
|
||||
cd /opt/app && git fetch origin pull/<prNumber>/head:pp-pr && git checkout pp-pr && git reset --hard FETCH_HEAD
|
||||
```
|
||||
4. **Re-detect Node version** (`.nvmrc` may have changed).
|
||||
4. **Re-run selected preinstall checks** (`.nvmrc` or runtime selections may have changed).
|
||||
5. **Overwrite `.env`** — re-write from current `RepoConfig.envVars`.
|
||||
6. Set Preview status to `BUILDING`. Append `\n--- Redeploy: <commitSha> ---\n` to `Preview.logs`.
|
||||
7. **Build commands** — re-run each.
|
||||
@@ -348,11 +340,12 @@ Note displayed in settings: _"PP will post PR comments as your Gitea account (@u
|
||||
- A repo already configured by another PP user shows a lock icon and "Claimed by another user" — the toggle is disabled.
|
||||
- Expanded per-repo config:
|
||||
- **Deny list** — tag input of Gitea usernames to skip.
|
||||
- **EC2 instance type** — searchable select (t2.micro, t2.medium, t3.medium, t3.large, m5.large, c5.large) + custom text input. Show estimated hourly cost next to each option.
|
||||
- **EC2 instance type** — searchable select (t3.medium, t3.large, t3a.medium, t3a.large, t4g.medium, t4g.large, m5.large, c5.large) + custom text input. Show estimated hourly cost next to each option.
|
||||
- **Inactivity kill timer** — slider 0.5h to 72h with labelled stops.
|
||||
- **App port** — number input (default 3000).
|
||||
- **Environment variables** — key/value editor, values masked. Add/remove rows.
|
||||
- **Docker Compose toggle** — if on: show compose file path input (default `docker-compose.yml`), hide manual command fields.
|
||||
- **Preinstall options** — checkboxes for Docker + Compose, Node.js (with version), Python, Go, Lua, build tools, plus custom apt packages.
|
||||
- **Docker Compose toggle** — if on: require Docker, show compose file path input (default `docker-compose.yml`), hide manual command fields.
|
||||
- **Commands** (shown for both modes unless noted):
|
||||
- Apt packages — tag input (compose + non-compose)
|
||||
- Setup commands — ordered list, add/remove/reorder (compose + non-compose, run once on first provision)
|
||||
|
||||
Reference in New Issue
Block a user