I am trying to create a project for sails js using Docker and Docker Compose. What I want is to generate the sails code inside Docker and generate the structure in the current directory.
When I try to generate it, as the directory is not empty because I have a Dockerfile and a docker-compose.yml, I'm getting an error saying that the directory is not empty.
This is the Dockerfile:
FROM node:8.9.3
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN npm install -g sails
RUN sails new .
RUN sails lift
With this configuration I get the error of current directory not empty.
Thinking about it I tried generating the code and the copying it.
...
RUN npm install -g sails
RUN sails new .
# I do the COPY after generating the code
COPY . /usr/src/app
RUN sails lift
This seems to work because I don't get any error in my local environment I don't have the generated code.
Maybe this process is wrong and I should install it as a dependency and then run with docker-compose a container to generate the code, but I think I will have the same problem about trying to generate the code in a non empty directory.
sails newcommand would be creating the source code that you are already copying from the build context. I would think that you do one or the other (not both). If the project was already created locally withsails new, then why run it atdocker buildtime?sailscode inside Docker. Probably I should do it in local and copy them in the Docker image. But the problem I have if that I don't want to use the local node, I want to install it using Docker but I have the problem that I can't generate the code in the current directory because it's not empty.WORKDIR /usr/src/appafter the COPYsails init) and then build an image using that code?