├── README.md ├── identijenk ├── plugins.txt ├── jenkins.yml ├── Dockerfile └── jenkins_shell ├── identidock ├── README.md ├── docker-compose.yml ├── Dockerfile ├── cmd.sh └── app │ ├── tests.py │ └── identidock.py └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | # Using Docker Code Examples 2 | ## "Continuous Integration and Testing with Docker" 3 | -------------------------------------------------------------------------------- /identijenk/plugins.txt: -------------------------------------------------------------------------------- 1 | scm-api:0.2 2 | git-client:1.16.1 3 | git:2.3.5 4 | greenballs:1.14 5 | -------------------------------------------------------------------------------- /identidock/README.md: -------------------------------------------------------------------------------- 1 | identidock 2 | ========== 3 | 4 | Simple identicon server based on monsterid from Kevin Gaudin. 5 | 6 | From "Using Docker" by Adrian Mouat published by O'Reilly media. 7 | -------------------------------------------------------------------------------- /identijenk/jenkins.yml: -------------------------------------------------------------------------------- 1 | identidock: 2 | build: . 3 | expose: 4 | - "9090" 5 | environment: 6 | ENV: PROD 7 | links: 8 | - dnmonster 9 | - redis 10 | 11 | dnmonster: 12 | image: amouat/dnmonster:1.0 13 | 14 | redis: 15 | image: redis:3.0 16 | -------------------------------------------------------------------------------- /identidock/docker-compose.yml: -------------------------------------------------------------------------------- 1 | identidock: 2 | build: . 3 | ports: 4 | - "5000:5000" 5 | environment: 6 | ENV: DEV 7 | volumes: 8 | - ./app:/app 9 | links: 10 | - dnmonster 11 | - redis 12 | 13 | dnmonster: 14 | image: amouat/dnmonster:1.0 15 | 16 | redis: 17 | image: redis:3.0 18 | -------------------------------------------------------------------------------- /identidock/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.4 2 | 3 | FROM python:3.4 4 | 5 | RUN groupadd -r uwsgi && useradd -r -g uwsgi uwsgi 6 | RUN pip install Flask==0.10.1 uWSGI==2.0.8 requests==2.5.1 redis==2.10.3 7 | WORKDIR /app 8 | COPY app /app 9 | COPY cmd.sh / 10 | 11 | EXPOSE 9090 9191 12 | USER uwsgi 13 | 14 | CMD ["/cmd.sh"] 15 | -------------------------------------------------------------------------------- /identidock/cmd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [ "$ENV" = 'DEV' ]; then 5 | echo "Running Development Server" 6 | exec python "identidock.py" 7 | elif [ "$ENV" = 'UNIT' ]; then 8 | echo "Running Unit Tests" 9 | exec python "tests.py" 10 | else 11 | echo "Running Production Server" 12 | exec uwsgi --http 0.0.0.0:9090 --wsgi-file /app/identidock.py \ 13 | --callable app --stats 0.0.0.0:9191 14 | fi 15 | -------------------------------------------------------------------------------- /identidock/app/tests.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import identidock 3 | 4 | 5 | class TestCase(unittest.TestCase): 6 | 7 | def setUp(self): 8 | identidock.app.config["TESTING"] = True 9 | self.app = identidock.app.test_client() 10 | 11 | def test_get_mainpage(self): 12 | page = self.app.post("/", data=dict(name="Moby Dock")) 13 | assert page.status_code == 200 14 | assert 'Hello' in str(page.data) 15 | assert 'Moby Dock' in str(page.data) 16 | 17 | def test_html_escaping(self): 18 | page = self.app.post("/", data=dict(name='">TEST