13

I have a simple web application that I would like to place in a docker container. The angular application exists in the frontend/ folder, which is withing the application/ folder.

When the Dockerfile is in the application/ folder and reads as follows:

FROM node
ADD frontend/ frontend/
RUN (cd frontend/; npm install;)
CMD (cd frontend/; npm start;)

everything runs correctly.

However, when I move the Dockerfile into the frontend/ folder and change it to read

FROM node
ADD . frontend/
RUN (cd frontend/; npm install;)
CMD (cd frontend/; npm start;)

no files are copied and the project does not run.

How can I add every file and folder recursively in the current directory to my docker image?

3
  • What about changing the source to ./ Commented Feb 15, 2017 at 1:50
  • ADD . / ./ all copy the current build context contents for me. What does your docker build command look like? Commented Feb 15, 2017 at 2:21
  • @Matt no luck with ADD . / ./, and my build command is sudo docker build -t testfrontend . in the frontend folder Commented Feb 15, 2017 at 12:21

2 Answers 2

14

The Dockerfile that ended up working was

FROM node
ADD . / frontend/
RUN (cd frontend/; npm install;)
CMD (cd frontend/; npm start;)

Shoutout to @Matt for the lead on . / ./, but I think the only reason that didn't work was because for some reason my application will only run when it is inside a directory, not in the 'root'. This might have something to do with @VonC's observation that the node image doesn't have a WORKDIR.

Sign up to request clarification or add additional context in comments.

1 Comment

Good feedback and more precise than my answer. +1. Did you try with a WORKDIR /?
2

First, try COPY just to test if the issue persists.

Second, make sure that no files are copied by changing your CMD to a ls frontend

I do not see a WORKDIR in node/7.5/Dockerfile, so frontend could be in /frontend: check ls /frontend too.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.