Created
April 1, 2018 14:02
-
-
Save maxiimilian/a2d659e3867b430dbfc9c2eff109e436 to your computer and use it in GitHub Desktop.
Dockerized Node.js with Makefile for easy access
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
version: '3' | |
services: | |
web: | |
image: node:8.11 | |
ports: | |
- 8080:8080 | |
command: bash -c "npm install && npm run dev" | |
working_dir: /src | |
volumes: | |
- ".:/src" | |
environment: | |
HOST: 0.0.0.0 |
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
SHELL=/bin/bash | |
.PHONY: start dev shell build | |
start: | |
@docker-compose ps web | grep -q "Up" || docker-compose start | |
dev: start | |
docker-compose logs -f | |
shell: start | |
docker-compose exec web /bin/bash | |
build: start | |
docker-compose exec web /bin/bash -c "npm run build" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These two files can be dropped into any Node.js application directory. Note however, that the application must have been created already otherwise
npm install
will fail. The Makefile provides convienient shortcuts to communicate with the dockerized npm.