Skip to content

.dockerignore: allowlist for copying into the Docker context#10578

Open
schildbach wants to merge 1 commit intolightningnetwork:masterfrom
schildbach:docker-ignore
Open

.dockerignore: allowlist for copying into the Docker context#10578
schildbach wants to merge 1 commit intolightningnetwork:masterfrom
schildbach:docker-ignore

Conversation

@schildbach
Copy link

@schildbach schildbach commented Feb 13, 2026

Without this change, any files in the project directory will be copied into the Docker context when using "docker build". Note this includes git-ignored and dirty files like passwords, wallets, possibly git history, and so on.

This uses quite a lot of disk space, causes unnecessary I/O and renders the Docker cache invalid even on the slightest change to the project.

The current Dockerfile doesn't use the context at all, and dev.Dockerfile only needs a fraction of it. So we ignore everything that isn't explicitly allowed.

@gemini-code-assist
Copy link

Summary of Changes

Hello @schildbach, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a .dockerignore file to optimize Docker build processes. By ignoring all files by default, it prevents the copying of extraneous data, which previously led to increased disk space usage, I/O operations, and frequent cache invalidations. This change enhances build efficiency and security by ensuring only necessary files are considered during the Docker build, as the Dockerfile currently fetches dependencies directly from GitHub.

Highlights

  • Optimized Docker Build Context: Introduced a .dockerignore file to prevent unnecessary files from being copied into the Docker build context, significantly reducing build times and disk usage.
  • Enhanced Security: Prevented sensitive files like passwords and wallets from being inadvertently included in the Docker context, improving security posture.
  • Improved Cache Invalidation: Addressed issues with Docker cache invalidation caused by minor project changes, leading to more efficient builds.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .dockerignore
    • Added a new .dockerignore file to exclude all project files from the Docker build context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aims to improve Docker build performance and security by adding a .dockerignore file, addressing the security risk of sensitive files being leaked into Docker images. However, the current approach of ignoring all files (*) is too broad and breaks existing Docker builds that rely on the local build context, such as dev.Dockerfile. It is recommended to adopt a more selective .dockerignore using an allowlist approach to protect sensitive data without disrupting other build processes.

@@ -0,0 +1,2 @@
# ignore everything
*

Choose a reason for hiding this comment

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

security-medium medium

The current * in .dockerignore ignores all files, causing a denial of service for development and tooling build pipelines by breaking Dockerfiles like dev.Dockerfile, docker/bitcoind/Dockerfile, docker/btcd/Dockerfile, and tools/Dockerfile which rely on the build context. To prevent sensitive file leakage while maintaining build functionality, an allowlist approach is necessary. Please consider the suggested code_suggestion to allow only required files.

# ignore everything
*

# Allowlist files needed for other Dockerfiles
!docker/lnd/start-lnd.sh
!docker/bitcoind/start-bitcoind.sh
!docker/btcd/start-btcctl.sh
!docker/btcd/start-btcd.sh
!tools/
!lnrpc/
!make/
# Add other necessary source files for dev.Dockerfile if needed
#!.git/
#!*

@lightninglabs-deploy lightninglabs-deploy added the severity-low Best-effort review label Feb 13, 2026
Without this change, any files in the project directory will be
copied into the Docker context when using "docker build". Note this
includes git-ignored and dirty files like passwords, wallets,
possibly git history, and so on.

This uses quite a lot of disk space, causes unnecessary I/O and
renders the Docker cache invalid even on the slightest change to
the project.

The current `Dockerfile` doesn't use the context at all, and
`dev.Dockerfile` only needs a fraction of it. So we ignore everything
that isn't explicitly allowed.
@schildbach schildbach changed the title .dockerignore: prevent copying the project into the Docker context .dockerignore: allowlist for copying into the Docker context Feb 13, 2026
@schildbach
Copy link
Author

I force-pushed a new version that takes dev.Dockerfile into account.

However I wasn't able to test the resulting output properly as I'm not an LND dev. So this should be reviewed carefully wether any important files are missing (and its non-existence silently ignored by the Makefile).

@schildbach
Copy link
Author

@schildbach, remember to re-request review from reviewers when ready

How do I do that? I don't think I have permission to (re)request review.

@lightninglabs-deploy
Copy link
Collaborator

@schildbach, remember to re-request review from reviewers when ready

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

severity-low Best-effort review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants