Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
202 views
in Technique[技术] by (71.8m points)

node.js - How to Dockerize a two nodejs applications in one directory

I have a directory structure like this: Directory Structure

I've never used Docker before and want to dockerize my application, the backend folder is a node app with its own package.json and the frontend folder is its own node app with a package.json, normally to launch my app in my dev environment I start it with two separate terminals, I also have a config.js file in the backend and frontend directory with environmental variables.

question from:https://stackoverflow.com/questions/65944877/how-to-dockerize-a-two-nodejs-applications-in-one-directory

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I would use them in two containers. You can just create a dockerfile in each folder and create a new docker image for each folder/service.

Once you have the images ready you can use e.g. docker-compose to start your containers. Each container can get the same volume to the config file so that each container can read the same config file.

https://docs.docker.com/engine/reference/builder/ https://docs.docker.com/compose/

Jens


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...