Skip to content

enhance: dev env setup - #1106

Merged
wesleyboar merged 1 commit into
TACC:mainfrom
wesleyboar:main
Feb 26, 2026
Merged

enhance: dev env setup#1106
wesleyboar merged 1 commit into
TACC:mainfrom
wesleyboar:main

Conversation

@wesleyboar

Copy link
Copy Markdown
Member

Overview

Improve dev environment setup for Agents and Humans.

Related / Changes / Testing

* 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>
@wesleyboar wesleyboar changed the title enhance: dev env setup (#1) enhance: dev env setup Feb 26, 2026
@wesleyboar
wesleyboar merged commit 3219d83 into TACC:main Feb 26, 2026
@qodo-code-review

Copy link
Copy Markdown

Review Summary by Qodo

Enhance dev environment setup with non-interactive support and documentation

✨ Enhancement

Grey Divider

Walkthroughs

Description
• 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
Diagram
flowchart 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"]
Loading

Grey Divider

File Changes

1. bin/setup-cms.sh ✨ Enhancement +31/-13

Enhance setup script for non-interactive execution

bin/setup-cms.sh


2. bin/git-describe.js ✨ Enhancement +3/-1

Fallback to short commit hash if no tags exist

bin/git-describe.js


3. AGENTS.md 📝 Documentation +48/-0

Add Cursor Cloud development environment guide

AGENTS.md


View more (6)
4. Makefile ✨ Enhancement +1/-1

Improve BUILD_ID fallback for tagless commits

Makefile


5. README.md 📝 Documentation +21/-4

Document CSS build and non-interactive setup options

README.md


6. docker-compose.dev.yml ⚙️ Configuration changes +1/-2

Update image name and remove version specification

docker-compose.dev.yml


7. docker-compose.example-cms.yml ⚙️ Configuration changes +0/-1

Remove version specification from compose file

docker-compose.example-cms.yml


8. docker-compose.example.yml ⚙️ Configuration changes +0/-1

Remove version specification from compose file

docker-compose.example.yml


9. docker-compose.yml ⚙️ Configuration changes +0/-1

Remove version specification from compose file

docker-compose.yml


Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented Feb 26, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (4) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Compose v1 may break 🐞 Bug ⛯ Reliability
Description
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.
Code

docker-compose.yml[R1-3]

services:
  cms:
    extends:
Evidence
The compose files no longer declare a compose file version, while the Makefile will still choose
docker-compose if present. The repo docs explicitly state docker-compose v1 is deprecated and
instruct upgrading to Compose v2, but the Makefile behavior undermines this by defaulting to v1 when
installed.

docker-compose.yml[1-5]
docker-compose.dev.yml[1-4]
Makefile[5-7]
docs/upgrade-project.md[57-62]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### 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


2. CSS build needs git in Node 🐞 Bug ⛯ Reliability
Description
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.
Code

bin/setup-cms.sh[R191-195]

+# 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"
Evidence
The setup script runs npm run build without any --build-id, and the CSS build tooling explicitly
falls back to invoking git commands to determine a build id. This introduces a runtime dependency on
a git executable and repository metadata within the Node container.

bin/setup-cms.sh[191-196]
bin/build-css.js[9-12]
bin/git-describe.js[9-13]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### 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



Remediation recommended

3. Root-owned node_modules 🐞 Bug ⛯ Reliability
Description
The new CSS build step runs npm ci in a root-run Node container with the repo bind-mounted, which
will write node_modules/ and build outputs onto the host as root. This often causes developer
permission issues (can’t clean/edit without sudo) and makes setup slower by reinstalling
dependencies every run.
Code

bin/setup-cms.sh[195]

+docker run --rm -v "$PROJECT_ROOT:/code" -w /code "$NODE_IMAGE" sh -c "npm ci && npm run build"
Evidence
The script bind-mounts the repo into the Node container and runs npm ci without setting a non-root
user or isolating node_modules into a named volume, so writes go directly to the host filesystem
under root ownership.

bin/setup-cms.sh[194-196]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`npm ci` is executed inside a root-run container against a bind-mounted repo, causing root-owned artifacts on the host and slow reruns.

### Issue Context
Developers commonly run setup from their host OS; root-owned `node_modules/` is a frequent source of friction.

### Fix Focus Areas
- bin/setup-cms.sh[191-196]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Superuser creation can fail 🐞 Bug ✓ Correctness
Description
In non-interactive mode (when DJANGO_SUPERUSER_PASSWORD is set), setup always tries to create
username admin but only checks whether *any* superuser exists. If an admin user already exists
(even as non-superuser), createsuperuser will error and the script will exit due to set -e.
Code

bin/setup-cms.sh[R173-176]

+    if [ -n "$DJANGO_SUPERUSER_PASSWORD" ]; then
+        echo -e "${INF}No superuser found. Creating superuser...${RST}"
+        docker exec -e DJANGO_SUPERUSER_PASSWORD="$DJANGO_SUPERUSER_PASSWORD" core_cms python manage.py createsuperuser --no-input --username admin --email admin@localhost
+        SUPERUSER_CREDS_NOTE="username ${IMP}admin${RST}${POS} and the password you provided"
Evidence
The guard condition checks only is_superuser=True existence, not whether the target username is
available. The code then unconditionally attempts to create --username admin in the
non-interactive path.

bin/setup-cms.sh[166-176]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
Non-interactive setup always creates `admin` when no superuser exists, but does not check if the `admin` username is already taken. This can cause setup to fail on reruns or partially-configured databases.

### Issue Context
The script uses `set -e`, so any createsuperuser failure aborts the entire setup.

### Fix Focus Areas
- bin/setup-cms.sh[166-189]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Comment thread docker-compose.yml
Comment on lines 1 to 3
services:
cms:
extends:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

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

Comment thread bin/setup-cms.sh
Comment on lines +191 to +195
# 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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

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

wesleyboar added a commit to TACC/Core-CMS-Template that referenced this pull request Feb 26, 2026
## 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.
wesleyboar added a commit that referenced this pull request Feb 26, 2026
## 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
wesleyboar added a commit that referenced this pull request Mar 6, 2026
## 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>&nbsp;<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>&nbsp;</p>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Wesley B <wesleyboar@users.noreply.github.com>
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.

1 participant