Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions template/.github/workflows/ci.yaml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
node-version: {% endraw %}{{ node_version }}{% raw %}

- name: Unit test
run: pnpm run --dir=frontend test-unit
run: pnpm --dir=frontend test-unit

- name: Upload test coverage on failure
if: ${{ failure() }}
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
skip-installing-ssm-plugin-manager: true

- name: Build frontend
run: pnpm run --dir=frontend generate
run: pnpm --dir=frontend generate

- name: Upload build artifact
uses: actions/upload-artifact@{% endraw %}{{ gha_upload_artifact }}{% raw %}
Expand Down Expand Up @@ -184,7 +184,7 @@ jobs:
node-version: {% endraw %}{{ node_version }}{% raw %}

- name: Test
run: pnpm run --dir=frontend test-compiled
run: pnpm --dir=frontend test-compiled

e2e-test:
name: End-to-end Testing
Expand Down Expand Up @@ -232,7 +232,7 @@ jobs:
run: tar -xvf backend/dist/{% endraw %}{{ repo_name }}{% raw %}/app.tar -C .
{% endraw %}{% endif %}{% raw %}
- name: E2E test
run: pnpm run --dir=frontend test-e2e
run: pnpm --dir=frontend test-e2e

{% endraw %}{% if create_docker_image_tar_artifact %}{% raw %} package-images:
name: Package Images
Expand Down
12 changes: 6 additions & 6 deletions template/README.md.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Copilot AI Aug 21, 2025

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.

Suggested change
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 %}

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

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

The uvicorn command still uses hardcoded port 4000, which is inconsistent with the Docker configuration that now uses the deployed port variable. This should use the same port as configured in the Dockerfile.

Suggested change
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 %}

Copilot uses AI. Check for mistakes.
```
```{% endraw %}{% endif %}{% raw %}
Comment on lines +36 to +39
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

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


## Updating from the template
This repository uses a copier template. To pull in the latest updates from the template, use the command:
Expand Down
4 changes: 2 additions & 2 deletions template/frontend/nuxt.config.ts.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default defineNuxtConfig({
interval: 200, // ms pause between batches – lets the Garbage Collector catch up
},
devProxy: {
// this is just a proxy used for `pnpm run dev`
// this is just a proxy used for `pnpm dev`
"/api": {
target: "http://localhost:4000", // backend dev port
changeOrigin: true, // rewrite Host header
Expand All @@ -53,7 +53,7 @@ export default defineNuxtConfig({
usePolling: true,
},{% endraw %}{% if has_backend and not deploy_as_executable %}{% raw %}
proxy: {
// this is just a proxy used for `pnpm run dev`
// this is just a proxy used for `pnpm dev`
"/api": {
target: "http://localhost:4000", // backend dev port
changeOrigin: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

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

The command change from 'pnpm run generate' to 'pnpm generate' may not work as expected. In most npm/pnpm projects, 'generate' is a script defined in package.json that should be invoked with 'pnpm run generate' or 'pnpm generate' only if it's a built-in pnpm command. Verify that 'generate' works without the 'run' prefix.

Suggested change
RUN pnpm list && pnpm generate
RUN pnpm list && pnpm run generate

Copilot uses AI. Check for mistakes.

# ------------ Stage 2: Production ------------
FROM nginx:{% endraw %}{{ nginx_image_version }}{% raw %}-alpine{% endraw %}{{ alpine_image_version }}{% raw %} AS production
Expand All @@ -30,10 +30,11 @@ COPY --from=builder /app/.output/public /usr/share/nginx/html

# set sensible defaults (overridable at `docker run`)
ENV BACKEND_HOST=host.docker.internal \
BACKEND_PORT={% endraw %}{{ backend_deployed_port_number }}{% raw %}
BACKEND_PORT={% endraw %}{{ backend_deployed_port_number }}{% raw %} \
FRONTEND_PORT={% endraw %}{{ frontend_deployed_port_number }}{% raw %}

# Using port 80 caused problems running K8s on windows hosts, so using a higher port number
EXPOSE {% endraw %}{{ frontend_deployed_port_number }}{% raw %}

# Nginx in foreground
CMD ["sh", "-c", "envsubst '$BACKEND_HOST $BACKEND_PORT' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"]{% endraw %}
CMD ["sh", "-c", "envsubst '$BACKEND_HOST $BACKEND_PORT $FRONTEND_PORT' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"]{% endraw %}
Copy link

Copilot AI Aug 21, 2025

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.

Copilot uses AI. Check for mistakes.
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};
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify 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 FRONTEND_PORT end-to-end (host⇄container) and sets FRONTEND_PORT for Nginx, but the production deployment template hard-codes the container port to 3000 while still exposing a variable host port. This will break routing whenever frontend_deployed_port_number ≠ 3000.

• In template/deployment/docker-compose.yaml.jinja around lines 15–17:

ports:
- "{{ frontend_deployed_port_number }}:3000"
+ "{{ frontend_deployed_port_number }}:{{ frontend_deployed_port_number }}"

(Change the right-hand side of the mapping from 3000 to the same variable.)

• (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 listen ${FRONTEND_PORT} will always match the container port you’ve exposed.

🤖 Prompt for AI Agents
In template/frontend/{% if not deploy_as_executable %}default.conf.template{%
endif %}.jinja around line 2, Nginx is configured to listen on ${FRONTEND_PORT}
but the production docker-compose template hard-codes the container side of the
port mapping to 3000; update template/deployment/docker-compose.yaml.jinja
(around lines 15–17) to map host port to the same variable (replace the
right-hand-side 3000 with {{ frontend_deployed_port_number }}) so container port
matches FRONTEND_PORT, and optionally add an environment section to the service:
include FRONTEND_PORT={{ frontend_deployed_port_number }} to make the runtime
port explicit.

server_name _;

root /usr/share/nginx/html;
Expand Down
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
Expand All @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

EXPOSE 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=jinja

Length 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' || true

Length 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 ""
done

Length of output: 3221


EXPOSE is documentation-only; compose template needs to wire up port and API_PORT

The Dockerfile’s EXPOSE {{ backend_deployed_port_number }} only informs tooling—it doesn’t actually publish the port at runtime or inject an environment variable. I verified in ​template/deployment/docker-compose.yaml.jinja that the backend service maps the port correctly (host {{ backend_deployed_port_number }} → container 4000), but there is no environment: block on the backend service to pass API_PORT. There are also no Kubernetes/Helm templates deploying the backend, so if you add any in the future you’ll need to wire containerPort and API_PORT there too.

• In template/deployment/docker-compose.yaml.jinja, under services.backend, add:

    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
In template/{% if has_backend %}backend{% endif %}/{% if not
deploy_as_executable %}Dockerfile{% endif %}.jinja around lines 27-28, the
Dockerfile only uses EXPOSE which is documentation-only; update the compose
deployment to actually publish the port and set API_PORT: in
template/deployment/docker-compose.yaml.jinja under services.backend add a ports
mapping from host {{ backend_deployed_port_number }} to container 4000 and add
an environment entry API_PORT with value {{ backend_deployed_port_number }};
also, if you later add Kubernetes/Helm manifests, ensure the backend container
spec includes containerPort: {{ backend_deployed_port_number }} and an env
variable name=API_PORT value={{ backend_deployed_port_number }}.


# 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 %}
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

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

Using shell form with variable expansion can be vulnerable to injection attacks. Consider using exec form with environment variable expansion in the Python script instead, or validate the API_PORT environment variable.

Suggested change
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 %}

Copilot uses AI. Check for mistakes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
dockerfile: Dockerfile
container_name: {% endraw %}{{ repo_name }}{% raw %}-backend
ports:
- "{% endraw %}{{ backend_deployed_port_number }}{% raw %}:4000"
- "{% endraw %}{{ backend_deployed_port_number }}{% raw %}:{% endraw %}{{ backend_deployed_port_number }}{% raw %}"
environment:
API_PORT: {% endraw %}{{ backend_deployed_port_number }}{% raw %}
restart: unless-stopped
network_mode: host
{% endraw %}{% endif %}{% raw %}
Expand All @@ -21,6 +23,7 @@
environment:
BACKEND_HOST: host.docker.internal
BACKEND_PORT: {% endraw %}{{ backend_deployed_port_number }}{% raw %}
FRONTEND_PORT: {% endraw %}{{ frontend_deployed_port_number }}{% raw %}
restart: unless-stopped
extra_hosts:
- "host.docker.internal:host-gateway"{% endraw %}