1

I have difficulties to understand the whole proces of an Angular-app in Docker. So anguler needs a webserver to run (like nginx) but also needs nodejs to access the backend? Do you have divide this in 2 containers or how do you have to perform this?

I have now 1 container which had as base image nodejs. There I performed the npm install, bower install and gulp build etc. Now I'm able to visit the localhost:8888/api to see that part of nodejs but I'm unable to visit my angular app. Probably because it's not hosted by a webserver?

1 Answers1

1

NGINX is a front-end server, which doesn't do back-end stuff. This means, that you can separate your application across 2 environments (containers):

  1. Node.js server with it's backend,
  2. NGINX with Angular sites.

NGINX will route requests to node server and that's the whole communication. From there, you can pull these separate container on your productions servers. You can also configure it in the same container and they should work fine together.
If you installed everything, then it should be a matter of proper configuration. You can check out this post as a reference on how to set everything up:
Node.js + Nginx - What now?

  • What's the best idea? Doing it seperatly or together? –  Jan 14 '16 at 13:58
  • 1
    I'd go for separate containers. This way you'll have more control over whole system and it will be less painful to change anything or extend the functionality. –  Jan 14 '16 at 14:46
  • what if the angular and the node-stuff isn't he same repo? You would split them up in 2 folders and have 2 dockerfiles? . And at the same stage having package.json (because they need it both?) –  Jan 15 '16 at 15:38
  • Yes, you should be able to operate on 2 dockerfiles. I think you can use a tool called Docker Compose. It suppose to help in complex applications spreaded across few containers. Here's an interesing post about it: http://anandmanisankar.com/posts/docker-container-nginx-node-redis-example/ –  Jan 15 '16 at 17:09