Skip to content

Conversation

@lukakoning
Copy link
Contributor

Makes Docker demo run fully in Docker + add automated test to verify Docker demo works

Copilot AI review requested due to automatic review settings December 15, 2025 10:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR eliminates the dependency on host-side bash scripts by enabling the Docker demo to run entirely within Docker containers using native Docker Compose commands. It also introduces automated CI testing via GitHub Actions to verify the demo pipeline works correctly.

Key changes:

  • Replaced custom run_demo.sh wrapper with direct Docker Compose commands
  • Added GitHub Actions workflow to automatically test the Docker demo in CI
  • Enhanced docker-compose.yml with profiles for different use cases (db-only, external database)

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 11 comments.

File Description
docker/demo/docker-compose.yml Refactored service names, added db-only profile, updated entrypoints to handle line endings and permissions at runtime, improved documentation
docker/demo/demo_entrypoint.sh Changed shebang to #!/usr/bin/env bash and modified error handling to support minimal environments
docker/demo/README.md Updated all examples to use direct Docker Compose commands instead of wrapper script
.github/workflows/docker-demo.yaml Added new CI workflow to build, run, and validate the Docker demo with comprehensive error handling

condition: service_healthy
working_dir: /app
entrypoint: ["/bin/bash", "/app/docker/demo/demo_entrypoint.sh"]
entrypoint: ["/bin/bash", "-lc", "sed -i 's/\r$//' /app/docker/demo/demo_entrypoint.sh && chmod +x /app/docker/demo/demo_entrypoint.sh && /app/docker/demo/demo_entrypoint.sh"]
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

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

Using bash -lc in the entrypoint is unusual and potentially problematic. The -l flag makes bash run as a login shell, which sources profile files and can introduce unexpected behavior or side effects. Unless login shell behavior is specifically required, use bash -c instead for more predictable execution.

Suggested change
entrypoint: ["/bin/bash", "-lc", "sed -i 's/\r$//' /app/docker/demo/demo_entrypoint.sh && chmod +x /app/docker/demo/demo_entrypoint.sh && /app/docker/demo/demo_entrypoint.sh"]
entrypoint: ["/bin/bash", "-c", "sed -i 's/\r$//' /app/docker/demo/demo_entrypoint.sh && chmod +x /app/docker/demo/demo_entrypoint.sh && /app/docker/demo/demo_entrypoint.sh"]

Copilot uses AI. Check for mistakes.
Comment on lines +69 to +73
docker exec ggmpilot-demo-db bash -lc "\
set -euo pipefail;\
psql -U postgres -d demo -v ON_ERROR_STOP=1 -c 'SELECT count(*) AS client_rows FROM silver.client;' \
|| psql -U postgres -d demo -v ON_ERROR_STOP=1 -c 'SELECT count(*) AS client_rows FROM silver."CLIENT";';\
"
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

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

The validation step uses bash -lc to run commands inside the container, which is inconsistent with the use of bash (without -l) elsewhere in the workflow. The login shell flag (-l) is unnecessary here and can introduce unexpected behavior from profile files. Use bash -c for consistency and more predictable execution.

Copilot uses AI. Check for mistakes.
set -euo pipefail
#!/usr/bin/env bash

set -euo errexit
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

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

The syntax set -euo errexit is incorrect because -e is already the short form of errexit. This line should be set -eu (since pipefail is set separately on line 7 with fallback). The current form mixes the short flag -e with the long option name errexit, which is redundant and may cause unexpected behavior.

Suggested change
set -euo errexit
set -eu

Copilot uses AI. Check for mistakes.
condition: service_healthy
working_dir: /app
entrypoint: ["/bin/bash", "/app/docker/demo/demo_entrypoint.sh"]
entrypoint: ["/bin/bash", "-lc", "sed -i 's/\r$//' /app/docker/demo/demo_entrypoint.sh && chmod +x /app/docker/demo/demo_entrypoint.sh && /app/docker/demo/demo_entrypoint.sh"]
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

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

The entrypoint uses sed to remove carriage returns and chmod to make the script executable. However, this approach is fragile because it processes the file at runtime on every container start. A better approach would be to ensure the file has correct line endings in the repository (via .gitattributes) and set execute permissions in the Dockerfile. This runtime workaround suggests the root cause (Windows line endings) should be fixed at the source.

Suggested change
entrypoint: ["/bin/bash", "-lc", "sed -i 's/\r$//' /app/docker/demo/demo_entrypoint.sh && chmod +x /app/docker/demo/demo_entrypoint.sh && /app/docker/demo/demo_entrypoint.sh"]
entrypoint: ["/app/docker/demo/demo_entrypoint.sh"]

Copilot uses AI. Check for mistakes.
run: |
docker pull postgres:16
docker pull python:3.12-slim
docker pull ghcr.io/astral-sh/uv:latest || true
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

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

The workflow uses docker pull ghcr.io/astral-sh/uv:latest || true which silently ignores pull failures. While this might be intentional for cache warmup, it could mask network issues or repository access problems. Consider logging when the pull fails to make troubleshooting easier.

Suggested change
docker pull ghcr.io/astral-sh/uv:latest || true
docker pull ghcr.io/astral-sh/uv:latest || echo "WARNING: Failed to pull ghcr.io/astral-sh/uv:latest (non-fatal)"

Copilot uses AI. Check for mistakes.
Comment on lines +96 to 99
image: ${DEMO_APP_IMAGE:-ggmpilot:demo}
build:
context: ../..
dockerfile: Dockerfile
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

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

The image is specified after the build section, but Docker Compose best practice is to specify image before build. While this works, the conventional order is to define the image name first, then the build context. This makes it clearer what image will be created.

Copilot uses AI. Check for mistakes.
- external
working_dir: /app
entrypoint: ["/bin/bash", "/app/docker/demo/demo_entrypoint.sh"]
entrypoint: ["/bin/bash", "-lc", "sed -i 's/\r$//' /app/docker/demo/demo_entrypoint.sh && chmod +x /app/docker/demo/demo_entrypoint.sh && /app/docker/demo/demo_entrypoint.sh"]
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

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

Using bash -lc in the entrypoint is unusual and potentially problematic. The -l flag makes bash run as a login shell, which sources profile files and can introduce unexpected behavior or side effects. Unless login shell behavior is specifically required, use bash -c instead for more predictable execution.

Suggested change
entrypoint: ["/bin/bash", "-lc", "sed -i 's/\r$//' /app/docker/demo/demo_entrypoint.sh && chmod +x /app/docker/demo/demo_entrypoint.sh && /app/docker/demo/demo_entrypoint.sh"]
entrypoint: ["/bin/bash", "-c", "sed -i 's/\r$//' /app/docker/demo/demo_entrypoint.sh && chmod +x /app/docker/demo/demo_entrypoint.sh && /app/docker/demo/demo_entrypoint.sh"]

Copilot uses AI. Check for mistakes.
- external
working_dir: /app
entrypoint: ["/bin/bash", "/app/docker/demo/demo_entrypoint.sh"]
entrypoint: ["/bin/bash", "-lc", "sed -i 's/\r$//' /app/docker/demo/demo_entrypoint.sh && chmod +x /app/docker/demo/demo_entrypoint.sh && /app/docker/demo/demo_entrypoint.sh"]
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

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

The entrypoint uses sed to remove carriage returns and chmod to make the script executable. However, this approach is fragile because it processes the file at runtime on every container start. A better approach would be to ensure the file has correct line endings in the repository (via .gitattributes) and set execute permissions in the Dockerfile. This runtime workaround suggests the root cause (Windows line endings) should be fixed at the source.

Suggested change
entrypoint: ["/bin/bash", "-lc", "sed -i 's/\r$//' /app/docker/demo/demo_entrypoint.sh && chmod +x /app/docker/demo/demo_entrypoint.sh && /app/docker/demo/demo_entrypoint.sh"]
entrypoint: ["/bin/bash", "-lc", "/app/docker/demo/demo_entrypoint.sh"]

Copilot uses AI. Check for mistakes.
Comment on lines +58 to 61
image: ${DEMO_APP_IMAGE:-ggmpilot:demo}
build:
context: ../..
dockerfile: Dockerfile
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

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

The image is specified after the build section, but Docker Compose best practice is to specify image before build. While this works, the conventional order is to define the image name first, then the build context. This makes it clearer what image will be created.

Copilot uses AI. Check for mistakes.
Comment on lines +61 to +65
docker exec ggmpilot-demo-db psql -U postgres -d demo -v ON_ERROR_STOP=1 -c "\
SELECT table_schema, table_name\
FROM information_schema.tables\
WHERE table_schema IN ('source','staging','silver')\
ORDER BY 1,2;\
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

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

The bash command embeds SQL that spans multiple lines within the docker exec command. The backslashes and line continuation make this hard to read and maintain. Consider extracting the SQL query to a variable or using a here-document for better readability.

Suggested change
docker exec ggmpilot-demo-db psql -U postgres -d demo -v ON_ERROR_STOP=1 -c "\
SELECT table_schema, table_name\
FROM information_schema.tables\
WHERE table_schema IN ('source','staging','silver')\
ORDER BY 1,2;\
docker exec ggmpilot-demo-db bash -c "psql -U postgres -d demo -v ON_ERROR_STOP=1 <<'EOF'
SELECT table_schema, table_name
FROM information_schema.tables
WHERE table_schema IN ('source','staging','silver')
ORDER BY 1,2;
EOF

Copilot uses AI. Check for mistakes.
- Used shared test helpers more consistently

- Centralized port assignment to avoid conflicts
- Used shared test helpers more consistently

- Centralized port assignment to avoid conflicts

- Improve retry behaviour in get_connection
- Used shared test helpers more consistently

- Centralized port assignment to avoid conflicts

- Improve retry behaviour in get_connection
- Used shared test helpers more consistently

- Centralized port assignment to avoid conflicts

- Improve retry behaviour in get_connection
@lukakoning lukakoning force-pushed the main branch 2 times, most recently from f0630f6 to 4fd500a Compare December 15, 2025 21:04
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