cmelion / generator-ng2-webpack

An opinionated tool for scaffolding an app using angular2 and webpack
MIT License
109 stars 18 forks source link

Build and publish a docker image [$100] #15

Closed cmelion closed 8 years ago

cmelion commented 8 years ago

see https://github.com/cmelion/generator-ng2-webpack/wiki/Why-Docker%3F

--- Did you help close this issue? Go claim the **[$100 bounty](https://www.bountysource.com/issues/31789904-build-and-publish-a-docker-image?utm_campaign=plugin&utm_content=tracker%2F32095848&utm_medium=issues&utm_source=github)** on [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F32095848&utm_medium=issues&utm_source=github).
cmelion commented 8 years ago

I finally have access to Docker Beta for Mac! With any luck I'll have an image for ng2-webpack built this weekend.

For those of you that read my post on Docker, this is big news. It lets us spin up a container and still take advantage of hot-loading from the comfort of our preferred IDE, no more restarting the container or expensive r-sync operations.

cmelion commented 8 years ago

The Dockerfile has been published to DockerHub: https://hub.docker.com/r/cmelion/generator-ng2-webpack/

You can pull the complete image and be up and running very quickly via Kitematic (I'm using the beta with Docker for Mac Beta).

The container spins up and the site works as expected, but I'm struggling to figure out how volumes work: https://forums.docker.com/t/mounting-a-volume-and-accessing-from-kitematic-beta/10953

Any help I can get with this issue will be greatly appreciated.

cmelion commented 8 years ago

Looking into https://github.com/nlf/dlite as an alternative to Docker Beta.

cmelion commented 8 years ago

The key to resolving the VOLUME mapping appears to be the entrypoint:

For example: COPY docker-entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"]

Digging into https://github.com/docker-library/ghost/blob/dce058cc4528fee2efa3cdd0d4d12feed8d91a5d/docker-entrypoint.sh

cmelion commented 8 years ago

Determined that, while it's a nice to have to "seed" the host directory from the container, it's not really necessary.

Still need to work out the complete workflow but as long as the src directory exists performing docker run -v with identical port mappings works flawlessly. If the ports are mis-matched then hot-loading won't work.

docker run -t -i -p 8080:8080 -v /Users/user/Documents/Kitematic/generator-ng2-webpack/src:/home/yeoman/client/src cmelion/ng2webpack:v12

cmelion commented 8 years ago

See https://github.com/cmelion/generator-ng2-webpack/wiki/Sample-Docker-Workflow