Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pm2 start app.js --container #3094

Closed
Unitech opened this issue Aug 16, 2017 · 2 comments
Closed

pm2 start app.js --container #3094

Unitech opened this issue Aug 16, 2017 · 2 comments
Labels

Comments

@Unitech
Copy link
Owner

Unitech commented Aug 16, 2017

Wizard to start a Node.js application inside a container and easily deploy a production container to a registry.

Development mode

The development mode allows you to easily run an application inside a container, while restarting the application in case of file changes in the host machine.

Wrapping your app inside a container is as easy as:

$ pm2 start app.js --container

It will check if a local Dockerfile is present, if not pm2 will generates a Dockerfile with best practices for developing an application inside a container:

1/ It copies the local package.json and run npm install inside the container
1/ Host sources are exposed to the container via VOLUME
1/ pm2-dev is used to auto restart the application on file changes in the host!

Production / Distribution

The distribution mode package the whole application sources inside a container image, ready to be pushed into your favorite registry.

Switching to distribution mode is simple:

$ pm2 start app.js --container --dist --image-name <image-name>

When switching to distribution mode, pm2 will edit the local Dockerfile to add some production stuff:
1/ COPY the whole source folder inside the target container
1/ Replace the CMD from pm2-dev to pm2 in production mode

Trial

$ npm install Unitech/pm2#pm2-start-container -g
$ pm2 update
$ pm2 start app.js --container

This is a v2 of the first spec

@simonepri
Copy link

It looks amazing 👍
Should we document somewhere what we mean by best practices?

Unitech added a commit that referenced this issue Aug 25, 2017
@Unitech
Copy link
Owner Author

Unitech commented Sep 15, 2017

beta release

$ pm2 start app.js --container
$ pm2 start app.js --container --dist --image-name keymetrics/something

@Unitech Unitech closed this as completed Sep 15, 2017
inerc pushed a commit to inerc/pm2 that referenced this issue Feb 11, 2020
inerc pushed a commit to inerc/pm2 that referenced this issue Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants