Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,28 @@ RUN apk add --no-cache gcc musl-dev libffi-dev openssl-dev rust cargo
RUN pip --no-input --no-cache-dir install --upgrade pip wheel
RUN pip --no-input --no-cache-dir install 'poetry>=1.2.0b2'

COPY poetry.lock pyproject.toml /code/
# Copy hathorlib source (local path dependency: ../hathor-core/hathorlib).
# Build from the parent directory:
# docker build -f tx-mining-service/Dockerfile -t tx-mining-service .
COPY hathor-core/hathorlib/ /code/hathor-core/hathorlib/

# Install in a subdirectory so the relative path "../hathor-core/hathorlib"
# in pyproject.toml resolves correctly to /code/hathor-core/hathorlib/.
COPY tx-mining-service/poetry.lock tx-mining-service/pyproject.toml /code/tx-mining-service/

WORKDIR /code/tx-mining-service

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C2 \
  --glob 'README*' \
  --glob 'docker-compose*' \
  --glob 'compose.*' \
  --glob 'Dockerfile*' \
  --glob 'Makefile*' \
  --glob '*.sh' \
  --glob '*.yml' \
  --glob '*.yaml' \
  'docker build|buildx build|context:|dockerfile:|tx-mining-service/Dockerfile'

Repository: HathorNetwork/tx-mining-service

Length of output: 1005


Update documentation: build command now requires parent directory context.

The Dockerfile correctly documents the new build requirement (line 13: docker build -f tx-mining-service/Dockerfile -t tx-mining-service . from parent), but README.md (line 23) and docker-compose.dev-miner.yml (line 24) still document the old build command without the -f flag. Users following these instructions will encounter COPY hathor-core/hathorlib/ failed errors because the build context lacks the required parent directories.

Update README.md to show: docker build -f tx-mining-service/Dockerfile -t tx-mining-service . (run from parent) or document the parent context requirement explicitly. Verify .dockerignore exists in the parent directory to avoid sending unnecessary files to the daemon on each build.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Dockerfile` around lines 11 - 20, The README.md and
docker-compose.dev-miner.yml must be updated to reflect the new build context
requirement used by the Dockerfile (see COPY hathor-core/hathorlib/ and WORKDIR
/code/tx-mining-service in the Dockerfile); change the documented build command
to "docker build -f tx-mining-service/Dockerfile -t tx-mining-service ." (run
from the repository parent) or explicitly state "run docker build from the
parent directory so ../hathor-core/hathorlib is in context", and add a note to
verify/create a .dockerignore in the parent directory to avoid sending
unnecessary files to the daemon during the build.


RUN poetry config virtualenvs.create false \
&& poetry install --only main --no-interaction --no-ansi

FROM python:3.11-alpine

COPY --from=build /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
# hathorlib is installed in develop mode (.pth file points to this path)
COPY --from=build /code/hathor-core/hathorlib /code/hathor-core/hathorlib
RUN apk add libgcc

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

find . -name "Dockerfile" -type f

Repository: HathorNetwork/tx-mining-service

Length of output: 87


🏁 Script executed:

cat -n ./Dockerfile

Repository: HathorNetwork/tx-mining-service

Length of output: 1685


Add --no-cache to the runtime apk add command.

The build stage (line 6) already uses --no-cache with apk add. The runtime stage should follow the same pattern to avoid storing the package index in the final image.

Proposed fix
-RUN apk add libgcc
+RUN apk add --no-cache libgcc
📝 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 apk add libgcc
RUN apk add --no-cache libgcc
🧰 Tools
🪛 Trivy (0.69.3)

[error] 30-30: 'apk add' is missing '--no-cache'

'--no-cache' is missed: apk add libgcc

Rule: DS-0025

Learn more

(IaC/Dockerfile)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Dockerfile` at line 30, The runtime Dockerfile RUN that installs libgcc
currently uses "RUN apk add libgcc" which leaves the package index in the final
image; change the instruction in the Dockerfile (the RUN apk add libgcc line) to
include --no-cache (e.g., RUN apk add --no-cache libgcc) so the package cache
isn't stored in the final image.


COPY txstratum/ ./txstratum
COPY main.py log.conf ./
COPY tx-mining-service/txstratum/ ./txstratum
COPY tx-mining-service/main.py tx-mining-service/log.conf ./

ENTRYPOINT ["python", "-m", "main"]
32 changes: 17 additions & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ prometheus-client = "^0.9.0"
idna_ssl = "^1.1.0"
# Cap required: setuptools >=82 removed pkg_resources, which is used by pycoin (a transitive dep via hathorlib)
setuptools = ">=68.0,<82"
hathorlib = {version = "^0.14.1", extras = ["client"]}
hathorlib = {path = "../hathor-core/hathorlib", develop = true, extras = ["client"]}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if README mentions the hathor-core dependency requirement
rg -i "hathor-core|companion|sibling" README.md || echo "No mention of hathor-core dependency found in README"

Repository: HathorNetwork/tx-mining-service

Length of output: 127


🏁 Script executed:

# Check for Dockerfile and CI configuration
find . -type f \( -name "Dockerfile*" -o -name "*.yml" -o -name "*.yaml" \) | grep -E "(Dockerfile|\.github|ci)" | head -20

Repository: HathorNetwork/tx-mining-service

Length of output: 147


🏁 Script executed:

# Look for CI configuration files
git ls-files | grep -E "\.github/workflows|\.circleci|\.travis|jenkinsfile" | head -10

Repository: HathorNetwork/tx-mining-service

Length of output: 142


🏁 Script executed:

# Search for hathor-core references in Docker/CI files
rg "hathor-core" -g "Dockerfile*" -g "*.yml" -g "*.yaml" 2>/dev/null || echo "No hathor-core references in config files"

Repository: HathorNetwork/tx-mining-service

Length of output: 537


🏁 Script executed:

cat -n Dockerfile | head -50

Repository: HathorNetwork/tx-mining-service

Length of output: 1297


🏁 Script executed:

cat -n .github/workflows/docker.yml

Repository: HathorNetwork/tx-mining-service

Length of output: 2593


🏁 Script executed:

cat -n .github/workflows/main.yml | head -80

Repository: HathorNetwork/tx-mining-service

Length of output: 1334


🏁 Script executed:

git ls-files | grep -E "\.gitmodules|\.git/config"

Repository: HathorNetwork/tx-mining-service

Length of output: 57


🏁 Script executed:

cat -n .gitmodules 2>/dev/null || echo "No .gitmodules file found"

Repository: HathorNetwork/tx-mining-service

Length of output: 100


🏁 Script executed:

# Check git config for submodules
git config --file .git/config --name-only --get-regexp path 2>/dev/null || echo "No submodules in git config"

Repository: HathorNetwork/tx-mining-service

Length of output: 89


🏁 Script executed:

# Check if docker.yml has checkout steps we haven't seen
rg -A 30 "uses: docker/build-push-action" .github/workflows/docker.yml

Repository: HathorNetwork/tx-mining-service

Length of output: 324


🏁 Script executed:

# Check poetry.lock to see how hathorlib is handled
head -100 poetry.lock | grep -A 5 -B 5 "hathorlib" || echo "Checking further in poetry.lock..."

Repository: HathorNetwork/tx-mining-service

Length of output: 109


🏁 Script executed:

# Search for hathorlib anywhere in poetry.lock
rg "hathorlib" poetry.lock || echo "No hathorlib entry found"

Repository: HathorNetwork/tx-mining-service

Length of output: 126


🏁 Script executed:

cat -n .github/workflows/docker.yml | grep -A 5 -B 5 "actions/checkout"

Repository: HathorNetwork/tx-mining-service

Length of output: 57


🏁 Script executed:

# Check the full workflow structure to see if hathor-core is cloned
rg -B 20 "docker/build-push-action" .github/workflows/docker.yml | head -40

Repository: HathorNetwork/tx-mining-service

Length of output: 1029


Local path dependency and CI configuration needs attention.

The Dockerfile correctly documents the local path dependency on hathor-core (lines 11-13), but this requirement is not documented in the README. More critically, the CI workflows require the hathor-core repository to be available:

  1. The docker.yml workflow doesn't explicitly checkout the parent directory or hathor-core, which is needed for the COPY command in the Dockerfile to succeed during builds.
  2. The main.yml test workflow only checks out the current repo, so poetry install will fail when it tries to resolve the local path dependency ../hathor-core/hathorlib.

Add documentation in the README for the required repository structure (directory layout with hathor-core as a sibling directory) and update CI workflows to clone both repositories appropriately before attempting to build or test.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pyproject.toml` at line 28, Document that pyproject.toml declares a local
path dependency on ../hathor-core/hathorlib and require the repo layout with a
sibling hathor-core directory in the README (show the directory tree and note
that Dockerfile COPY expects ../hathor-core); update the CI workflows
(docker.yml and main.yml) to checkout the sibling repository before build/test
by adding an actions/checkout step for the parent/sibling repo (or checking out
the parent directory) so poetry install and Dockerfile COPY succeed during CI.

python-healthchecklib = "^0.1.0"

[tool.poetry.group.dev.dependencies]
Expand Down
Loading
Loading