Skip to content

Instantly share code, notes, and snippets.

@chouseknecht
Created December 13, 2017 16:30
Show Gist options
  • Save chouseknecht/da350858d345a62cb4906e4bd8148fff to your computer and use it in GitHub Desktop.
Save chouseknecht/da350858d345a62cb4906e4bd8148fff to your computer and use it in GitHub Desktop.
A complex Ansible Container config file
version: '2'
settings:
conductor:
base: centos:7
volumes:
- ${PWD}/static:/static:rw
project_name: funnels
defaults:
django_port: 8000
ng_port: 4200
webhook_url: 'http://localhost:4200'
cloudsql_key: ''
postgresql_default_password: ''
postgres_db: 'chat'
postgres_host: 'postgres'
postgres_port: '5432'
postgres_connection_name: ''
postgres_user: 'funnels'
postgres_password: 'funnels'
services:
django:
containers:
- container_name: server
from: centos:7
roles:
- role: django
user: django
group: django
os_packages:
- https://centos7.iuscommunity.org/ius-release.rpm
allowed_hosts:
- '*'
expose:
- '{{ django_port }}'
user: django
working_dir: /funnels/chat
command: [/usr/bin/dumb-init, /venv/bin/gunicorn, -w, '2', chat.wsgi:application, --bind, 0.0.0.0:8000,
--access-logfile, -, --error-logfile, -, --log-level, debug]
entrypoint: [/usr/bin/entrypoint.sh]
environment:
DJANGO_LOG_LEVEL: INFO
POSTGRES_DB: '{{ postgres_db }}'
POSTGRES_HOST: '{{ postgres_host }}'
POSTGRES_PORT: '{{ postgres_port }}'
dev_overrides:
links:
- postgres
volumes:
- ${PWD}:/funnels:rw
command: [/usr/bin/dumb-init, /venv/bin/python, manage.py, runserver, '0.0.0.0:{{ django_port }}']
depends_on:
- postgres
environment:
DEBUG: 'True'
DJANGO_LOG_LEVEL: DEBUG
POSTGRES_DB: '{{ postgres_db }}'
POSTGRES_HOST: '{{ postgres_host }}'
POSTGRES_PORT: '{{ postgres_port }}'
secrets:
postgres:
docker:
- postgres_user
- postgres_password
k8s:
- mount_path: '/run/secrets/postgres'
read_only: true
- container_name: db-proxy
from: gcr.io/cloudsql-docker/gce-proxy:1.09
command:
- '/cloud_sql_proxy'
- '--dir=/cloudsql'
- '-instances={{ postgres_connection_name }}=tcp:{{ postgres_port }}'
- '-credential_file=/run/secrets/cloudsql/instance_credentials'
dev_overrides:
command:
- /bin/true
secrets:
cloudsql:
k8s:
- mount_path: '/run/secrets/cloudsql'
read_only: false
ng:
from: centos:7
roles:
- role: ng
user: ng
group: ng
os_packages: []
- role: ng-build
command: [/bin/true]
entrypoint: [/usr/bin/entrypoint.sh]
working_dir: /funnels
volumes:
- ${PWD}:/funnels:rw
ports:
- '{{ ng_port }}:{{ ng_port }}'
links:
- django-server:django
dev_overrides:
working_dir: /funnels/chatjs
command: [/usr/bin/dumb-init, /usr/bin/ng, serve, --host, '0.0.0.0', --poll, '5000', --watch, --proxy-config, proxy.conf.js]
k8s:
state: absent
nginx:
roles:
- role: nginx
ASSET_PATHS:
- /src/chatjs/dist
- /static
PROXY: yes
PROXY_PASS: http://django:8000
PROXY_LOCATION: '~* ^/(api|admin|auth)'
links:
- django-server:django
dev_overrides:
command: [/bin/true]
k8s:
service:
type: NodePort
postgres:
from: postgres:latest
command:
- /bin/true
dev_overrides:
expose:
- 5432
command: [postgres]
environment:
POSTGRES_DB: '{{ postgres_db }}'
POSTGRES_USER: '{{ postgres_user }}'
POSTGRES_PASSWORD: '{{ postgres_password }}'
k8s:
state: absent
registries:
staging:
url: us.gcr.io
namespace: funnels-175910
secrets:
cloudsql:
instance_credentials: cloudsql_key
postgres:
user: postgres_user
password: postgres_password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment