From 7ada8b6ddd5964e90c990098b708b610d709b835 Mon Sep 17 00:00:00 2001 From: Pete Saia Date: Mon, 30 Mar 2015 02:13:04 -0300 Subject: [PATCH 1/7] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index fe75ff0..446b187 100644 --- a/readme.md +++ b/readme.md @@ -14,7 +14,7 @@ Optionally, you can create another copy for a specific environment. ```bash # Get it up. -docker-compose up -p my-container +docker-compose up # Now you should be able to visit localhost or () if on a mac. # So something like this: From 3f8adda62e66da9be8d7cbbc351ebd4eb1e3a263 Mon Sep 17 00:00:00 2001 From: Pete Saia Date: Thu, 2 Apr 2015 00:33:51 -0300 Subject: [PATCH 2/7] update to readme --- readme.md | 60 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/readme.md b/readme.md index 446b187..cfc942b 100644 --- a/readme.md +++ b/readme.md @@ -1,32 +1,46 @@ ## What is this? +This is a really handy Makefile example for docker development. The example here is a nginx load balanced node, mongo, and redis +application. The benefit to the Makefile is that you can have "controlled persistence". Obviously, if you remove a container +then your data will be lost. When you re-run/build your containers you will be left with a clean slate. This Makefile gives you +2 manual actions for controlling persistence - `make save` and `make restore`. Use them in development, use them in deployment. +Every time you `make save`, a database backup is created in the folder specified (defaults to backups/). You can restore to any point +in history now. This example was made with mongo, but with a little tweaking any store could be used. + This can be used as a boilerplate for a node project. The benefit to using docker is that it allows you to manage your environment is to make sure all environments are consistent from the developers to the production server. It also saves you a ton of time. ## How do I use it? -First you should have a general understanding of what [docker](https://www.docker.com/) and [docker-compose](https://docs.docker.com/compose/yml/) are -and make sure they're installed on your machine. For Linux it's a snap. For OS X, [there are a few extra steps](http://viget.com/extend/how-to-use-docker-on-os-x-the-missing-guide) -but it really isn't that bad. - -The idea is pretty simple. You can tweak the volumes in the [docker-compose.yml](docker-compose.yml) to match your enviornment and get going. -Optionally, you can create another copy for a specific environment. - -```bash -# Get it up. -docker-compose up - -# Now you should be able to visit localhost or () if on a mac. -# So something like this: -# http://192.168.59.103:8080/ <=== Port forwarded for the node app running locally. 8080:8080 -# http://192.168.59.103:8888/ <=== Port forwarded from port 80 being run by nginx. 8888:80 - -# In production, obviously you wouldn't need to forward these ports if DNS is setup and nginx -# is running on port 80. Feel free to tweak nginx/* and just re-run: docker-compose build. +First you should have a general understanding of what [docker](https://www.docker.com/) is and make sure they're installed on your +machine. For Linux it's a snap. For OS X, [there are a few extra steps](http://viget.com/extend/how-to-use-docker-on-os-x-the-missing-guide) but it really isn't that bad. + +1. First, run `make build`. This will build the image for the application. +2. Then run `make run-dev`. This will run all of the containers and you're ready to develop. On linux you can visit localhost:3030. On OS X +visit your (boot2docker ip):3030. +3. Refresh a few times, which adds cats to the system. Head back to the command line and do `make save`. +4. Head back to the browser and refresh as many times as you can. Then go back and do `make restore`. You'll be back where you saved. Controlled +persistence. +5. To remove this app do `make destroy`. + +```text +~ :: make + +Application management. Please make sure you have the env_make file setup. + +Usage: +make build This builds the lev-interactive/myapp image. +make run-dev This will start the application mapping port 80 to 3030. All src + files will be volumed as well for automatic restarts. + be working in for instant changes. Runs on port 3000. +make run-release This will run a container without the volumes on port 80. Good + for production. @TODO +make save This will save the database in the backups directory. +make restore This will restore from the last time you saved. +make destroy Stops and removes all running containers. +``` -# Rebuilds Dockfile if you made changes to that. -docker-compose build && docker-compose up +## TODO's -# Build from scratch. -docker-compose build --no-cache web && docker-compose up -``` +* Redis persistence. +* Ability to pass in the name of a mongodb dump directory instead of it always pulling the latest. From 58c4fd561f289d750c56b6e68eaeadad2fb28dd8 Mon Sep 17 00:00:00 2001 From: Pete Saia Date: Thu, 2 Apr 2015 06:29:28 -0300 Subject: [PATCH 3/7] Update readme.md --- readme.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index cfc942b..8d5cdc0 100644 --- a/readme.md +++ b/readme.md @@ -15,11 +15,12 @@ is to make sure all environments are consistent from the developers to the produ First you should have a general understanding of what [docker](https://www.docker.com/) is and make sure they're installed on your machine. For Linux it's a snap. For OS X, [there are a few extra steps](http://viget.com/extend/how-to-use-docker-on-os-x-the-missing-guide) but it really isn't that bad. -1. First, run `make build`. This will build the image for the application. -2. Then run `make run-dev`. This will run all of the containers and you're ready to develop. On linux you can visit localhost:3030. On OS X +1. First `cp env_make.dist env_make`. This is where you can overwrite environment specific vars for the makefile. +2. Run `make build`. This will build the image for the application. +3. Then run `make run-dev`. This will run all of the containers and you're ready to develop. On linux you can visit localhost:3030. On OS X visit your (boot2docker ip):3030. -3. Refresh a few times, which adds cats to the system. Head back to the command line and do `make save`. -4. Head back to the browser and refresh as many times as you can. Then go back and do `make restore`. You'll be back where you saved. Controlled +4. Refresh a few times, which adds cats to the system. Head back to the command line and do `make save`. +5. Head back to the browser and refresh as many times as you can. Then go back and do `make restore`. You'll be back where you saved. Controlled persistence. 5. To remove this app do `make destroy`. From 6ca2fe295d3faf8b39ada5bdcdc0fa11d23c3f5e Mon Sep 17 00:00:00 2001 From: Pete Saia Date: Thu, 2 Apr 2015 06:49:07 -0300 Subject: [PATCH 4/7] Update readme.md --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index 8d5cdc0..11a0be0 100644 --- a/readme.md +++ b/readme.md @@ -10,6 +10,8 @@ in history now. This example was made with mongo, but with a little tweaking any This can be used as a boilerplate for a node project. The benefit to using docker is that it allows you to manage your environment is to make sure all environments are consistent from the developers to the production server. It also saves you a ton of time. +![example](http://i.imgur.com/yhVTi0S.gif) + ## How do I use it? First you should have a general understanding of what [docker](https://www.docker.com/) is and make sure they're installed on your From dbca874e3885f6f86bb7a1ba89a8c94e107d177b Mon Sep 17 00:00:00 2001 From: Pete Saia Date: Thu, 2 Apr 2015 07:10:27 -0300 Subject: [PATCH 5/7] updated phony --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 763af35..9f8b2b7 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ include env_make # # Phony targets. # -.PHONY: help build run-db run-dev dump-db import-db run-release destroy +.PHONY: help build run-dev run-release save destroy # # Iterated after major releases. From 2f9b55ff9f7a46fecb94d2fda2e93ad82150b088 Mon Sep 17 00:00:00 2001 From: Pete Saia Date: Thu, 2 Apr 2015 08:18:42 -0300 Subject: [PATCH 6/7] Update readme.md --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 11a0be0..fca8a27 100644 --- a/readme.md +++ b/readme.md @@ -47,3 +47,4 @@ make destroy Stops and removes all running containers. * Redis persistence. * Ability to pass in the name of a mongodb dump directory instead of it always pulling the latest. +* Create data-container for logs for load-balanced node instances so we can tail all of them. From a732c9092cfa506fc48e72ece21959033f8bf12a Mon Sep 17 00:00:00 2001 From: Pete Saia Date: Thu, 2 Apr 2015 09:08:24 -0300 Subject: [PATCH 7/7] Update readme.md --- readme.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/readme.md b/readme.md index fca8a27..e935c56 100644 --- a/readme.md +++ b/readme.md @@ -10,8 +10,12 @@ in history now. This example was made with mongo, but with a little tweaking any This can be used as a boilerplate for a node project. The benefit to using docker is that it allows you to manage your environment is to make sure all environments are consistent from the developers to the production server. It also saves you a ton of time. +Checkout this gif: + ![example](http://i.imgur.com/yhVTi0S.gif) +Whoa. + ## How do I use it? First you should have a general understanding of what [docker](https://www.docker.com/) is and make sure they're installed on your