Skip to content
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

chore(ci): migrate docker build back into repo and remove docker buil… #6798

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

leet4tari
Copy link
Contributor

@leet4tari leet4tari commented Feb 12, 2025

Description
Migrate docker build back into repo
Remove old docker build section from ReadMe
Disabled xmrig and monerod docker builds, as they failing

Motivation and Context
Easier to maintain docker images

How Has This Been Tested?
Builds in local fork

Summary by CodeRabbit

  • New Features

    • Introduced a unified configuration for managing Docker deployments, including a new startup utility for streamlined application initialization.
  • Documentation

    • Updated deployment instructions to reference the latest Docker image for the base node.
    • Simplified user guidance by removing legacy build instructions.
  • Chores

    • Streamlined CI/CD workflows and refined build configurations by removing outdated options and redundant environment variables.

@leet4tari leet4tari requested a review from a team as a code owner February 12, 2025 13:17
Copy link

coderabbitai bot commented Feb 12, 2025

Walkthrough

The changes update and streamline the Docker build and deployment configurations. GitHub Actions workflows have been modified by adjusting input options, branch build tags, and output settings while removing unnecessary environment variables and repository path references. The documentation now points to the latest Docker image and removes self-build instructions. Several legacy Dockerfiles and scripts for the Minotari Base Node and Tor have been deleted. In their place, new and updated Dockerfiles and configuration files for Monero, Tor, XMRig, and Tari applications have been added along with a new startup script that orchestrates application launch within Docker.

Changes

File(s) Change Summary
.github/workflows/build_dockers.yml
.github/workflows/build_dockers_workflow.yml
Adjusted CI workflows: commented out monerod and xmrig in inputs, updated branch build outputs (tag_alias changed to latest-testing, build_items now set to all), removed unused env variables, and updated repository/path references.
README.md Updated Docker image reference from a fixed version to latest-nextnet and removed instructions for building a custom Docker image.
buildtools/docker/{base_node.Dockerfile, start.sh, torrc} Deleted obsolete Dockerfile, startup script, and Tor configuration.
buildtools/docker_rig/3rdparty.json Added new entry for Tor ("image_name": "tor").
buildtools/docker_rig/monerod.Dockerfile Introduced a multi-platform build for the Monero daemon with architecture-specific parameters and verification steps.
buildtools/docker_rig/start_tari_app.sh New shell script to start Tari applications: sets environment variables, checks directories, applies wait for Tor, and executes the Tari app.
buildtools/docker_rig/tarilabs.Dockerfile Added multi-stage build for the console wallet with extensive ARG/ENV declarations, an ENTRYPOINT, and a CMD configuration.
buildtools/docker_rig/tarisuite.json New JSON config listing multiple applications (node, wallet, merge mining proxy, sha3 miner) with their image names and execution commands.
buildtools/docker_rig/tor.Dockerfile New Dockerfile for Tor: uses Alpine Linux, sets build args/ENV, exposes ports, defines volumes, and establishes an entrypoint/command.
buildtools/docker_rig/xmrig.Dockerfile Updated XMRig Dockerfile: reverted Alpine version from 3.21 to 3.19, set XMRig version to 6.21.3, and added a new version argument.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant WS as GitHub Workflow
    participant DB as Docker Build Process
    U->>WS: Trigger workflow_dispatch
    WS->>WS: Read build_items input (without monerod and xmrig)
    WS->>WS: Set branch build outputs (tag_alias → latest-testing, build_items → all)
    WS->>DB: Execute Docker build steps
    DB-->>WS: Return build status
    WS->>U: Notify build completion
Loading
sequenceDiagram
    participant C as Docker Container
    participant S as start_tari_app.sh
    participant FS as File System
    C->>S: Start container & invoke startup script
    S->>S: Display configuration variables
    S->>S: Wait for Tor if WAIT_FOR_TOR is set
    S->>FS: Check and create TARI_BASE directory if missing
    S->>S: Change directory to TARI_BASE
    S->>C: Execute Tari application command (APP_EXEC)
    C-->>S: Application runs in container
Loading

Poem

I'm a rabbit coding all day,
Hopping through changes in a whimsical way.
Docker images built with a nimble hop,
CI workflows now smoother nonstop.
New scripts and configs make my heart thump 🥕,
With each update I cheer and joyfully jump!
Happy code and carrot dreams, oh my!


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 6

🔭 Outside diff range comments (2)
.github/workflows/build_dockers_workflow.yml (2)

17-17: ⚠️ Potential issue

Update the Rust toolchain version.

The default toolchain is set to nightly-2024-07-07 which is outdated. Consider updating to a more recent nightly version or using a stable release.

-        default: nightly-2024-07-07
+        default: nightly-2025-02-01

81-81: 🛠️ Refactor suggestion

Implement error handling for matrix setup.

The TODO comment indicates missing error handling. Consider implementing checks for:

  • Invalid JSON files
  • Empty matrix selection
  • Invalid build item names
🧹 Nitpick comments (7)
.github/workflows/build_dockers_workflow.yml (1)

216-216: Enable Docker provenance for supply chain security.

The provenance flag is set to false. Consider enabling it to improve supply chain security by providing verifiable build metadata.

-          provenance: false
+          provenance: true
buildtools/docker_rig/start_tari_app.sh (2)

31-33: Add error handling for directory creation.

The mkdir operation should include error handling to ensure the directory is created successfully.

-if [[ ! -d "${TARI_BASE}" ]]; then
-  mkdir -p "${TARI_BASE}"
-fi
+if [[ ! -d "${TARI_BASE}" ]]; then
+  mkdir -p "${TARI_BASE}" || {
+    echo "Error: Failed to create directory ${TARI_BASE}"
+    exit 1
+  }
+fi

1-40: Add signal handling for graceful shutdown.

The script should handle signals to ensure graceful shutdown of the application.

 #!/bin/bash
+
+# Handle signals
+cleanup() {
+  echo "Shutting down ${APP_NAME}..."
+  kill -TERM "$child" 2>/dev/null
+}
+
+trap cleanup SIGTERM SIGINT
+
 #
 # Docker Start Script for Tari applications
🧰 Tools
🪛 Shellcheck (0.10.0)

[error] 23-23: Argument mixes string and array. Use * or separate argument.

(SC2145)


[error] 38-38: Argument mixes string and array. Use * or separate argument.

(SC2145)


[error] 39-39: Double quote array expansions to avoid re-splitting elements.

(SC2068)

buildtools/docker_rig/xmrig.Dockerfile (1)

47-48: Add HEALTHCHECK instruction.

Consider adding a health check to monitor the XMRig process status.

 COPY --from=builder /xmrig/build/xmrig /usr/local/bin/
+
+# Add health check
+HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
+  CMD pgrep xmrig || exit 1
buildtools/docker_rig/monerod.Dockerfile (1)

54-55: Simplify SHA256 environment variable assignment.

The current implementation uses two lines to set the SHA256 environment variable. This can be simplified.

-ENV MONERO_SHA256=${MONERO_SHA256:-$MONERO_AMD64_SHA256}
-ENV MONERO_SHA256=${MONERO_SHA256:-$MONERO_ARM64_SHA256}
+ENV MONERO_SHA256=${MONERO_SHA256:-${MONERO_AMD64_SHA256:-$MONERO_ARM64_SHA256}}
buildtools/docker_rig/tarilabs.Dockerfile (1)

161-162: Add HEALTHCHECK instruction.

Consider adding a health check to monitor the application status.

 ENTRYPOINT [ "start_tari_app.sh" ]
 CMD [ "--non-interactive-mode" ]
+
+# Add health check
+HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
+  CMD pgrep -f "$APP_EXEC" || exit 1
.github/workflows/build_dockers.yml (1)

47-48: Verify the build configuration changes.

The following changes have been made to the Docker build workflow:

  1. Commented out monerod and xmrig from build options
  2. Changed tag alias from latest-weekly to latest-testing
  3. Changed build_items from minotari_all to all

Please confirm if these changes align with the intended migration strategy.

Consider documenting these changes in the repository's documentation to help other developers understand the new build process.

Also applies to: 94-98

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d3ea51f and eb9b250.

📒 Files selected for processing (13)
  • .github/workflows/build_dockers.yml (2 hunks)
  • .github/workflows/build_dockers_workflow.yml (6 hunks)
  • README.md (1 hunks)
  • buildtools/docker/base_node.Dockerfile (0 hunks)
  • buildtools/docker/start.sh (0 hunks)
  • buildtools/docker/torrc (0 hunks)
  • buildtools/docker_rig/3rdparty.json (1 hunks)
  • buildtools/docker_rig/monerod.Dockerfile (1 hunks)
  • buildtools/docker_rig/start_tari_app.sh (1 hunks)
  • buildtools/docker_rig/tarilabs.Dockerfile (1 hunks)
  • buildtools/docker_rig/tarisuite.json (1 hunks)
  • buildtools/docker_rig/tor.Dockerfile (1 hunks)
  • buildtools/docker_rig/xmrig.Dockerfile (1 hunks)
💤 Files with no reviewable changes (3)
  • buildtools/docker/start.sh
  • buildtools/docker/base_node.Dockerfile
  • buildtools/docker/torrc
✅ Files skipped from review due to trivial changes (2)
  • buildtools/docker_rig/3rdparty.json
  • buildtools/docker_rig/tarisuite.json
🧰 Additional context used
🪛 Shellcheck (0.10.0)
buildtools/docker_rig/start_tari_app.sh

[error] 23-23: Argument mixes string and array. Use * or separate argument.

(SC2145)


[error] 38-38: Argument mixes string and array. Use * or separate argument.

(SC2145)


[error] 39-39: Double quote array expansions to avoid re-splitting elements.

(SC2068)

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: test (mainnet, stagenet)
  • GitHub Check: test (nextnet, nextnet)
  • GitHub Check: machete
  • GitHub Check: Cucumber tests / FFI
  • GitHub Check: cargo check with stable
  • GitHub Check: Cucumber tests / Base Layer
  • GitHub Check: clippy
🔇 Additional comments (8)
README.md (1)

347-347: LGTM! Docker image reference updated correctly.

The Docker image reference has been updated to use the latest-nextnet tag, which aligns with the PR objectives and provides a more maintainable approach.

buildtools/docker_rig/tor.Dockerfile (5)

11-15: LGTM! Well-structured package installation.

The package installation is properly configured with:

  • Minimum version constraint for Tor
  • No-cache flag to reduce image size
  • Helpful reference link to the Alpine package repository

17-20: LGTM! Good use of environment variables for versioning.

The environment variables provide excellent transparency for debugging and maintenance by exposing:

  • Dockerfile version
  • Build architecture
  • Alpine version
  • Tor version

22-27: LGTM! Well-configured network and storage setup.

The configuration properly:

  • Exposes and documents both required Tor ports
  • Defines persistent storage volumes for configuration and data

52-54: LGTM! Secure runtime configuration.

The runtime configuration follows security best practices:

  • Runs as non-root tor user
  • Provides flexibility with missing config files

3-9: ⚠️ Potential issue

Fix incorrect Alpine version.

Alpine Linux version 3.21 does not exist. The latest stable version is 3.19.

Apply this diff to fix the version:

-ARG ALPINE_VERSION=3.21
+ARG ALPINE_VERSION=3.19
❌ Incorrect review comment

🌐 Web query:

What is the latest version of Alpine Linux?

💡 Result:

The latest stable release of Alpine Linux as of February 2025 is version 3.21.2, released on January 8, 2025[1][4]. This release remains actively supported with security updates until November 1, 2026[1].

Key Details

  • Release cycle: Alpine follows a rolling release model where new stable versions are created from development snapshots ("edge") approximately every six months[1].
  • Current supported versions:
    • 3.21.x (supported until Nov 2026)
    • 3.20.x (supported until Apr 2026)
    • 3.19.x (supported until Nov 2025)
    • 3.18.x (supported until May 2025)[1]

To check your Alpine version:

cat /etc/alpine-release

This command will output your specific installed version[1][3]. For comprehensive system details including kernel version and architecture:

hostnamectl
uname -r

Alpine continues to emphasize security through position-independent executables and a hardened toolchain while maintaining its signature small footprint (~5MB base image)[4][5].

Citations:


Incorrect Alpine version review comment

The latest available Alpine Linux stable release as of February 2025 is version 3.21.x (specifically 3.21.2). This confirms that using ARG ALPINE_VERSION=3.21 is appropriate per the current release cycle. No change is needed.

Likely an incorrect or invalid review comment.

buildtools/docker_rig/xmrig.Dockerfile (1)

3-4: Verify the version downgrades.

The Alpine version has been downgraded from 3.21 to 3.19, and XMRig from 6.22.2 to 6.21.3. Please confirm if these downgrades are intentional and if there are any known issues with the newer versions.

Also applies to: 12-13

✅ Verification successful

🌐 Web query:

What are the latest stable versions of Alpine Linux and XMRig? Are there any known issues with Alpine 3.21 or XMRig 6.22.2?

💡 Result:

The latest stable version of Alpine Linux is 3.21.2 (released January 8, 2025)[1][9], while XMRig is at v6.22.2 (released November 3, 2024)[6][7].

Alpine Linux 3.21 Known Issues

  1. Filesystem Separation Limitation: Systems with separate / and /usr partitions are no longer supported[5].
  2. Custom Kernel Requirements: Users must enable CONFIG_FW_LOADER_COMPRESS_ZSTD=y due to Zstd compression in linux-firmware[5].
  3. GNOME Software Compatibility: gnome-software is excluded due to incompatibility with Alpine’s apk package format[4].
  4. LoongArch64 Support: Initial support for this architecture is experimental but functional[8].

XMRig v6.22.2 Known Issues

  1. Thread Configuration on Intel CPUs: Requires fixes for thread count detection on Intel Core Ultra CPUs[6][7].
  2. Stability Risks:
    • Overclocking instability or insufficient power supply can cause crashes[3].
    • First-gen AMD Ryzen/EPYC CPUs may require BIOS-level Opcache disabling or MSR mods in config.json[3].
    • Windows scheduler bugs (post-v1903) may cause hashrate drops; unpinning CPU threads via "rx": [-1,...] is a workaround[3].
  3. Algorithm-Specific Requirements: Some algorithms (e.g., GhostRider) require specific CPU cache sizes and lack proxy support[10].

Both projects remain actively maintained, with Alpine emphasizing security and lightweight design[1][4], while XMRig focuses on multi-algorithm mining efficiency[2][10].

Citations:


Action Required: Confirming Intentional Version Downgrades

Based on the latest stable releases and their known issues:

  • Alpine Linux: The latest stable version is 3.21.2; however, Alpine 3.21 has reported challenges (e.g., filesystem separation limitations, kernel configuration requirements for Zstd, and GNOME software compatibility issues). The decision to revert to Alpine 3.19 may be aimed at avoiding these issues.
  • XMRig: The latest version is v6.22.2, but it comes with known concerns such as thread configuration problems on some Intel CPUs and other stability risks. Downgrading to v6.21.3 could be a precautionary measure for improved reliability.

It appears the downgrades in the Dockerfile are consistent with concerns over the newer versions’ issues. Please confirm if these intentional adjustments did not overlook any dependency that might require the latest versions elsewhere.

buildtools/docker_rig/monerod.Dockerfile (1)

117-119: Verify health check endpoint security.

The health check uses an HTTP endpoint. Ensure this endpoint is properly secured and doesn't expose sensitive information.

❌ Verification inconclusive

🌐 Web query:

What security considerations should be taken into account when exposing Monero daemon's HTTP endpoints?

💡 Result:

When exposing Monero daemon (monerod) HTTP endpoints, several critical security considerations must be addressed to mitigate risks such as unauthorized access, data leakage, and potential exploitation:


1. Authentication and Authorization

  • Enable RPC authentication using --rpc-login with strong credentials[7]. Without this, attackers can freely interact with exposed endpoints.
  • Restrict RPC commands by limiting unnecessary endpoints (e.g., avoid exposing administrative commands like start_mining)[6][7].
  • Use TLS encryption (--rpc-ssl) to protect credentials and data in transit[6].

2. Network Exposure Risks

  • Avoid public exposure: Bind monerod to localhost (--rpc-bind-ip 127.0.0.1) unless remote access is essential[4][7].
  • Firewall rules: Block external access to port 18081 (default RPC port) unless explicitly required[2][8].
  • Monitor traffic: Use tools like tcpdump or intrusion detection systems (IDS) to detect suspicious connections (e.g., unexpected IPs accessing seed-related endpoints)[1][5].

3. Container Hardening (If Deployed in Docker)

  • Disable inter-container communication via Docker’s "icc": false setting[3].
  • Run containers as non-root users and apply --no-new-privileges to prevent privilege escalation[3][5].
  • Restrict environment variables: Avoid leaking credentials or API keys via metrics/logging[2][8].

4. Data Leakage Vulnerabilities

  • Sensitive information exposure: Endpoints like /get_transaction_pool or /get_info can leak node metadata (e.g., blockchain height, peer IPs)[2][7]. Restrict access to trusted users.
  • Wallet integration risks: While monerod doesn’t handle private keys[4], compromised clients (e.g., malicious monero-wallet-cli) could exfiltrate seeds via HTTP requests[1].

5. Software Integrity

  • Verify binary hashes: Ensure downloaded monerod binaries match official releases to avoid tampered versions[1].
  • Regular updates: Patch vulnerabilities promptly by tracking Monero’s GitHub repository[3][9].

6. Attack Surface Reduction

  • Disable unused services: Avoid enabling --restricted-rpc unless necessary for lightweight clients[7].
  • Limit bootstrap nodes: Use set_bootstrap_daemon only with trusted nodes to prevent man-in-the-middle attacks[7].

7. Monitoring and Logging

  • Audit logs: Review bitmonero.log for unusual activity (e.g., unexpected RPC calls)[4].
  • Detect cryptojacking: Monitor CPU/memory usage for unauthorized mining activity[5][8].

By addressing these considerations—through authentication controls, network segmentation, container hardening, and vigilant monitoring—administrators can securely expose Monero daemon HTTP endpoints while minimizing attack vectors[1][3][5][7].

Citations:


Health Check Endpoint Security – Verify Container RPC Configuration

The Dockerfile’s health check is currently using an unsecured HTTP call (i.e. curl --fail http://localhost:18089/get_info). This is acceptable if the Monero daemon is configured to bind solely to localhost and is not exposed outside the container. However, as highlighted in recent research, consider the following to ensure endpoint security:

  • Local Binding: Confirm that Monero’s RPC (and any related HTTP endpoints) are configured with --rpc-bind-ip=127.0.0.1 (or an equivalent restriction) so that they are not inadvertently accessible from an external network.
  • Authentication: Verify that, if any RPC endpoint exposure is required (or if there’s any risk of spillover), RPC authentication (such as using --rpc-login) is enabled to prevent unauthorized access.
  • Network Controls: Ensure that Docker networking and any external firewall rules prevent unintended public access to the port in use (here, port 18089).
  • Additional Hardening: Evaluate whether additional measures (e.g., TLS encryption) make sense in your deployment context—especially if sensitive node metadata might be exposed on the /get_info endpoint.

Please review the overall container and monerod configuration to confirm that these security measures are in place. If they are, the current health check is sufficient; if not, adjustments will be required to align with best practices.

Comment on lines +29 to +50
# Tell Docker to periodically run curl as a way of checking that Tor is runnning OK,
# and is able to build a circuit. Link goes to a Tor Project page, which checks that
# client is accessing it through Tor network and not directly. It gives false negatives
# sometimes, so we should allow several retries.
#
# --socks5-hostname parameter is very important - it tells curl to ask proxy (Tor) for DNS lookup,
# instead of doing it on its own - the behavior that torrc file above explicitly prohibits,
# because it opens a possibility for a traffic correlation attack.
#
# --location flag is added just in case Tor Project changes the location of the page and puts a redirect at
# the previos location, so curl can follow that redirect.
#
# grep gets the output of curl and looks for first occurence of the string 'Congratulations',
# exits with 0 if found and 1 otherwise. Nothing is printed to stdout during this command.

# Currently this healthcheck is problematic and may need very long timeout periods to operate. The endpoint we're using
# isn't controlled by us and sometimes takes up to 45seconds to return, othertimes it gets denied by cloudflare.
# Additionally the HEALTHCHECK emits docker events that launchpad doesn't currently handle well, and will cause the
# container to show as offline.
# HEALTHCHECK --interval=120s --timeout=30s --start-period=60s --retries=5 \
# CMD curl --silent --location --socks5-hostname localhost:9050 https://check.torproject.org/?lang=en_US | \
# grep -qm1 Congratulations
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider implementing a more reliable healthcheck mechanism.

The current healthcheck implementation has several issues:

  1. Long response times from the external endpoint
  2. Potential Cloudflare denials
  3. Docker event handling problems with launchpad

Consider implementing a local healthcheck that verifies Tor's functionality without external dependencies. Here's a suggested implementation:

-# HEALTHCHECK --interval=120s --timeout=30s --start-period=60s --retries=5 \
-#             CMD curl --silent --location --socks5-hostname localhost:9050 https://check.torproject.org/?lang=en_US | \
-#             grep -qm1 Congratulations
+HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
+            CMD nc -z localhost 9050 && nc -z localhost 9051 || exit 1

This approach:

  • Checks if both required ports are listening
  • Avoids external dependencies
  • Has faster response times
  • Is more reliable
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Tell Docker to periodically run curl as a way of checking that Tor is runnning OK,
# and is able to build a circuit. Link goes to a Tor Project page, which checks that
# client is accessing it through Tor network and not directly. It gives false negatives
# sometimes, so we should allow several retries.
#
# --socks5-hostname parameter is very important - it tells curl to ask proxy (Tor) for DNS lookup,
# instead of doing it on its own - the behavior that torrc file above explicitly prohibits,
# because it opens a possibility for a traffic correlation attack.
#
# --location flag is added just in case Tor Project changes the location of the page and puts a redirect at
# the previos location, so curl can follow that redirect.
#
# grep gets the output of curl and looks for first occurence of the string 'Congratulations',
# exits with 0 if found and 1 otherwise. Nothing is printed to stdout during this command.
# Currently this healthcheck is problematic and may need very long timeout periods to operate. The endpoint we're using
# isn't controlled by us and sometimes takes up to 45seconds to return, othertimes it gets denied by cloudflare.
# Additionally the HEALTHCHECK emits docker events that launchpad doesn't currently handle well, and will cause the
# container to show as offline.
# HEALTHCHECK --interval=120s --timeout=30s --start-period=60s --retries=5 \
# CMD curl --silent --location --socks5-hostname localhost:9050 https://check.torproject.org/?lang=en_US | \
# grep -qm1 Congratulations
# Tell Docker to periodically run curl as a way of checking that Tor is runnning OK,
# and is able to build a circuit. Link goes to a Tor Project page, which checks that
# client is accessing it through Tor network and not directly. It gives false negatives
# sometimes, so we should allow several retries.
#
# --socks5-hostname parameter is very important - it tells curl to ask proxy (Tor) for DNS lookup,
# instead of doing it on its own - the behavior that torrc file above explicitly prohibits,
# because it opens a possibility for a traffic correlation attack.
#
# --location flag is added just in case Tor Project changes the location of the page and puts a redirect at
# the previos location, so curl can follow that redirect.
#
# grep gets the output of curl and looks for first occurence of the string 'Congratulations',
# exits with 0 if found and 1 otherwise. Nothing is printed to stdout during this command.
# Currently this healthcheck is problematic and may need very long timeout periods to operate. The endpoint we're using
# isn't controlled by us and sometimes takes up to 45seconds to return, othertimes it gets denied by cloudflare.
# Additionally the HEALTHCHECK emits docker events that launchpad doesn't currently handle well, and will cause the
# container to show as offline.
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD nc -z localhost 9050 && nc -z localhost 9051 || exit 1

echo "WAIT_FOR_TOR: $WAIT_FOR_TOR"
echo "base folder (in container): ${TARI_BASE}"
echo "config file (in container): ${TARI_CONFIG}"
echo "arguments (in container): ${@}"
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix shellcheck warnings about array expansion.

The script has issues with array expansion that could lead to word splitting.

-echo "arguments (in container): ${@}"
+echo "arguments (in container): $*"

-echo " > command: ${APP_EXEC} --config ${TARI_CONFIG} --base-path ${TARI_BASE} ${@} <"
-exec ${APP_EXEC} --config ${TARI_CONFIG} --base-path ${TARI_BASE} ${@} || exit 1
+echo " > command: ${APP_EXEC} --config ${TARI_CONFIG} --base-path ${TARI_BASE} $* <"
+exec "${APP_EXEC}" --config "${TARI_CONFIG}" --base-path "${TARI_BASE}" "$@" || exit 1

Also applies to: 38-39

🧰 Tools
🪛 Shellcheck (0.10.0)

[error] 23-23: Argument mixes string and array. Use * or separate argument.

(SC2145)

Comment on lines +10 to +16
APP_NAME=${APP_NAME:-base_node}
APP_EXEC=${APP_EXEC:-tari_base_node}
WAIT_FOR_TOR=${WAIT_FOR_TOR:-0}
TARI_BASE=${TARI_BASE:-/var/tari/$APP_NAME}
TARI_CONFIG=${TARI_CONFIG:-/var/tari/config/config.toml}
USER_ID=${USER_ID:-1000}
GROUP_ID=${GROUP_ID:-1000}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add validation for required environment variables.

The script should validate that required environment variables are set and contain valid values.

+# Validate required environment variables
+for var in APP_NAME APP_EXEC; do
+  if [[ -z "${!var}" ]]; then
+    echo "Error: ${var} environment variable is required"
+    exit 1
+  fi
+done
+
 APP_NAME=${APP_NAME:-base_node}
 APP_EXEC=${APP_EXEC:-tari_base_node}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
APP_NAME=${APP_NAME:-base_node}
APP_EXEC=${APP_EXEC:-tari_base_node}
WAIT_FOR_TOR=${WAIT_FOR_TOR:-0}
TARI_BASE=${TARI_BASE:-/var/tari/$APP_NAME}
TARI_CONFIG=${TARI_CONFIG:-/var/tari/config/config.toml}
USER_ID=${USER_ID:-1000}
GROUP_ID=${GROUP_ID:-1000}
# Validate required environment variables
for var in APP_NAME APP_EXEC; do
if [[ -z "${!var}" ]]; then
echo "Error: ${var} environment variable is required"
exit 1
fi
done
APP_NAME=${APP_NAME:-base_node}
APP_EXEC=${APP_EXEC:-tari_base_node}
WAIT_FOR_TOR=${WAIT_FOR_TOR:-0}
TARI_BASE=${TARI_BASE:-/var/tari/$APP_NAME}
TARI_CONFIG=${TARI_CONFIG:-/var/tari/config/config.toml}
USER_ID=${USER_ID:-1000}
GROUP_ID=${GROUP_ID:-1000}


ARG XMRIG_VERSION
ARG VERSION=1.0.1
COPY --from=builder /xmrig/build/xmrig /usr/local/bin/
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Set explicit permissions for the binary.

Set appropriate permissions for the XMRig binary to ensure secure execution.

 COPY --from=builder /xmrig/build/xmrig /usr/local/bin/
+RUN chmod 755 /usr/local/bin/xmrig
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
COPY --from=builder /xmrig/build/xmrig /usr/local/bin/
COPY --from=builder /xmrig/build/xmrig /usr/local/bin/
RUN chmod 755 /usr/local/bin/xmrig

Comment on lines +107 to +125
RUN apt-get update && \
apt-get install --no-install-recommends --assume-yes \
apt-transport-https \
bash \
ca-certificates \
curl \
gpg \
iputils-ping \
less \
libreadline8 \
libreadline-dev \
libsqlite3-0 \
openssl \
procps \
lsof && \
# Docker image reduction
apt-get clean all && \
apt-get autoremove --assume-yes && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Pin package versions for reproducible builds.

The apt-get install command doesn't specify versions for the installed packages. This could lead to inconsistent builds.

 RUN apt-get update && \
     apt-get install --no-install-recommends --assume-yes \
-      apt-transport-https \
-      bash \
-      ca-certificates \
-      curl \
+      apt-transport-https=2.6.1 \
+      bash=5.2.15-2+b2 \
+      ca-certificates=20230311 \
+      curl=7.88.1-10+deb12u5 \
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
RUN apt-get update && \
apt-get install --no-install-recommends --assume-yes \
apt-transport-https \
bash \
ca-certificates \
curl \
gpg \
iputils-ping \
less \
libreadline8 \
libreadline-dev \
libsqlite3-0 \
openssl \
procps \
lsof && \
# Docker image reduction
apt-get clean all && \
apt-get autoremove --assume-yes && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN apt-get update && \
apt-get install --no-install-recommends --assume-yes \
apt-transport-https=2.6.1 \
bash=5.2.15-2+b2 \
ca-certificates=20230311 \
curl=7.88.1-10+deb12u5 \
gpg \
iputils-ping \
less \
libreadline8 \
libreadline-dev \
libsqlite3-0 \
openssl \
procps \
lsof && \
# Docker image reduction
apt-get clean all && \
apt-get autoremove --assume-yes && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

Comment on lines +28 to +29
#ENV RUSTFLAGS="-C target_cpu=$ARCH"
#ENV ROARING_ARCH=$ARCH
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Document the reason for commented build flags.

The RUSTFLAGS and ROARING_ARCH environment variables are commented out. Please document why these optimizations are disabled.


🏁 Script executed:

#!/bin/bash
# Check if these flags are used elsewhere in the codebase
rg "RUSTFLAGS.*target_cpu" 
rg "ROARING_ARCH"

Length of output: 478


Action: Document the Disabled Build Flags in tarilabs.Dockerfile

  • The Dockerfile has the following commented-out lines:
    • #ENV RUSTFLAGS="-C target_cpu=$ARCH"
    • #ENV ROARING_ARCH=$ARCH
  • In other parts of the repository:
    • buildtools/build-notes.md exports RUSTFLAGS='-C target_cpu=generic' and ROARING_ARCH=generic.
    • scripts/cross_compile_tooling.sh also has these exports commented out.
  • Recommendation: Update the Dockerfile (and possibly accompanying documentation) to explain why these build flags are disabled. Clarify whether the Docker image is intended to use the generic defaults defined elsewhere (as in the build-notes) or if there’s another reason for omitting these optimizations in this context.

Copy link

Test Results (CI)

    3 files    129 suites   36m 0s ⏱️
1 361 tests 1 361 ✅ 0 💤 0 ❌
4 081 runs  4 081 ✅ 0 💤 0 ❌

Results for commit eb9b250.

Copy link

Test Results (Integration tests)

36 tests  +36   36 ✅ +36   22m 59s ⏱️ + 22m 59s
11 suites +11    0 💤 ± 0 
 2 files   + 2    0 ❌ ± 0 

Results for commit eb9b250. ± Comparison against base commit d3ea51f.

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.

1 participant