├── LICENSE ├── README.md ├── docker-compose.yml ├── docker-compose.yml-bkp ├── vote-app ├── web-py ├── Dockerfile ├── app.py └── requirements.txt └── web ├── Dockerfile ├── app.py └── requirements.txt /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Datadog, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # exemplo-docker-compose 2 | Repositório de exemplo 3 | 4 | Para utilização: 5 | 6 | git clone https://github.com/mundodocker/exemplo-docker-compose 7 | 8 | docker-compose up 9 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | 5 | mysql: 6 | image: mysql 7 | networks: 8 | - interna 9 | environment: 10 | - MYSQL_ROOT_PASSWORD=senha 11 | - MYSQL_DATABASE=wordpress 12 | 13 | wordpress: 14 | image: wordpress 15 | ports: 16 | - 80:80 17 | networks: 18 | - interna 19 | depends_on: 20 | - mysql 21 | deploy: 22 | mode: replicated 23 | replicas: 1 24 | environment: 25 | - WORDPRESS_DB_HOST=mysql:3306 26 | - WORDPRESS_DB_PASSWORD=senha 27 | - WORDPRESS_DB_USER=root 28 | 29 | networks: 30 | interna: 31 | -------------------------------------------------------------------------------- /docker-compose.yml-bkp: -------------------------------------------------------------------------------- 1 | version: "2" 2 | services: 3 | web: 4 | build: web 5 | command: python app.py 6 | ports: 7 | - "5000:5000" 8 | volumes: 9 | - ./web:/code 10 | links: 11 | - redis 12 | environment: 13 | - DATADOG_HOST=datadog 14 | redis: 15 | image: redis 16 | -------------------------------------------------------------------------------- /vote-app: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | 5 | redis: 6 | image: redis:3.2-alpine 7 | ports: 8 | - "6379" 9 | networks: 10 | - voteapp 11 | deploy: 12 | placement: 13 | constraints: [node.role == manager] 14 | 15 | db: 16 | image: postgres:9.4 17 | volumes: 18 | - db-data:/var/lib/postgresql/data 19 | networks: 20 | - voteapp 21 | deploy: 22 | placement: 23 | constraints: [node.role == manager] 24 | 25 | voting-app: 26 | image: gaiadocker/example-voting-app-vote:good 27 | ports: 28 | - 5000:80 29 | networks: 30 | - voteapp 31 | depends_on: 32 | - redis 33 | deploy: 34 | mode: replicated 35 | replicas: 2 36 | labels: [APP=VOTING] 37 | placement: 38 | constraints: [node.role == worker] 39 | 40 | result-app: 41 | image: gaiadocker/example-voting-app-result:latest 42 | ports: 43 | - 5001:80 44 | networks: 45 | - voteapp 46 | depends_on: 47 | - db 48 | 49 | worker: 50 | image: gaiadocker/example-voting-app-worker:latest 51 | networks: 52 | voteapp: 53 | aliases: 54 | - workers 55 | depends_on: 56 | - db 57 | - redis 58 | deploy: 59 | mode: replicated 60 | replicas: 2 61 | labels: [APP=VOTING] 62 | resources: 63 | limits: 64 | cpus: '0.25' 65 | memory: 512M 66 | reservations: 67 | cpus: '0.25' 68 | memory: 256M 69 | restart_policy: 70 | condition: on-failure 71 | delay: 5s 72 | max_attempts: 3 73 | window: 120s 74 | update_config: 75 | parallelism: 1 76 | delay: 10s 77 | failure_action: continue 78 | monitor: 60s 79 | max_failure_ratio: 0.3 80 | placement: 81 | constraints: [node.role == worker] 82 | 83 | networks: 84 | voteapp: 85 | 86 | volumes: 87 | db-data: 88 | -------------------------------------------------------------------------------- /web-py/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:latest 2 | MAINTAINER Rajdeep Dua "dua_rajdeep@yahoo.com" 3 | RUN apt-get update -y 4 | RUN apt-get install -y python-pip python-dev build-essential 5 | COPY . /app 6 | WORKDIR /app 7 | RUN pip install -r requirements.txt 8 | ENTRYPOINT ["python"] 9 | CMD ["app.py"] 10 | -------------------------------------------------------------------------------- /web-py/app.py: -------------------------------------------------------------------------------- 1 | From flask import Flask 2 | app = Flask(__name__) 3 | 4 | @app.route('/') 5 | def hello_world(): 6 | return 'Flask Dockerized' 7 | 8 | if __name__ == '__main__': 9 | app.run(debug=True,host='0.0.0.0') 10 | -------------------------------------------------------------------------------- /web-py/requirements.txt: -------------------------------------------------------------------------------- 1 | Flask==0.12.3 2 | -------------------------------------------------------------------------------- /web/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:2.7 2 | ADD . /code 3 | WORKDIR /code 4 | RUN pip install -r requirements.txt 5 | -------------------------------------------------------------------------------- /web/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask 2 | from redis import Redis 3 | import os 4 | 5 | # Add and initialize Datadog monitoring. 6 | from datadog import initialize, statsd 7 | initialize(statsd_host=os.environ.get('DATADOG_HOST')) 8 | 9 | 10 | app = Flask(__name__) 11 | redis = Redis(host='redis', port=6379) 12 | 13 | @app.route('/') 14 | def hello(): 15 | # Increment the Datadog counter. 16 | statsd.increment('docker_compose_example.page.views') 17 | 18 | redis.incr('hits') 19 | return 'Ola! Este Site foi acessado %s vezes.' % redis.get('hits') 20 | 21 | if __name__ == "__main__": 22 | app.run(host="0.0.0.0", debug=True) 23 | -------------------------------------------------------------------------------- /web/requirements.txt: -------------------------------------------------------------------------------- 1 | flask 2 | redis 3 | datadog 4 | --------------------------------------------------------------------------------