iporaitech / pwr2-docker

ARCHIVED: Docker image based on Ubuntu with Elixir and Phoenix Framework integrated with Webpack+Relay+React
MIT License
20 stars 6 forks source link

Build Dockerfile locally (COPY package.json $APP_HOME/) #57

Closed DavidACL closed 8 years ago

DavidACL commented 8 years ago

I'm trying to get this project running on Windows 8 (so using Docker Toolbox vs. Docker for Windows).

I am experiencing an issue with the Dockerfile on step 28, like:

Step 28 : COPY package.json $APP_HOME/
lstat package.json: no such file or directory

My setup process is:

docker-machine create -d virtualbox linuxvm
eval $(docker-machine env linuxvm)

VBoxManage sharedfolder add linuxvm --name repo --hostpath "c:\pwr2-docker\" --transient

docker-machine ssh linuxvm
---------------------------------------------------
                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/
 _                 _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 1.12.2, build HEAD : 9d8e41b - Tue Oct 11 23:40:08 UTC 2016
Docker version 1.12.2, build bb80604
----------------------------------------------------

sudo mount -t vboxsf repo /repo
ls

Listing the contents of /repo shows the mounting to the repo's root, listing contents:

CONTRIBUTING.md     LICENSE             apps/               docker-compose.yml  insecure_key        mix.lock
Dockerfile          README.md           config/             docs/               mix.exs

now, while SSH'd into the Boot2Docker linuxvm, I run:

docker build .

which produces the `Step 28 : COPY package.json $APP_HOME/ lstat package.json: no such file or directory' issue, which stops the build and obviously prevents npm install from being possible because the package.json file isn't in the right place.

It seems that the Dockerfile steps

ENV APP_HOME=/home/app/webapp
RUN mkdir $APP_HOME
WORKDIR $APP_HOME

...

`COPY package.json $APP_HOME/`

Conflict with each other on my system (or I have the directory structure wrong). It seems to me that /home/app/webapp is supposed to be the project root, and /home/app/webapp/apps/webapp is supposed to be the webapp directory that contains package.json. If we WORKDIR to /home/app/webapp, then the command would have to be:

COPY apps/webapp/package.json $APP_HOME/

This change allows the step to complete, but doesn't solve the problem, as there are follow-on issues (npm installl, mix deps.get, establishment of symlinks to match, etc,

My belief is that perhaps I'm setting up the shared folder incorrectly, thus the Dockerfile is not executing for me as it does when you built the hosted image.

For reference, the correct contents (based on the working hosted image) for home/app/webapp/ directory looks like:

_build     deps         insecure_key     mix.exs      package.json      specs
config     docker-compose.dev.example.yml     lib     mix.lock     priv     web    
CONTRIUBTING.md     Dockerfile     LICENSE     node_modules     README.md     webpack.config.js 

You can see that the dir has contents form both the repo-root and repo-root/apps/webapp (including docker-compose.yml), but in contrast, if I but some debug statements in the Dockerfile and run it locally, like:

COPY mix.exs mix.lock $APP_HOME/
RUN pwd
RUN ls

I see only:

 ---> RUN pwd
/home/app/webapp
Step 27 : RUN ls
deps
mix.exs
mix.lock

If I move up COPY . $APP_HOME, /home/app/webapp/ will populate with the contents of the repo-root, which gets me files like Dockerfile and docker-compose.yml, which I'm expecting based on the image, but it appears this commend is intending to copy the repo-root/apps/webapp folder, which it will if the Dockerfile command is changed to COPY apps/webapp/. $APP_HOME, but then the repo-root files are missing compared to the working image.

It seems that I'm missing a step to copy some files into the target dir, and I suspect the problem is how I'm mounting the windows repo-root drive to the linux vm that will build and host the container. I have tried 3 mountings and get the same package.json error for all:

3 mountings I tried that don't work:

sudo mount -t vboxsf repo /repo    //outside of /home/app/webapp -> doesn't work

sudo mount -t vboxsf repo /home/app/webapp    //repo-root = /home/app/webapp -> doesn't work, because package.json is then at /home/app/webapp/apps/webapp/ and COPY command fails

sudo mount -t vboxsf repo /home    //repo-root = /home -> doesn't appear to work

Any help or insight into the intended folder structure, correct mount target, etc would be greatly appreciated.

Thanks!

hisapy commented 8 years ago

Hi @DavidACL

Maybe #53 is related to this.

Which branch are you in?.

PS: develop branch is our development branch where we put that is not released yet and somethings are surely broken. You want to check master or tags to get have a working Dockerfile. We're working to get the next release as soon as possible with some major enhancements and a production ready demo.

DavidACL commented 8 years ago

Hi @hisapy

Yes, you nailed it. I was on develop branch without realizing the branch was broken vs. Readme instructions.

Though I did find the issue stated above and used it to get very close to successfully building through manual adjustments, I'm glad I reached out to you as I could tell something was wrong vs. release image.

I might recommend that you make the note about the 'develop' branch ("NOTICE: The default branch for this repo is develop. Check the README on master to see what's in the last release.") that the branch is frequently broken, and the README steps only apply to the release branch.

Thanks again. Please close at your leisure.

hisapy commented 8 years ago

Thank you for questioning and recommending @DavidACL !... We'll sure make the notice clearer :)

I'm going to close this issue but feel free to re-open it if you find it necessary.