enhance: dev env setup - #1106
Conversation
* Add AGENTS.md and postgres secrets for dev setup Co-authored-by: Wesley B <wesleyboar@users.noreply.github.com> * Update AGENTS.md: recommend Makefile commands, document make setup caveat Co-authored-by: Wesley B <wesleyboar@users.noreply.github.com> * Fix setup-cms.sh for non-interactive use and add npm build step - Remove -it flags from docker exec calls that don't need a TTY (migrate, collectstatic) - Detect TTY for createsuperuser: interactive prompt if TTY, --no-input with default creds otherwise - Add npm ci && npm run build before collectstatic (dev compose volume mount overwrites image's pre-built CSS) - Simplify AGENTS.md now that make setup works non-interactively Co-authored-by: Wesley B <wesleyboar@users.noreply.github.com> * Remove unnecessary conf/postgres secret files PostgreSQL container uses environment variables, not these files. The volume mounts are harmless if the files are absent. Co-authored-by: Wesley B <wesleyboar@users.noreply.github.com> * Pass superuser password via docker exec -e, not command string Avoids exposing the password in the process table (ps aux). Co-authored-by: Wesley B <wesleyboar@users.noreply.github.com> * Show default credentials in setup banner for non-interactive path Co-authored-by: Wesley B <wesleyboar@users.noreply.github.com> * Rename SUPERUSER_NOTE to SUPERUSER_CREDS_NOTE Co-authored-by: Wesley B <wesleyboar@users.noreply.github.com> * Address review feedback: env var for password, CSS build via Docker - Superuser password reads DJANGO_SUPERUSER_PASSWORD env var (falls back to default) - Remove hardcoded password from docs, document env var override instead - Run npm ci/build inside node:18 container instead of requiring host Node Co-authored-by: Wesley B <wesleyboar@users.noreply.github.com> * Document non-interactive superuser password option in README Co-authored-by: Wesley B <wesleyboar@users.noreply.github.com> * fix: prevent "fatal" error side effect Fixes — ```log $ make setup fatal: No names found, cannot describe anything. ``` — on a fork that has no Git tags. * chore: delete obsolete `version` property * Require explicit DJANGO_SUPERUSER_PASSWORD for non-interactive runs, pin Node image - Non-interactive path now fails with a clear message if DJANGO_SUPERUSER_PASSWORD is unset - Node image version extracted to NODE_IMAGE variable, pinned to match Dockerfile Co-authored-by: Wesley B <wesleyboar@users.noreply.github.com> * chore: update dev docker compose cms image The core-portal-cms was last updated 4 years ago. Mimics ceef6cb. Un-reverts 935e950. * fix: prevent "fatal" error side effect Testing: `node -e "require('./bin/git-describe')()"` returns commit hash or description. UI: ```log Core-CMS---personal-fork % node -e "require('./bin/git-describe')()" Output from `git describe`: 24e10c1 Core-CMS---personal-fork % cd ../Core-CMS---extra-clone Core-CMS---extra-clone % node -e "require('./bin/git-describe')()" Output from `git describe`: v4.38.2-14-gc0bc273b ``` * docs: docuemnt missing CSS build step * Prioritize DJANGO_SUPERUSER_PASSWORD over TTY detection Lets TTY users skip interactive prompts by setting the env var. Co-authored-by: Wesley B <wesleyboar@users.noreply.github.com> * Fix misleading CSS build comment The host mount hides the image's CSS; this step rebuilds it, not overwrites it. Co-authored-by: Wesley B <wesleyboar@users.noreply.github.com> * Clarify CSS rebuild process in setup script Updated comments for clarity on CSS rebuilding process. * Consolidate PROJECT_ROOT/SRC_ROOT, fix docker run working dir - Remove duplicate SRC_ROOT (identical to PROJECT_ROOT) - Use $PROJECT_ROOT instead of $(pwd) for docker run volume mount - Remove redundant cd commands (script stays in PROJECT_ROOT throughout) Co-authored-by: Wesley B <wesleyboar@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Wesley B <wesleyboar@users.noreply.github.com>
Review Summary by QodoEnhance dev environment setup with non-interactive support and documentation
WalkthroughsDescription• Improve dev environment setup with non-interactive support and better documentation • Add AGENTS.md guide for Cursor Cloud and Docker-based development workflow • Fix setup script to handle TTY detection and secure password handling • Build CSS via Docker container to avoid volume mount conflicts • Simplify path variables and remove unnecessary docker exec flags Diagramflowchart LR
A["Setup Script"] -->|"TTY Detection"| B["Interactive or Non-Interactive Path"]
B -->|"With DJANGO_SUPERUSER_PASSWORD"| C["Create Superuser Non-Interactively"]
B -->|"With TTY"| D["Prompt User for Credentials"]
A -->|"Build CSS"| E["Docker Node Container"]
E -->|"npm ci && npm run build"| F["CSS Ready"]
A -->|"Django Setup"| G["Migrations & Collectstatic"]
G -->|"Complete"| H["CMS Ready at localhost:8000"]
File Changes1. bin/setup-cms.sh
|
Code Review by Qodo
1. Compose v1 may break
|
| services: | ||
| cms: | ||
| extends: |
There was a problem hiding this comment.
1. Compose v1 may break 🐞 Bug ⛯ Reliability
Compose files now omit the top-level version: key, but the Makefile still prefers the legacy docker-compose binary when it exists. In environments where docker-compose (v1) is installed, this can cause compose parsing/feature support issues and break make build/start/stop even though docs recommend using Compose v2.
Agent Prompt
### Issue description
Compose files removed the top-level `version:` key, but `make` still prefers legacy `docker-compose` when present. This can break the dev workflow on machines that still have docker-compose installed.
### Issue Context
The repo documentation already recommends Docker Compose v2 and notes docker-compose v1 is deprecated, but the Makefile continues to auto-select docker-compose.
### Fix Focus Areas
- Makefile[5-17]
- docker-compose.yml[1-6]
- docker-compose.dev.yml[1-5]
- docs/upgrade-project.md[57-62]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| # Build CSS via Docker | ||
| # FAQ: To rebuild CSS via ad-hoc Node container, because | ||
| # `docker-compose.dev.yml` mounts `.:/code` which erases pre-built CSS | ||
| echo -e "${INF}Building CSS...${RST}" | ||
| docker run --rm -v "$PROJECT_ROOT:/code" -w /code "$NODE_IMAGE" sh -c "npm ci && npm run build" |
There was a problem hiding this comment.
2. Css build needs git in node 🐞 Bug ⛯ Reliability
bin/setup-cms.sh now runs npm run build inside a plain node:18 container without passing a build id. The CSS build script falls back to running git describe/git rev-parse; if git isn’t available in that container or .git isn’t present in the bind mount, setup will fail during CSS build.
Agent Prompt
### Issue description
CSS build inside `node:18` relies on a git-based fallback to compute BUILD_ID because setup does not pass `--build-id`. This can fail when git (or `.git`) is unavailable in the container.
### Issue Context
`bin/build-css.js` calls `gitDescribe()` when `--build-id` is missing/empty, and `gitDescribe()` runs git commands.
### Fix Focus Areas
- bin/setup-cms.sh[191-196]
- bin/build-css.js[9-12]
- bin/git-describe.js[9-13]
- Makefile[12-23]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
## Overview Improve superuser creation and Docker commands. ## Related - mimics some of TACC/Core-CMS#1106 ## Changes - Removed unnecessary `-it` flags from Docker exec commands for better compatibility. - Enhanced superuser creation logic to handle password input and TTY checks. - Updated instructions for logging in with superuser credentials.
## Overview Restore `SRC_ROOT` to `setup-cms.sh`. TACC/Core-CMS-Custom changes this variable. Having it here introduces parity. ## Related - reverts non-functional change from #1106
## Overview Resolve issues encountered while setting up dev env ## Related - replaces wesleyboar#3 - builds upon #1106 ## Changes - **`docker-compose.dev.yml`**: updated Elasticsearch image from `7.17.0` to `7.17.9` - **`AGENTS.md`**: noted discovered gotchas ## Testing 1. `DJANGO_SUPERUSER_PASSWORD=admin123 make setup` 2. Verify all Docker containers are running. 3. Confirm CMS running at `localhost:8000`. 4. Verify Elasticsearch cluster health is green at `localhost:9201/_cluster/health`. 5. (Optional) `docker exec core_cms flake8 taccsite_cms/ --max-line-length=120` (332 pre-existing warnings expected). 6. (Optional) `docker exec core_cms python manage.py test taccsite_cms.contrib.taccsite_sample --no-input` (6 tests passed). 7. (Manual) Log in as admin, create a "Hello World" CMS page, and edit page. ## UI Verified. Not posted. --- <p><a href="https://cursor.com/agents/bc-1b9f9d75-bdfe-405a-a1e5-74d58319a19e"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-1b9f9d75-bdfe-405a-a1e5-74d58319a19e"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </p> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Wesley B <wesleyboar@users.noreply.github.com>
Overview
Improve dev environment setup for Agents and Humans.
Related / Changes / Testing