Reduce size of local Docker images by fixing .dockerignore
patterns
#2360
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Code Changes
.dockerignore
paths to ignore subdirectoriesSteps to Confirm
nox -s test_env
to confirm everything builds as expected and runs nicelyPre-Merge Checklist
CHANGELOG.md
Description Of Changes
We've all noticed that our local Docker development is slow, resource-intensive, and requires a lot of rebuilding (and often lots of cleaning out Docker files!).
In my own local testing I inspected the size of my local dev image and was pretty shocked that it was 2.3 GB! After some tinkering and troubleshooting I realized that all the local build artifacts from both Python (e.g.
*.pyc
files) and NextJS (e.g..next/
) were getting copied into the local image, which has at least two painful consequences:COPY . fides/
command in the webserver build, forcing unnecessary rebuildsThe culprit here is just that the
.dockerignore
patterns are relative to the Dockerfile... so.next
or*.pyc
only ignore those folders/files in the root of the repo. Changing these to**/.next
correctly ignores these from all the subdirectories.Here's the before/after of
docker image ls ethyca/fides:local
on my machine:I don't think this'll have a massive benefit on CI builds, since those won't have those types of local build artifacts lying around, but I suspect this'll be a subtle boost to local development. Hard to quantify exactly how much it'll help yet...