The documentation says that .dockerignore
isn’t used when building an image. Is there any way to work around this?
The simplest way to leverage your project’s .dockerignore
is to build the image outside of Aptible and use Direct Docker Image Deployment. This gives you full control over the build process including the ability to use .dockerignore
.
For Dockerfile Deployment, there isn’t really a viable way to utilize this file. However, usually a project’s .gitignore
will exclude the same files that are in .dockerignore
since the repo should generally only include the necessary files to build the project. If there are additional files being ignored at build time, I recommend evaluating if they should be added to the .gitignore
as well.
Beyond that, the only other option I see is to explicitly only ADD
or COPY
the files/directories that you want to include in the image. If you find this to be difficult you can probably make it easier by reorganizing the project based on which files should be included in the image.