Created
January 12, 2022 13:29
-
-
Save ericorruption/db9776d6b24669456170a1db0a901689 to your computer and use it in GitHub Desktop.
Simplest node development environment with docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| services: | |
| node: | |
| image: node:16 | |
| user: "node" | |
| command: "npm start" | |
| working_dir: /app | |
| volumes: | |
| - ./:/app | |
| ports: | |
| - 3000:3000 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This assumes that you have a
package.jsonfile with an npm script calledstart.It also assumes that a server runs on
npm starton port3000, and this port is attached to your localhost port of same number.(A good example of this setup is create react app.)
Usage is generally like this:
docker compose run node npm installdocker compose updocker compose run node npm install [package name]compose runandcompose up:docker compose down