-
Notifications
You must be signed in to change notification settings - Fork 11
(socks-proxy) add healthcheck to dockerfile #402
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
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughUpdates to the SOCKS proxy Docker image and entrypoint: apt installs made noninteractive in the base stage; runtime stage now installs netcat-traditional then copies Changes
Sequence Diagram(s)sequenceDiagram
participant Container
participant Entrypoint
participant Sockd
participant Healthcheck as HC
Container->>Entrypoint: container start
rect `#F6F8FF`
Entrypoint->>Entrypoint: set umask 0077
Entrypoint->>Entrypoint: remaining init logic (unchanged)
Entrypoint->>Sockd: exec sockd (CMD)
end
loop periodic
HC->>Container: nc -zv 127.0.0.1 <PROXY_PORT>
alt success
HC-->>Container: probe OK (exit 0)
else failure
HC-->>Container: probe failed (non-zero)
end
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
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. Comment |
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/socks-proxy/entrypoint.sh (1)
44-44: Optional refactor: replacexargswhitespace trim with bash parameter expansion.Line 44 uses
echo "$ip_range" | xargsto trim whitespace. This spawns a subprocess unnecessarily. Consider a pure bash approach for consistency and minor efficiency gain:- ip_range=$(echo "$ip_range" | xargs) + ip_range="${ip_range#"${ip_range%%[![:space:]]*}"}" # trim leading + ip_range="${ip_range%"${ip_range##*[![:space:]]}"}" # trim trailingOr more concisely using parameter expansion (requires bash 4.4+):
+ ip_range=${ip_range//[[:space:]]} # removes all whitespaceHowever, for maximum clarity and compatibility, the current
xargsapproach is also acceptable.Also applies to: 41-63
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/socks-proxy/Dockerfile(2 hunks)src/socks-proxy/entrypoint.sh(1 hunks)
⏰ 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). (6)
- GitHub Check: docker-publish-mta-in / docker-build-push
- GitHub Check: docker-publish-socks-proxy / docker-build-push
- GitHub Check: test-back
- GitHub Check: lint-back
- GitHub Check: build-front
- GitHub Check: check-api-state
🔇 Additional comments (3)
src/socks-proxy/Dockerfile (1)
9-9: Good practice: noninteractive apt installation and efficient layer structure.The use of
DEBIAN_FRONTEND="noninteractive"prevents interactive prompts, and the runtime stage correctly isolates curl installation with proper cleanup, reducing layer bloat.Also applies to: 25-29
src/socks-proxy/entrypoint.sh (2)
3-3: Good security practice: restrictive umask and credential storage.The
umask 0077ensures/healthcredsis created with0600permissions (readable only by owner), protecting the healthcheck credentials from unauthorized access. The random password generation using/dev/urandomand character stripping is appropriate.Also applies to: 10-12
41-63: Dynamic DANTE config generation handles IP whitelist correctly.The loop properly splits
PROXY_SOURCE_IP_WHITELISTby comma and generates client/socks sections for each range. Default to0.0.0.0/0when unset is sensible. This approach scales better than hardcoded configuration.
bc0ac1a to
e352af3
Compare
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.
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)
src/socks-proxy/entrypoint.sh (1)
18-23: Misleading message: code always resets password despite "skipping" log.The message on line 19 says the user is being skipped, but line 23 unconditionally calls
chpasswd, which resets the password every invocation. Either skip the password reset or clarify the message to match the actual behavior.Apply this diff to clarify intent:
if id "$user" &>/dev/null; then - echo "User $user already exists, skipping" + echo "User $user already exists, updating password" else useradd -M -s /usr/sbin/nologin "$user" fiAlternatively, if you want true idempotency and only set password on creation, restructure as:
if id "$user" &>/dev/null; then echo "User $user already exists, skipping" else useradd -M -s /usr/sbin/nologin "$user" echo "$user:$pass" | chpasswd fi
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/socks-proxy/Dockerfile(2 hunks)src/socks-proxy/entrypoint.sh(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/socks-proxy/Dockerfile
⏰ 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). (5)
- GitHub Check: docker-publish-socks-proxy / docker-build-push
- GitHub Check: check-api-state
- GitHub Check: build-front
- GitHub Check: lint-back
- GitHub Check: test-back
🔇 Additional comments (1)
src/socks-proxy/entrypoint.sh (1)
10-12: Verify Dockerfile HEALTHCHECK correctly reads generated credentials.The entrypoint generates and stores healthcheck credentials in
/healthcreds(plaintext), but idempotency and timing must align with the Dockerfile's HEALTHCHECK probe. Ensure:
- The HEALTHCHECK curl command reads from
/healthcredsor receives the password via environment.- The
/healthcredsfile is readable by the process running the health probe.- No race condition exists between credential generation (line 12) and initial healthcheck probe.
Since the Dockerfile was not provided for review, please verify that the healthcheck mechanism correctly uses these credentials.
57ffcc2 to
3148970
Compare
|
@zeylos not sure I feel good about adding a dependency to an external service ? (ip.me) |
|
you're right actually, I hit ip.me so that I can have the current outgoing IP in the |
|
Actually I don't want other instances to rely on us and putting a var just for the healthcheck feels overkill. Since netcat will handle what we actually want -checking the daemon's health- I'll just go with netcat |
c1cbed3 to
2de4c7e
Compare
2de4c7e to
0c279b1
Compare
|
Netcat was generating way too much logs, and I didn't find any easy way to delete netcat logs and keep the actual traffic's logs. the current healthcheck is not actually that useful - it only checks if the process is not in Disk Sleep or Zombie state. This should do, we can work on it if we find any weird edge case later |
Purpose
Description...
Proposal
Description...
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.