Skip to content

Add GHCR registry support and fix PDF generation in Docker containers#172

Merged
thawn merged 8 commits intomasterfrom
copilot/enhance-docker-build-workflow
Jan 5, 2026
Merged

Add GHCR registry support and fix PDF generation in Docker containers#172
thawn merged 8 commits intomasterfrom
copilot/enhance-docker-build-workflow

Conversation

Copy link
Contributor

Copilot AI commented Jan 4, 2026

PDF generation in Docker containers was failing with ERR_CONNECTION_REFUSED because chromium couldn't connect to localhost. Additionally, there was no fast iteration cycle for testing Docker builds.

Changes

Workflow enhancements

  • .github/workflows/docker-build-test.yml: Added push_to_ghcr parameter and build step for GitHub Container Registry
  • .github/workflows/docker-pr.yml: Enabled GHCR push for PRs (tagged as pr<number>)
  • .github/workflows/ghcr-cleanup.yml: New workflow for daily cleanup of test images (3-day retention)

PR builds now automatically push to ghcr.io/thawn/ttmp32gme:pr<number> for immediate testing.

PDF generation fixes

  • src/ttmp32gme/print_handler.py: Changed chromium URL from http://localhost:{port}/pdf to http://127.0.0.1:{port}/pdf

In Docker containers, localhost can fail to resolve due to network namespace isolation. The explicit loopback address ensures reliable connection.

# Before
args = [
    chromium_path,
    "--headless",
    f"http://localhost:{port}/pdf",  # Fails in containers
]

# After
args = [
    chromium_path,
    "--headless",
    f"http://127.0.0.1:{port}/pdf",  # Works reliably
]
  • src/ttmp32gme/ttmp32gme.py: Command-line --port and --host arguments are now persisted to the database

When the server is started with --port or --host command-line arguments, these values are now saved to the database using db.set_config_value(). This ensures that PDF generation (which reads the port from the config) uses the correct runtime port instead of the database default (10020).

# Override config with command-line args and save to database
if args.port:
    config["port"] = args.port
    db.set_config_value("port", str(args.port))
    logger.info(f"Port set to {args.port} from command line and saved to database")
if args.host:
    config["host"] = args.host
    db.set_config_value("host", args.host)
    logger.info(f"Host set to {args.host} from command line and saved to database")

This fixes the issue where chromium was using the default port (10020) from the database instead of the actual server port (e.g., 8080) when started with the --port argument in Docker containers.

Dockerfile fixes

  • resources/build_assets/docker/Dockerfile: Replaced broken uv install script with official container image: COPY --from=ghcr.io/astral-sh/uv:latest
  • Added --native-tls flag for SSL certificate handling
Original prompt

There are still problems with the docker image. Now the PDF is created, but it shows the following content:

This site can’t be reached
localhost refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
  • first enable a faster test cycle by adapting the docker build workflow such that it uploads built images to the github registry (with a lifetime of 3 days), so that I can test them immediately.
  • then tackle the problem itself

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 4, 2026 22:48
Co-authored-by: thawn <1308449+thawn@users.noreply.github.com>
Co-authored-by: thawn <1308449+thawn@users.noreply.github.com>
…ent platform limitation

Co-authored-by: thawn <1308449+thawn@users.noreply.github.com>
Copilot AI changed the title [WIP] Enable faster test cycle for docker images Add GHCR registry support and fix PDF generation in Docker containers Jan 4, 2026
Copilot AI requested a review from thawn January 4, 2026 22:56
…ment

Removed update-ca-certificates command and adjusted pip install commands to remove --native-tls option.
@thawn
Copy link
Owner

thawn commented Jan 4, 2026

@copilot I found the problem: the chromium pdf creation command is: /usr/bin/chromium --no-sandbox --headless --disable-gpu --no-pdf-header-footer --print-to-pdf=/tmp/ttmp32gme_print_std8212a.pdf http://127.0.0.1:10020/pdf the port 10020 is wrong. it is the default port (which is likely still stored like that in the database) but the server is listening on 8080 as per the command line. we need to make sure that chromium gets the correct path.
The port given via command line should be stored in the database.

When the server is started with --port or --host command-line arguments,
these values are now persisted to the database. This ensures that PDF
generation (which uses the port from the database config) uses the correct
port that the server is actually listening on.

Fixes issue where chromium PDF generation was using the default port 10020
from the database instead of the actual server port (e.g., 8080) when
started with --port argument in Docker containers.

Co-authored-by: thawn <1308449+thawn@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 5, 2026

@copilot I found the problem: the chromium pdf creation command is: `/usr/bin/chromium --no-sandbox --headless --disable-gpu --no-pdf-header-footer --print-to-pdf=/tmp/ttmp32gme_print_std8212a.pdf htt...

Fixed in commit 586f312. When --port or --host are provided via command line, they are now saved to the database using db.set_config_value(). This ensures the PDF generation (which reads from the config) uses the correct runtime port instead of the database default (10020).

Copilot AI requested a review from thawn January 5, 2026 00:05
@thawn thawn force-pushed the copilot/enhance-docker-build-workflow branch from b7635c9 to fa22f6e Compare January 5, 2026 00:22
@thawn thawn marked this pull request as ready for review January 5, 2026 00:25
@thawn thawn merged commit 6fb06a3 into master Jan 5, 2026
26 checks passed
@thawn thawn deleted the copilot/enhance-docker-build-workflow branch January 5, 2026 00:26
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