Skip to content

Refactor Cloudflare Tunnel setup in README and CI workflow#39

Merged
fakebizprez merged 3 commits intomasterfrom
hotfix/compose
Jan 3, 2026
Merged

Refactor Cloudflare Tunnel setup in README and CI workflow#39
fakebizprez merged 3 commits intomasterfrom
hotfix/compose

Conversation

@fakebizprez
Copy link
Copy Markdown
Member

@fakebizprez fakebizprez commented Jan 3, 2026

  • Updated README to clarify the automatic start of the Cloudflare Tunnel service and simplified the startup command.
  • Adjusted CI workflow to remove the cloudflare profile specification during deployment, ensuring a more straightforward process.
  • Retained the restart policy in docker-compose.yml for the tunnel service.

Summary by CodeRabbit

  • Documentation

    • Renamed and clarified Cloudflare Tunnel docs: tunnel described as required for CI/production (CLOUDFLARED_TOKEN) while optional for local development; deployment instructions simplified to use standard compose up; note added that main service continues if tunnel fails to start without a token.
  • Chores

    • Removed profile gating so the tunnel service starts automatically during standard deployments; token handling and runtime behavior unchanged.

✏️ Tip: You can customize this high-level summary in your review settings.

- Updated README to clarify the automatic start of the Cloudflare Tunnel service and simplified the startup command.
- Adjusted CI workflow to remove the cloudflare profile specification during deployment, ensuring a more straightforward process.
- Retained the restart policy in docker-compose.yml for the tunnel service.
@fakebizprez fakebizprez added the bug Something isn't working label Jan 3, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 3, 2026

Walkthrough

Removed Cloudflare profile gating so the cloudflared service starts automatically. CI deployment no longer uses --profile cloudflare. README and CI comments updated to state CLOUDFLARED_TOKEN is required for the tunnel service; token handling and .env appending remain unchanged. (≤50 words)

Changes

Cohort / File(s) Summary
Compose: cloudflared service
docker-compose.yml
Removed profiles block from the cloudflared service so it is no longer gated by a cloudflare profile; restart unchanged.
CI workflow edits
.github/workflows/ci.yml
Removed --profile cloudflare from the Docker Compose deploy step; updated comments to call CLOUDFLARED_TOKEN “required for cloudflared tunnel service” while leaving token-append logic unchanged.
Documentation / defaults
README.md
Renamed “Cloudflare Tunnel (Optional)” to “Cloudflare Tunnel”; clarified that the bundled tunnel starts automatically and that CLOUDFLARED_TOKEN is required for CI/production (optional for local dev); updated deployment example to use docker compose up -d and noted behavior when token is unset.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

greptile

Poem

🐰 I hopped through compose and CI today,
The profile gate has hopped away.
The tunnel listens when token's near,
Local dev still runs if cloudflared's not here.
A tiny change, a lighter play—🥕

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main changes: refactoring Cloudflare Tunnel setup across the README and CI workflow files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec34c2c and 6028c88.

📒 Files selected for processing (1)
  • README.md
🧰 Additional context used
🧠 Learnings (7)
📚 Learning: 2025-11-27T09:21:56.117Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T09:21:56.117Z
Learning: Applies to **/CLAUDE.md : Update CLAUDE.md when making architectural changes, adding new configuration options, or modifying core algorithms

Applied to files:

  • README.md
📚 Learning: 2025-11-27T09:21:56.117Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T09:21:56.117Z
Learning: Applies to **/temp_monitor.py : Store BEARER_TOKEN in .env file (never committed to git) and load at application startup; auto-generate token if .env is missing

Applied to files:

  • README.md
📚 Learning: 2025-11-27T09:21:56.117Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T09:21:56.117Z
Learning: Applies to **/temp_monitor.py : Use environment variables (loaded via python-dotenv) for configurable paths: LOG_FILE, LOGO_PATH, FAVICON_PATH, BEARER_TOKEN

Applied to files:

  • README.md
📚 Learning: 2026-01-03T19:06:09.139Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T19:06:09.139Z
Learning: Applies to **/temp_monitor.py : Document temperature calibration by adjusting factor parameter in get_compensated_temperature() based on actual readings to compensate for CPU heat effects

Applied to files:

  • README.md
📚 Learning: 2026-01-03T19:06:09.139Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T19:06:09.139Z
Learning: Applies to **/*.py : Implement sensor compensation with CPU heat factor 0.7 and -4°F correction in get_compensated_temperature(), taking 10 readings (5 from humidity + 5 from pressure sensors) with outlier filtering

Applied to files:

  • README.md
📚 Learning: 2025-11-27T09:21:56.117Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T09:21:56.117Z
Learning: Applies to **/temp_monitor.py : Use consistent JSON API response format with fields: temperature_c, temperature_f, humidity, timestamp

Applied to files:

  • README.md
📚 Learning: 2026-01-03T19:06:09.139Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T19:06:09.139Z
Learning: Applies to {Dockerfile,docker-compose.yml} : Use Docker Compose with ARM build support for deployment and include privileged mode, I2C device mounting, and /sys read-only access for hardware interaction

Applied to files:

  • README.md
🪛 LanguageTool
README.md

[uncategorized] ~236-~236: The official name of this software platform is spelled with a capital “H”.
Context: ... for CI/production** - the CI workflow (.github/workflows/ci.yml:79-83) enforces this ...

(GITHUB)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Baz Reviewer
🔇 Additional comments (3)
README.md (3)

85-85: Clear scope-based requirement statement for CLOUDFLARED_TOKEN.

The change from "(none)" to "(required for CI)" with the local dev note provides explicit clarity on when the token is needed. This directly addresses the prior inconsistency between the table designation and the explanation sections.


231-234: Well-aligned deployment section.

The removal of "(Optional)" from the section title is appropriate now that the service starts automatically. The simplified deployment command (docker compose up -d instead of profile-gated) matches the PR's objective to remove profile gating and aligns with the updated CI workflow. The 3-step setup is clear.


236-237: Excellent clarification of token requirements and local development behavior.

The new note successfully addresses the prior documentation concerns by:

  1. Explicitly stating the token is required for CI/production with a reference to the specific CI workflow lines
  2. Clearly explaining optional behavior for local development
  3. Describing the concrete failure mode (cloudflared fails, but temp-monitor continues)
  4. Providing a clear workaround (docker compose up -d temp-monitor) for local-only deployments

This resolves both earlier comments regarding inconsistent messaging and unclear failure behavior.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@fakebizprez
Copy link
Copy Markdown
Member Author

@greptileai review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Jan 3, 2026

Greptile Summary

Removed the cloudflare profile from docker-compose.yml, making the Cloudflare Tunnel service start automatically alongside the main application. Updated README documentation and CI workflow deployment command to reflect this simplified startup process. The changes maintain consistency across all three files - the tunnel service now starts with a standard docker compose up command instead of requiring --profile cloudflare flag.

Key Changes:

  • Removed profiles: [cloudflare] from cloudflared service in docker-compose.yml
  • Updated README instructions from "optional" to automatic startup
  • Removed --profile cloudflare flag from CI deployment command (.github/workflows/ci.yml:119)
  • Updated comment in CI workflow to clarify CLOUDFLARED_TOKEN requirement

Impact: The CI workflow already validates that CLOUDFLARED_TOKEN is required (enforced at .github/workflows/ci.yml:80-83), so this change makes the deployment more straightforward without affecting reliability. Users who don't need the tunnel would need to modify docker-compose.yml or use Docker Compose profiles differently.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • All changes are documentation and configuration updates that maintain consistency across files. The cloudflared service already has proper restart policy and the CI workflow validates required secrets before deployment. No logic changes or security implications.
  • No files require special attention

Important Files Changed

Filename Overview
docker-compose.yml Removed cloudflare profile from cloudflared service, making tunnel start automatically with docker compose up
README.md Updated instructions to reflect automatic Cloudflare Tunnel startup, removing --profile cloudflare flag requirement
.github/workflows/ci.yml Removed --profile cloudflare flag from deployment command and updated comment for clarity

Sequence Diagram

sequenceDiagram
    participant GH as GitHub Actions
    participant Runner as Self-Hosted Runner
    participant Secrets as GitHub Secrets
    participant FS as File System
    participant Docker as Docker Compose
    participant TM as temp-monitor Service
    participant CF as cloudflared Service
    
    GH->>Runner: Trigger deploy job (push/release)
    Runner->>Runner: Checkout code
    Runner->>Secrets: Request BEARER_TOKEN
    Runner->>Secrets: Request CLOUDFLARED_TOKEN
    Runner->>Secrets: Request SLACK_WEBHOOK_URL
    
    Runner->>Runner: Validate BEARER_TOKEN exists
    Runner->>Runner: Validate CLOUDFLARED_TOKEN exists
    
    Runner->>FS: Create .env file with secrets
    Runner->>FS: mkdir -p logs
    
    Runner->>Docker: docker compose up -d --build
    Docker->>Docker: Build temp-monitor image
    Docker->>TM: Start temp-monitor service
    Docker->>CF: Start cloudflared service (automatic)
    CF->>CF: tunnel run --token ${CLOUDFLARED_TOKEN}
    CF->>TM: Proxy traffic to temp-monitor:8080
    
    TM-->>Docker: Health check every 30s
    Docker-->>GH: Deployment complete
Loading

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
docker-compose.yml (1)

26-31: Consider whether cloudflared should remain optional via profile.

Removing the profile gating means the cloudflared service will always attempt to start. If CLOUDFLARED_TOKEN is not set, the service will fail repeatedly (even with restart: unless-stopped), generating error logs. This makes Cloudflare Tunnel effectively mandatory rather than optional.

Options:

  1. Restore the profile approach: profiles: ["cloudflare"] to keep it truly optional
  2. Add clear documentation that CLOUDFLARED_TOKEN is now mandatory for all deployments
  3. Make the service more resilient by adding a healthcheck or startup condition

Note: The main temp-monitor service should continue working even if cloudflared fails, but the deployment will show a degraded state.

.github/workflows/ci.yml (1)

79-91: Remove redundant conditional logic for CLOUDFLARED_TOKEN.

Lines 79-83 validate that CLOUDFLARED_TOKEN is required and fail the workflow if missing. However, lines 88-91 then check if the token is set before adding it to the .env file. This conditional logic is now redundant since line 80 ensures CLOUDFLARED_TOKEN is always non-empty at that point.

🔎 Proposed fix to remove redundant logic
   # Create .env file with required configuration
   echo "BEARER_TOKEN=${BEARER_TOKEN}" > .env

-  # Add optional Cloudflare Tunnel token if configured
-  if [ -n "${CLOUDFLARED_TOKEN}" ]; then
-    echo "CLOUDFLARED_TOKEN=${CLOUDFLARED_TOKEN}" >> .env
-  fi
+  # Add Cloudflare Tunnel token (validated as required above)
+  echo "CLOUDFLARED_TOKEN=${CLOUDFLARED_TOKEN}" >> .env
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d15c9eb and 62ba41a.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml
  • README.md
  • docker-compose.yml
🧰 Additional context used
📓 Path-based instructions (1)
{Dockerfile,docker-compose.yml}

📄 CodeRabbit inference engine (CLAUDE.md)

Use Docker Compose with ARM build support for deployment and include privileged mode, I2C device mounting, and /sys read-only access for hardware interaction

Files:

  • docker-compose.yml
🧠 Learnings (2)
📚 Learning: 2025-11-27T09:21:56.117Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T09:21:56.117Z
Learning: Applies to **/CLAUDE.md : Update CLAUDE.md when making architectural changes, adding new configuration options, or modifying core algorithms

Applied to files:

  • README.md
📚 Learning: 2026-01-03T19:06:09.139Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T19:06:09.139Z
Learning: Applies to {Dockerfile,docker-compose.yml} : Use Docker Compose with ARM build support for deployment and include privileged mode, I2C device mounting, and /sys read-only access for hardware interaction

Applied to files:

  • README.md
  • .github/workflows/ci.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Greptile Review
🔇 Additional comments (1)
.github/workflows/ci.yml (1)

119-119: LGTM! Deployment command correctly reflects the removal of profile gating.

The removal of --profile cloudflare is consistent with the docker-compose.yml changes where the cloudflared service no longer uses profile-based gating.

- Updated README to indicate that `CLOUDFLARED_TOKEN` is required for the Cloudflare Tunnel service to start.
- Modified CI workflow comments to reflect the necessity of the Cloudflare Tunnel token during environment setup.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/ci.yml (1)

79-91: Redundant conditional logic after required validation.

Lines 79-83 validate that CLOUDFLARED_TOKEN exists and exit if it's missing, establishing it as required. However, lines 89-91 then conditionally add the token only "if [ -n "${CLOUDFLARED_TOKEN}" ]", which is redundant since we've already confirmed it exists.

Additionally, line 88's comment changed from "optional" to "required", but the conditional logic suggests optional behavior, creating confusion about the actual requirement.

🔎 Suggested simplification
-          # Add required Cloudflare Tunnel token
-          if [ -n "${CLOUDFLARED_TOKEN}" ]; then
-            echo "CLOUDFLARED_TOKEN=${CLOUDFLARED_TOKEN}" >> .env
-          fi
+          # Add required Cloudflare Tunnel token (validated above)
+          echo "CLOUDFLARED_TOKEN=${CLOUDFLARED_TOKEN}" >> .env
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 62ba41a and ec34c2c.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml
  • README.md
🧰 Additional context used
🧠 Learnings (6)
📚 Learning: 2025-11-27T09:21:56.117Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T09:21:56.117Z
Learning: Applies to **/CLAUDE.md : Update CLAUDE.md when making architectural changes, adding new configuration options, or modifying core algorithms

Applied to files:

  • README.md
📚 Learning: 2025-11-27T09:21:56.117Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T09:21:56.117Z
Learning: Applies to **/temp_monitor.py : Store BEARER_TOKEN in .env file (never committed to git) and load at application startup; auto-generate token if .env is missing

Applied to files:

  • README.md
  • .github/workflows/ci.yml
📚 Learning: 2025-11-27T09:21:56.117Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T09:21:56.117Z
Learning: Applies to **/temp_monitor.py : Use environment variables (loaded via python-dotenv) for configurable paths: LOG_FILE, LOGO_PATH, FAVICON_PATH, BEARER_TOKEN

Applied to files:

  • README.md
  • .github/workflows/ci.yml
📚 Learning: 2026-01-03T19:06:09.139Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T19:06:09.139Z
Learning: Applies to {Dockerfile,docker-compose.yml} : Use Docker Compose with ARM build support for deployment and include privileged mode, I2C device mounting, and /sys read-only access for hardware interaction

Applied to files:

  • README.md
  • .github/workflows/ci.yml
📚 Learning: 2026-01-03T19:06:09.139Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T19:06:09.139Z
Learning: Applies to .env.example : Generate API Bearer token using python3 -c "import secrets; print(secrets.token_hex(32))" and store securely in .env file

Applied to files:

  • .github/workflows/ci.yml
📚 Learning: 2026-01-03T19:06:09.139Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T19:06:09.139Z
Learning: Applies to **/*.py : Use environment variables from .env file for configuration (LOG_FILE, BEARER_TOKEN, SLACK_WEBHOOK_URL, WEBHOOK_*, ALERT_*, STATUS_UPDATE_*) managed through python-dotenv

Applied to files:

  • .github/workflows/ci.yml
🔇 Additional comments (2)
README.md (1)

236-237: Good addition addressing previous review feedback.

The added note clearly explains the behavior when CLOUDFLARED_TOKEN is not set and provides guidance for running without Cloudflare Tunnel. This directly addresses the concern raised in the previous review about documenting failure behavior.

</review_comment_end>

.github/workflows/ci.yml (1)

119-119: Approved: Profile flag removal aligns with docker-compose changes.

Removing --profile cloudflare is consistent with the broader refactoring to make the Cloudflare Tunnel service start automatically when the token is present, rather than requiring explicit profile activation.

</review_comment_end>

- Updated README to specify that `CLOUDFLARED_TOKEN` is required for CI/production environments, while being optional for local development.
- Enhanced notes on the Cloudflare Tunnel service startup process and its implications for local and CI deployments.
@fakebizprez
Copy link
Copy Markdown
Member Author

baz review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Jan 3, 2026

Skipped: This PR does not contain any of your configured labels: (greptile)

@fakebizprez fakebizprez merged commit ea4a63a into master Jan 3, 2026
5 checks passed
@fakebizprez fakebizprez deleted the hotfix/compose branch January 3, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

baz approved bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant