Reputation: 407
I am a newbie at Docker just started learning it.
So I have three build files for an Angular app. The Angular app is just a startup template created using ng new 'projectName'
Dockerfile.dev
Dockerfile.qa
Dockerfile.prod
Now these files work. I have tested them.
Sample Dockerfile.dev
FROM node:alpine
WORKDIR /srv/app
COPY package.json .
RUN npm install
COPY . .
CMD ["npm","run","start"]
But the issue I am facing is how to use the .dockerignore file to exclude the node_modules
I already have the .dockerignore file Which is just a copy of my .gitignore file.
This .dockerignore file works with Dockerfile but not with Dockerfile.qa/dev/prod
I use the following commands to build it
docker build -f Dockerfile.qa .
But the files I want to ignore aren't ignored and are copied over using the
Copy . .
Thank you.
Upvotes: 0
Views: 1428
Reputation: 4274
You can try this:
$ DOCKER_BUILDKIT=1 docker build .
You also need to prefix the name of your .dockerignore
file with the Dockerfile name.
If your Dockerfile is called Dockerfile.dev
the ignore file needs to be called Dockerfile.dev.dockerignore
.
The Docker client tries to load
<dockerfile-name>.dockerignore
first and then falls back to.dockerignore
if it can't be found. So dockerbuild -f Dockerfile.dev .
first tries to loadDockerfile.dev.dockerignore
.
subdirectories
that each have their own Dockerfile
and .dockerignore
files: dev/qa/prod
Upvotes: 1