Node Sandbox
This docker image builds and runs a node app that is compatible with yarn. I use it to easily clone and host javascript projects on my remote development environment. I use it along side with nginx/letsencrypt proxy to easily develop on this code in a cloud-based IDE.
Run it
- (optional) replace node source code in /sandbox (comes with the create-react-app stock app)
- $docker-node-sandbox> cp .env-ui.example .env-ui
- docker-compose up
Your app is now running on :80 of your docker host.
Customize
This setup is very barebones and lends itself to customization.
Change Port
Two things need to be edited in order to modify the port:
- change
expose:80
toexpose:{your_port}
in docker-compose.yml - change PORT=80 to PORT={your_port} in .env-ui
Adding/Removing Packages
- Make sure you have yarn installed
- `yarn add {package_name}
- docker-compose up --build --force-recreate
--build and --force-recreate ensure's you get a fresh container and build, I am looking for a better way to handle caching of node_modules, which will make adding/removing/upgrading deps more automatic
Using npm instead of yarn
Spin up node-app container with bash instead of yarn start
docker-compose run node-app bash -il
In the container install and run the app
npm install && npm start