So, the idea is to dockerize an existing meteor app from 2015. The app is divided into two (backend and frontend). I already made a huge bash script to handle all the older dependencies...software dependencies...etc etc. I just need to run the script and we get the app running. But the idea now is to create a docker image for that project. How should I achieve this? Should I create an empty docker image and run my script there?. Thanks. I'm new to docker.
-
1I would recommend to avoid the shell script, read about how to write [`Dockerfiles`](https://docs.docker.com/engine/reference/builder/), which is a nice way to `build` `images`. Also, keep in mind that the idea with docker is to keep things separated (for example different containers for the app, the database...) and avoid having it "all-in-one" which will make your app a *"monolith"* app. – tgogos Jan 22 '18 at 14:12
-
could I call my script from within the Dockerfile ? – João Vilaça Jan 22 '18 at 14:17
-
Yes, you can. Simply copy the script into the container and call it. But most of the times all the dependency install scripts can be reduced to a few simple install commands since you know what os and package manager you run in your container and their versions also. – Ádám Révész Jan 22 '18 at 14:28
-
I need to install a lot of stuff in order for the app to run, so I really need to run that script, or just paste all that on a dockerfile...anyway, thanks! – João Vilaça Jan 22 '18 at 14:30
-
*"I need to install a lot of stuff..."* My comment on this would be: read about how `docker` `images` are built and the concept of [layers](https://stackoverflow.com/questions/31222377/what-are-docker-image-layers) they have. – tgogos Jan 22 '18 at 14:57
-
Will do. I appreciate your help. :) – João Vilaça Jan 22 '18 at 15:06
1 Answers
A bit more info about the stack, the script, the dependencies could be helpful. Assuming that this app is not in development, you can simply use eg an nginx image, and give it the frontend files to serve.
For the backend there is a huge variety of options like php, node, etc. The dockerfile of your backend image should contain the installation and setup of dependencies (except for other services like database. There are images to do those separated).
To keep things simple you should try out docker-compose to configure your containers to act as a service as a whole (and save you some configurations).
Later, to scale things up, you could look for orchestration tools such as kubernetes. But I assume, this service is not there yet (based on your question). :)

- 231
- 2
- 8
-
Yeah, my idea is to dockerize frontend, backend, and mongo. Then use docker-compose to link all 3. What do you think? About the stack, it's node - meteor - nginx - mongo. The rest of the dependencies are just npm for the project and some 3rd party software that needs to be installed, which is achieved by pulling from a git repo and running "make" on their .c files. – João Vilaça Jan 22 '18 at 14:16
-
Sounds good. There are official images for all of the components of your stack, and you can find articles and github examples with the same stack. (Just googling "nginx, node, mongo docker".) If you don't need any magic installing dependencies than you are good to go with the official [node image](https://github.com/nodejs/docker-node/blob/master/README.md#how-to-use-this-image) without any modification since it installs npm dependencies on startup. :) – Ádám Révész Jan 22 '18 at 14:22
-
I do need a lot of magic to happen ;P . That's why i wrote a script (composed with 4 other scripts) in order for the other devs to pick this up if I can't. Basically I need the image/vm/machine to have a lot of core os dependencies installed, aswell as global npm packages. I'm still pretty lost but your observations helped a bit. Thanks man. – João Vilaça Jan 22 '18 at 14:24