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 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 |
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.json
file with an npm script calledstart
.It also assumes that a server runs on
npm start
on 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 install
docker compose up
docker compose run node npm install [package name]
compose run
andcompose up
:docker compose down