-
Notifications
You must be signed in to change notification settings - Fork 1
Fix: backend port mapping #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2f1d939
589aa6f
498fb85
80b81f9
f177ad7
61abdb0
9d5923d
7eb173f
611597b
2419d69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,25 +18,25 @@ docker compose up | |||||||||
| ## Frontend | ||||||||||
| Start the development server on `http://localhost:3000`: | ||||||||||
| ```bash | ||||||||||
| pnpm run --dir=frontend dev | ||||||||||
| pnpm --dir=frontend dev | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| Build the application for production: | ||||||||||
|
|
||||||||||
| ```bash | ||||||||||
| pnpm run --dir=frontend build | ||||||||||
| pnpm --dir=frontend generate | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| Locally preview production build: | ||||||||||
| ```bash | ||||||||||
| pnpm run --dir=frontend preview | ||||||||||
| ``` | ||||||||||
| pnpm --dir=frontend preview | ||||||||||
| ```{% endraw %}{% if has_backend %}{% raw %} | ||||||||||
|
|
||||||||||
| ## Backend | ||||||||||
| Start the GraphQL server: | ||||||||||
| Start the API server on port 4000: | ||||||||||
| ```bash | ||||||||||
| uv --directory=backend run uvicorn src.entrypoint:app --reload --host '::' --port 4000 | ||||||||||
|
||||||||||
| uv --directory=backend run uvicorn src.entrypoint:app --reload --host '::' --port 4000 | |
| Start the API server on port {% endraw %}{{ backend_deployed_port_number }}{% raw %}: | |
| ```bash | |
| uv --directory=backend run uvicorn src.entrypoint:app --reload --host '::' --port {% endraw %}{{ backend_deployed_port_number }}{% raw %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs should reflect the dynamic backend port; avoid hardcoding 4000
The project now parameterizes the backend port, and the container listens on that port. The README still instructs to run on 4000, which can mislead when {{ backend_deployed_port_number }} ≠ 4000.
Apply this diff to keep the docs consistent with the templates:
-Start the API server on port 4000:
+Start the API server on port {% endraw %}{{ backend_deployed_port_number }}{% raw %}:
```bash
-uv --directory=backend run uvicorn src.entrypoint:app --reload --host '::' --port 4000
+uv --directory=backend run uvicorn src.entrypoint:app --reload --host 0.0.0.0 --port {% endraw %}{{ backend_deployed_port_number }}{% raw %}
Notes:
- Switched `--host` to `0.0.0.0` to mirror the Dockerfile default and avoid potential IPv6-only binding surprises on some hosts. If you want dual‑stack, we can document `--host ::` as an alternative.
<details>
<summary>🤖 Prompt for AI Agents</summary>
In template/README.md.jinja around lines 36 to 39, the README hardcodes port
4000 and uses --host '::', which conflicts with the parameterized backend port
and Docker default; update the example command to use the template variable for
the port and switch the host to 0.0.0.0. Replace the hardcoded "--port 4000"
with "--port {{ backend_deployed_port_number }}" (respecting the surrounding
Jinja raw/endraw blocks as in the template) and change "--host '::'" to "--host
0.0.0.0" so the docs reflect the dynamic configuration and match container
networking.
</details>
<!-- fingerprinting:phantom:poseidon:chinchilla -->
<!-- This is an auto-generated comment by CodeRabbit -->
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -18,7 +18,7 @@ RUN pnpm install --frozen-lockfile | |||||
| COPY . . | ||||||
|
|
||||||
| # build the Nuxt app (generates .output folder in Nuxt 3) | ||||||
| RUN pnpm list && pnpm run generate | ||||||
| RUN pnpm list && pnpm generate | ||||||
|
||||||
| RUN pnpm list && pnpm generate | |
| RUN pnpm list && pnpm run generate |
Copilot
AI
Aug 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The envsubst command with unvalidated environment variables could be vulnerable to injection attacks. Consider validating the environment variables or using a more secure templating approach.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| {% raw %}server { | ||
| listen {% endraw %}{{ frontend_deployed_port_number }}{% raw %}; | ||
| listen ${FRONTEND_PORT}; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify end-to-end: FRONTEND_PORT is provided and port mappings are consistent. Ensure docker-compose/K8s manifests provide FRONTEND_PORT and map host:container to the same value to avoid “listen ;” or mismatched publishing. Run: 🏁 Script executed: #!/bin/bash
# 1) Confirm FRONTEND_PORT is set where services are defined
rg -nP -C2 '\bFRONTEND_PORT\b' -g '!**/node_modules/**'
# 2) Sanity-check for any lingering 3000 port mappings that could be outdated
rg -nP -C2 '(:|=)\s*3000\b' -g '!**/node_modules/**'
# 3) If you use docker-compose templates, confirm ports mapping mirrors FRONTEND_PORT
rg -nP -C2 'ports:|FRONTEND_PORT' -g '*docker-compose*.jinja'Length of output: 8809 Align container port mapping with FRONTEND_PORT in production deployment Your local compose template correctly maps • In ports:
- "{{ frontend_deployed_port_number }}:3000"
+ "{{ frontend_deployed_port_number }}:{{ frontend_deployed_port_number }}"(Change the right-hand side of the mapping from • (Optional) To improve clarity, you can also add an explicit environment section: environment:
- FRONTEND_PORT={{ frontend_deployed_port_number }}so it’s clear at runtime which port Nginx will listen on. With this change, Nginx’s 🤖 Prompt for AI Agents |
||
| server_name _; | ||
|
|
||
| root /usr/share/nginx/html; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,7 +1,7 @@ | ||||||
| {% raw %}FROM python:{% endraw %}{{ python_version }}{% raw %}-slim-{% endraw %}{{ debian_release_name }}{% raw %} | ||||||
|
|
||||||
| # docker build -t my-graphql-backend . | ||||||
| # docker run -p {% endraw %}{{ backend_deployed_port_number }}{% raw %}:4000 my-graphql-backend | ||||||
| # docker run -p {% endraw %}{{ backend_deployed_port_number }}{% raw %}:{% endraw %}{{ backend_deployed_port_number }}{% raw %} my-graphql-backend | ||||||
|
|
||||||
| # tell uv to treat /usr/local as the project env | ||||||
| ENV UV_PROJECT_ENVIRONMENT=/usr/local | ||||||
|
|
@@ -21,7 +21,11 @@ COPY . . | |||||
|
|
||||||
| RUN uv pip list --format=columns --verbose | ||||||
|
|
||||||
| EXPOSE 4000 | ||||||
| # set sensible defaults (overridable at `docker run`) | ||||||
| ENV API_PORT={% endraw %}{{ backend_deployed_port_number }}{% raw %} | ||||||
|
|
||||||
| # When deployed with network-mode=host on Rancher Desktop on Windows (for WSL-compatibility), there's no actual port mapping, so we need to have it running on the deployed port within the container itself | ||||||
| EXPOSE {% endraw %}{{ backend_deployed_port_number }}{% raw %} | ||||||
|
Comment on lines
+27
to
+28
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainEXPOSE is documentation-only; ensure compose/k8s also wire containerPort to the same value EXPOSE helps tooling but doesn’t publish ports. Double-check docker-compose.yaml.jinja (and any Helm/k8s templates, if present) map {{ backend_deployed_port_number }} on both host and container, and pass API_PORT in environment. If already done in this PR, you’re good. 🏁 Script executed: #!/bin/bash
# Verify compose and templates map the same container port and set API_PORT
rg -n -C2 -P '(ports:|EXPOSE|API_PORT|backend_deployed_port_number)' --type=yaml --type=dockerfile --type=jinjaLength of output: 148 🏁 Script executed: #!/bin/bash
set -euo pipefail
# List all Jinja templates
echo "Listing all Jinja templates:"
fd --type f -e jinja || true
# Identify compose-related templates
echo -e "\nCompose-related templates:"
fd --type f -e jinja | grep -i 'compose' || true
# Verify backend_deployed_port_number usage in compose templates
echo -e "\nVerify backend_deployed_port_number in compose templates:"
fd --type f -e jinja | grep -i 'compose' | xargs -r rg -n -C2 'backend_deployed_port_number' || true
# Verify ports: mapping in compose templates
echo -e "\nVerify ports: in compose templates:"
fd --type f -e jinja | grep -i 'compose' | xargs -r rg -n -C2 'ports:' || true
# Verify API_PORT environment variable in compose templates
echo -e "\nVerify API_PORT in compose templates:"
fd --type f -e jinja | grep -i 'compose' | xargs -r rg -n -C2 'API_PORT' || true
# Identify K8s/Helm-related templates
echo -e "\nK8s/Helm-related templates:"
fd --type f -e jinja | grep -Ei 'helm|k8s|deployment|service' || true
# Verify containerPort mapping in K8s templates
echo -e "\nVerify containerPort in K8s templates:"
fd --type f -e jinja | grep -Ei 'helm|k8s|deployment|service' | xargs -r rg -n -C2 'containerPort' || true
# Verify backend_deployed_port_number in K8s templates
echo -e "\nVerify backend_deployed_port_number in K8s templates:"
fd --type f -e jinja | grep -Ei 'helm|k8s|deployment|service' | xargs -r rg -n -C2 'backend_deployed_port_number' || trueLength of output: 5659 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Find all docker-compose Jinja templates
compose_files=$(fd --type f -e jinja | grep -i 'docker-compose.yaml')
# Print the first 200 lines of each to inspect ports and environment settings
for f in $compose_files; do
echo "===== Inspecting $f ====="
sed -n '1,200p' "$f" || true
echo ""
doneLength of output: 3221 EXPOSE is documentation-only; compose template needs to wire up port and API_PORT The Dockerfile’s • In ports:
- "{{ backend_deployed_port_number }}:4000"
environment:
API_PORT: "{{ backend_deployed_port_number }}"• If you introduce Kubernetes/Helm manifests for the backend, ensure they include: containerPort: {{ backend_deployed_port_number }}
env:
- name: API_PORT
value: "{{ backend_deployed_port_number }}"🤖 Prompt for AI Agents |
||||||
|
|
||||||
| # By default, run the entrypoint to serve the GraphQL app | ||||||
| CMD ["python", "src/entrypoint.py", "--host", "0.0.0.0", "--port", "4000"]{% endraw %} | ||||||
| CMD ["sh", "-c", "python src/entrypoint.py --host 0.0.0.0 --port $API_PORT"]{% endraw %} | ||||||
|
||||||
| CMD ["sh", "-c", "python src/entrypoint.py --host 0.0.0.0 --port $API_PORT"]{% endraw %} | |
| CMD ["python", "src/entrypoint.py", "--host", "0.0.0.0", "--port", "${API_PORT}"]{% endraw %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation still references port 4000 specifically, but the backend now runs on the configured deployed port. Consider updating this to reference the variable port or remove the specific port number.