Skip to content

Instantly share code, notes, and snippets.

@maxiimilian
Created April 1, 2018 14:02
Show Gist options
  • Save maxiimilian/a2d659e3867b430dbfc9c2eff109e436 to your computer and use it in GitHub Desktop.
Save maxiimilian/a2d659e3867b430dbfc9c2eff109e436 to your computer and use it in GitHub Desktop.
Dockerized Node.js with Makefile for easy access
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
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"
@maxiimilian
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment