Docker-compose doesn't copy Test files from local folder into Container , but copies everything else

Viewed 70

Consider the docker-compose :

 employee_app:
    container_name: EmployeeContainer
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "9999:3000"
    depends_on:
      - elastic
      
      
  ... more services

And the Dockerfile of employee app :

FROM node:14

COPY . /app
WORKDIR /app/

RUN npm i 
ENTRYPOINT npm start


....

I have a lot of folders in the employee app and when I docker-compose up it copies everything , except for the .test.js files.

Why ?

1 Answers

Based on the comments, I thought I'd be more formal & a more complete answer. When using Docker, if you want something included inside the container you need to make sure that you don't have a .dockerignore file, in hindsight it's obvious, like any other ignore file, you're choosing to exclude things from whatever it is you're working on. I.E. .gitignore, same idea, different tool I guess?

Though, as you mentioned *.test.js, I'd wonder why you'd want that in your container & not as a part of your CI process, even if you run your tests via Docker, i.e. if you look at this example, it could save you removing anything from your .dockerignore file. But of course this is a context specific subject & it's entirely up to you & your team at the end of the day, it's nothing more than a suggestion at most.

Hope that helps!

Related