diff --git a/.gitignore b/.gitignore index f465b1a..a1a8a54 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .DS_Store npm-debug.log node_modules -blog.md \ No newline at end of file +_presentation diff --git a/README.md b/README.md new file mode 100644 index 0000000..d64a3d9 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +sample diff --git a/_presentation/images/circleci.png b/_presentation/images/circleci.png deleted file mode 100644 index f6c3a76..0000000 Binary files a/_presentation/images/circleci.png and /dev/null differ diff --git a/_presentation/images/compose.jpg b/_presentation/images/compose.jpg deleted file mode 100644 index 017effa..0000000 Binary files a/_presentation/images/compose.jpg and /dev/null differ diff --git a/_presentation/images/compose.png b/_presentation/images/compose.png deleted file mode 100644 index 5297723..0000000 Binary files a/_presentation/images/compose.png and /dev/null differ diff --git a/_presentation/images/docker-logo.jpg b/_presentation/images/docker-logo.jpg deleted file mode 100644 index 6811588..0000000 Binary files a/_presentation/images/docker-logo.jpg and /dev/null differ diff --git a/_presentation/images/fig.png b/_presentation/images/fig.png deleted file mode 100644 index 86d3574..0000000 Binary files a/_presentation/images/fig.png and /dev/null differ diff --git a/_presentation/images/figup.png b/_presentation/images/figup.png deleted file mode 100644 index 2754bfa..0000000 Binary files a/_presentation/images/figup.png and /dev/null differ diff --git a/_presentation/images/heart.jpg b/_presentation/images/heart.jpg deleted file mode 100644 index 7f6141b..0000000 Binary files a/_presentation/images/heart.jpg and /dev/null differ diff --git a/_presentation/images/holy-grail.jpg b/_presentation/images/holy-grail.jpg deleted file mode 100644 index f3a0982..0000000 Binary files a/_presentation/images/holy-grail.jpg and /dev/null differ diff --git a/_presentation/images/logo.png b/_presentation/images/logo.png deleted file mode 100644 index 8fe5eab..0000000 Binary files a/_presentation/images/logo.png and /dev/null differ diff --git a/_presentation/images/oh-my.jpg b/_presentation/images/oh-my.jpg deleted file mode 100644 index 5e74acd..0000000 Binary files a/_presentation/images/oh-my.jpg and /dev/null differ diff --git a/_presentation/images/rp_logo_color_small.png b/_presentation/images/rp_logo_color_small.png deleted file mode 100644 index fe863f7..0000000 Binary files a/_presentation/images/rp_logo_color_small.png and /dev/null differ diff --git a/_presentation/images/steps.jpg b/_presentation/images/steps.jpg deleted file mode 100644 index 62c9da4..0000000 Binary files a/_presentation/images/steps.jpg and /dev/null differ diff --git a/_presentation/images/tutum.jpg b/_presentation/images/tutum.jpg deleted file mode 100644 index dade520..0000000 Binary files a/_presentation/images/tutum.jpg and /dev/null differ diff --git a/_presentation/images/tutum.png b/_presentation/images/tutum.png deleted file mode 100644 index 76ecb56..0000000 Binary files a/_presentation/images/tutum.png and /dev/null differ diff --git a/_presentation/presentation.md b/_presentation/presentation.md deleted file mode 100644 index 430fcc9..0000000 --- a/_presentation/presentation.md +++ /dev/null @@ -1,226 +0,0 @@ -![docker logo](images/docker-logo.jpg) - -### Fitter. Happier. More Productive. - -
- -Presented at the [NodeJS Denver/Boulder](http://www.meetup.com/Node-js-Denver-Boulder/)
Meetup group on March 5th, 2015. - ---- - -## Joke - -

- -### What did the hippie say when asked to get off the couch? - ----- - -Namaste
(nah-I'm-a-stay) - ---- - -## About Me - -
- -- Full-stack web developer -- Co-founder/Author of [Real Python](https://realpython.com) - specializes in teaching the Python syntax and web development. - - ![real python logo](images/rp_logo_color_small.png) - -- Mentor/educator/teacher/blogger - [refactorU](http://www.refactoru.com/) -- Bottom-line: *I don't sleep*. - ---- - -## Today - -
- -1. Docker basics (~10%) -1. Development workflow (~90%) - Docker setup, local development, continous integration/delivery - -Note: We're covering a lot of material today. Don't worry if you miss something or don't fully understand a concept since this entire workflow will be featured in a blog post on Real Python - https://realpython.com. The post will go live on 02/10/2015. I would recommend just watching me go through the workflow, and then recreate it on your own next week when the post goes live. - ---- - -## What is Docker? - -

- -#### Containers AND Images AND Dockerfiles. Oh my! - -![oh my](images/oh-my.jpg) - -Note: -With Docker you can easily deploy a web application along with the app's dependencies, environment variables, and configuration settings - everything you need to recreate your environment quickly and efficiently. -- A *Dockerfile* is a file that contains a set of instructions used to create an *image*. -- An *image* is used to build and save snapshots (the state) of an environment. -- A *container* is an instantiated, live *image* that runs a collection of processes. - ----- - -## Why Docker? - -
- -1. Version control for infrastructure -1. Easily distribute/recreate your entire dev env -1. Build once, run anywhere - aka The Holy Grail! - -![holy grail](images/holy-grail.jpg) - -Note: In other words, you can truly mimic your production environment on your local machine. No more having to debug environment specific bugs or worrying that your app will perfrom different in production. - ---- - -## Workflow! - -

- -![steps](images/steps.jpg) - -Note: -1. Code locally on a feature branch -1. Open a pull request on Github against the master branch -1. Run automated tests against the Docker container -1. If the tests pass, manually merge the pull request into master -1. Once merged, the automated tests run again -1. If the second round of tests pass, a build is created on Docker Hub -1. Once the build is created, it's then automatically (err, automagically) deployed to production - ---- - -# Part 1 - Local Setup - ----- - -## Docker Setup - -
- -Let's get Docker up and running! - -
- -Enter **Boot2Docker** - a *lightweigh*t Linux distribution designed specifically to run Docker ([Install](https://docs.docker.com/installation/mac/)) - ----- - -## Compose Up! - -
- -![docker compose](images/compose.png) - -- **[Docker Compose](https://github.com/docker/compose)** builds and runs services needed for your application's tech stack. -- Install and then define the services within a *docker-compose.yml* file. - ----- - -## Build and Run - -

- -### `$ docker-compose up` - -![fig logo](images/figup.png) - ---- - -# Part 2 - Continuous Integration - ----- - -## Docker Hub - -
- -- [Docker Hub](https://hub.docker.com/) is a repository of Docker images. -- It acts as a CI server since you can configure it to create a build every time you push a new commit to Github. - ----- - -## CircleCI - -
- -![circleci logo](images/circleci.png) - -- **[CircleCI](https://circleci.com/)** is a continuous integration and delivery platform that supports testing within Docker containers. -- [Getting started with CircleCI](https://circleci.com/docs/getting-started) - super simple setup -- Add a *circle.yml* config file - ----- - -## Feature Branch Workflow - -
- -Example... - -1. Create the branch -1. Make changes locally -1. Issue a Pull request -1. Manually merge once the tests pass -1. The tests run again on the master branch -1. Once the second round passes, a new build is triggered on Docker Hub - ---- - -# Part 3 - Continuous Delivery - ----- - -## Tutum - -
- -![tutum logo](images/tutum.jpg) - -- [Tutum](https://www.tutum.co/) manages the orchestration and deployment of Docker images and containers. -- This service is used for the actual delivery of our app to Digital Ocean. - ----- - -## Tutum (setup) - -
- -1. Sign up -1. Link your Digital Ocean Account -1. Add a Node -1. Add a stack -1. Add web hook -1. Profit - ----- - -## Feature Branch Workflow (redux) - -
- -1. Create the branch -1. Make changes locally -1. Issue a Pull request -1. Manually merge once the tests pass -1. The tests run again on the master branch -1. Once the second round passes, a new build is triggered on Docker Hub -1. After the build is triggered, a post request is sent to Tutum, which redeploys the app. - ---- - - -# Conclusion - -
- -- So, we went over a nice development workflow that included setting up a local environment coupled with continuous integration. -- **michael@realpython.com** - -
- -Cheers! - ---- diff --git a/app/Dockerfile b/app/Dockerfile index af8c6c3..971a00a 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -1,4 +1,4 @@ -FROM dockerfile/nodejs +FROM node:latest RUN mkdir /src diff --git a/app/index.js b/app/index.js index 18636fa..56a2563 100644 --- a/app/index.js +++ b/app/index.js @@ -5,8 +5,8 @@ var express = require('express'), var app = express(); var client = redis.createClient( - process.env.REDIS_1_PORT_6379_TCP_PORT || '127.0.01', - process.env.REDIS_1_PORT_6379_TCP_ADDR || 6379 + process.env.REDIS_1_PORT_6379_TCP_PORT || 6379, + process.env.REDIS_1_PORT_6379_TCP_ADDR || '127.0.0.1' ); app.get('/', function(req, res, next) { @@ -18,4 +18,4 @@ app.get('/', function(req, res, next) { http.createServer(app).listen(process.env.PORT || 3000, function() { console.log('Listening on port ' + (process.env.PORT || 3000)); -}); \ No newline at end of file +}); diff --git a/app/package.json b/app/package.json index 63cbc80..d860ba6 100644 --- a/app/package.json +++ b/app/package.json @@ -1,13 +1,13 @@ { "name": "node-docker-workflow", - "version": "0.0.1", + "version": "0.0.2", "private": true, "scripts": { "start": "node index.js" }, "dependencies": { - "express": "3.4.8", - "mocha": "^2.1.0", - "redis": "^0.12.1" + "express": "^4.13.3", + "mocha": "^2.3.3", + "redis": "^2.2.5" } } diff --git a/circle.yml b/circle.yml index 3ba395b..12ec40f 100644 --- a/circle.yml +++ b/circle.yml @@ -4,7 +4,7 @@ machine: dependencies: override: - - sudo pip install docker-compose + - sudo pip install --upgrade docker-compose==1.3.3 test: override: @@ -15,4 +15,4 @@ deployment: hub: branch: master commands: - - $DEPLOY \ No newline at end of file + - $DEPLOY diff --git a/docker-compose.yml b/docker-compose.yml index b93c0f0..a9363ad 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,12 @@ web: build: ./app volumes: - - "app:/src/app" + - "./app:/src/app" ports: - "80:3000" links: - redis redis: - build: ./redis + image: redis:latest ports: - "6379:6379" diff --git a/readme.md b/readme.md deleted file mode 100644 index 847a3e8..0000000 --- a/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -Hi! - -[![Circle CI](https://circleci.com/gh/mjhea0/node-docker-workflow.svg?style=svg)](https://circleci.com/gh/mjhea0/node-docker-workflow) \ No newline at end of file diff --git a/redis/Dockerfile b/redis/Dockerfile deleted file mode 100644 index e14b225..0000000 --- a/redis/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -# -# Redis Dockerfile -# -# https://github.com/dockerfile/redis -# - -# Pull base image -FROM dockerfile/ubuntu - -# Install Redis -RUN \ - cd /tmp && \ - wget http://download.redis.io/redis-stable.tar.gz && \ - tar xvzf redis-stable.tar.gz && \ - cd redis-stable && \ - make && \ - make install && \ - cp -f src/redis-sentinel /usr/local/bin && \ - mkdir -p /etc/redis && \ - cp -f *.conf /etc/redis && \ - rm -rf /tmp/redis-stable* && \ - sed -i 's/^\(bind .*\)$/# \1/' /etc/redis/redis.conf && \ - sed -i 's/^\(daemonize .*\)$/# \1/' /etc/redis/redis.conf && \ - sed -i 's/^\(dir .*\)$/# \1\ndir \/data/' /etc/redis/redis.conf && \ - sed -i 's/^\(logfile .*\)$/# \1/' /etc/redis/redis.conf - -# Define mountable directories. -VOLUME ["/data"] - -# Define working directory. -WORKDIR /data - -# Define default command. -ENTRYPOINT ["redis-server"] - -# Expose ports locally on VM -EXPOSE 6379 \ No newline at end of file diff --git a/test_tutum.yml b/test_tutum.yml deleted file mode 100644 index 5e45d4d..0000000 --- a/test_tutum.yml +++ /dev/null @@ -1,32 +0,0 @@ -lb: - image: tutum/haproxy - autorestart: always - ports: - - "80:80" - roles: - - global - links: - - "web:web" - tags: - - staging - - lb - environment: - BACKEND_PORT: 3000 - -web: - image: mjhea0/node-docker-workflow - autorestart: always - links: - - "redis:redis" - deployment_strategy: high_availability - tags: - - staging - - web - target_num_containers: 4 - -redis: - image: redis - tags: - - staging - - cache - autorestart: always \ No newline at end of file diff --git a/tutum.yml b/tutum.yml deleted file mode 100644 index 4bb3648..0000000 --- a/tutum.yml +++ /dev/null @@ -1,12 +0,0 @@ -web: - image: mjhea0/node-docker-workflow - autorestart: always - ports: - - "80:3000" - links: - - "redis:redis" -redis: - image: redis - autorestart: always - ports: - - "6379:6379" \ No newline at end of file