Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
465 views
in Technique[技术] by (71.8m points)

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

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 ?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

1 Answer

0 votes
by (71.8m points)

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! ??


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
...