Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
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-4/hathorlib).
# Build from the parent directory:
# docker build -f tx-mining-service/Dockerfile -t tx-mining-service .
COPY hathor-core-4/hathorlib/ /code/hathor-core-4/hathorlib/

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

WORKDIR /code/tx-mining-service

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-4/hathorlib /code/hathor-core-4/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"]
30 changes: 16 additions & 14 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-4/hathorlib", develop = true, extras = ["client"]}
python-healthchecklib = "^0.1.0"

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