Skip to content

Add Cloud Agent development environment (.cursor/environment.json) - #3

Open
shappir wants to merge 2 commits into
mainfrom
cursor/setup-cloud-agent-environment-82f7
Open

shappir wants to merge 2 commits into
mainfrom
cursor/setup-cloud-agent-environment-82f7

Conversation

@shappir

@shappir shappir commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Summary

Sets up a reproducible Cursor Cloud Agent development environment for nodejs-goof. The app is an Express todo app that depends on MongoDB (todos + auth) and MySQL/TypeORM (users table), and listens on port 3001.

MongoDB's official download/apt domains are blocked by the Cloud Agent egress policy, but docker.io is allowed. This setup therefore runs the databases via Docker using the same mongo:3 / mysql:5 images the repo's own docker-compose.yml uses (these old images are required for compatibility with the app's 2015-era mongoose@4 driver). Docker's default overlayfs snapshotter fails inside the nested Cloud Agent VM, so the daemon is pinned to the fuse-overlayfs storage driver.

Files

  • .cursor/environment.json — repo-managed config: install, start, a goof terminal running npm start, and exposes port 3001.
  • .cursor/install.sh — idempotent: installs docker.io + fuse-overlayfs, writes the Docker daemon config, runs npm install, and best-effort pre-pulls the DB images so a fresh boot is fast.
  • .cursor/start.sh — idempotent per-boot: starts the Docker daemon, launches goof-mongo (mongo:3) and goof-mysql (mysql:5), and waits for both to be ready — MySQL is gated on real query readiness (mysqladmin ping), not just an open port.

Validation

Validated locally from a clean slate and on two fresh Cloud Agents booted from prebuilt environment builds:

Check Result
Homepage GET / HTTP 200
Create todo (persists to MongoDB) HTTP 302, item rendered back in list
GET /users (MySQL/TypeORM seeded data) [{"id":1,"name":"Liran",...}]
Admin login POST /login/admin HTTP 302 → HTTP 200
install.sh / start.sh idempotence Passed (safe re-runs)
Draft build (install runs in build env) SUCCEEDED
Fresh Cloud Agent (Node 22, Docker+fuse-overlayfs, cached images, DBs up, app end-to-end) Passed

Fixed: first-boot MySQL race

The initial fresh-agent verification caught a real race — mysql:5 opens its TCP port while still initializing its data directory, so a bare port check returned prematurely, the app connected too early, failed to seed the users table, and crashed on the first /users / /login request. start.sh now blocks on mysqladmin ping until MySQL can actually serve queries. A second fresh-agent verification (booted from a rebuilt image) confirmed the happy path start.shnpm start now works on the first try with no crash and clean seeding.

Handoff

This is a repo-managed environment (.cursor/environment.json is the highest-precedence config source). Merging this PR makes the tested setup active for future Cloud Agents automatically — no dashboard Save is required.

Open in Web Open in Cursor 

Adds .cursor/environment.json plus idempotent install.sh and start.sh that:
- install Docker + fuse-overlayfs (overlayfs snapshotter fails in nested VM)
- install npm dependencies
- run mongo:3 and mysql:5 containers the app depends on
- run the app via a 'goof' terminal, exposing port 3001

Co-authored-by: Dan Shappir <dan.shappir@snyk.io>
@snyk-io

snyk-io Bot commented Sep 2, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

mysql:5 opens its TCP port while still initializing its data directory on
first boot, so the previous bare port check returned prematurely. The app then
connected too early, failed to seed the users table, and crashed on the first
/users or /login request. Wait on 'mysqladmin ping' until the server can
actually answer queries before returning from start.sh.

Co-authored-by: Dan Shappir <dan.shappir@snyk.io>
@shappir
shappir marked this pull request as ready for review September 2, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants