summaryrefslogtreecommitdiffstats
path: root/installer/roles/local_docker/templates/docker-compose.yml.j2
blob: a6cf121593626bc1136c3881d38bf68cb636ea31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#jinja2: lstrip_blocks: True
version: '2'
services:

  web:
    image: {{ awx_docker_actual_image }}
    container_name: awx_web
    depends_on:
      - redis
      - memcached
      {% if pg_hostname is not defined %}
      - postgres
      {% endif %}
    {% if (host_port is defined) or (host_port_ssl is defined) %}
    ports:
      {% if (host_port_ssl is defined) and (ssl_certificate is defined) %}
      - "{{ host_port_ssl }}:8053"
      {% endif %}
      {% if host_port is defined %}
      - "{{ host_port }}:8052"
      {% endif %}
    {% endif %}
    hostname: {{ awx_web_hostname }}
    user: root
    restart: unless-stopped
    volumes:
      - supervisor-socket:/var/run/supervisor
      - rsyslog-socket:/var/run/awx-rsyslog/
      - rsyslog-config:/var/lib/awx/rsyslog/
      - "{{ docker_compose_dir }}/SECRET_KEY:/etc/tower/SECRET_KEY"
      - "{{ docker_compose_dir }}/environment.sh:/etc/tower/conf.d/environment.sh"
      - "{{ docker_compose_dir }}/credentials.py:/etc/tower/conf.d/credentials.py"
      - "{{ docker_compose_dir }}/nginx.conf:/etc/nginx/nginx.conf:ro"
      - "{{ docker_compose_dir }}/redis_socket:/var/run/redis/:rw"
      - "{{ docker_compose_dir }}/memcached_socket:/var/run/memcached/:rw"
    {% if project_data_dir is defined %}
      - "{{ project_data_dir +':/var/lib/awx/projects:rw' }}"
    {% endif %}
    {% if custom_venv_dir is defined %}
      - "{{ custom_venv_dir +':'+ custom_venv_dir +':rw' }}"
    {% endif %}
    {% if ca_trust_dir is defined %}
      - "{{ ca_trust_dir +':/etc/pki/ca-trust/source/anchors:ro' }}"
    {% endif %}
    {% if (ssl_certificate is defined) and (ssl_certificate_key is defined) %}
      - "{{ ssl_certificate +':/etc/nginx/awxweb.pem:ro' }}"
      - "{{ ssl_certificate_key +':/etc/nginx/awxweb_key.pem:ro' }}"
    {% elif (ssl_certificate is defined) and (ssl_certificate_key is not defined) %}
      - "{{ ssl_certificate +':/etc/nginx/awxweb.pem:ro' }}"
    {% endif %}
    {% if (awx_container_search_domains is defined) and (',' in awx_container_search_domains) %}
    {% set awx_container_search_domains_list = awx_container_search_domains.split(',') %}
    dns_search:
    {% for awx_container_search_domain in awx_container_search_domains_list %}
      - {{ awx_container_search_domain }}
    {% endfor %}
    {% elif awx_container_search_domains is defined %}
    dns_search: "{{ awx_container_search_domains }}"
    {% endif %}
    {% if (awx_alternate_dns_servers is defined) and (',' in awx_alternate_dns_servers) %}
    {% set awx_alternate_dns_servers_list = awx_alternate_dns_servers.split(',') %}
    dns:
    {% for awx_alternate_dns_server in awx_alternate_dns_servers_list %}
      - {{ awx_alternate_dns_server }}
    {% endfor %}
    {% elif awx_alternate_dns_servers is defined %}
    dns: "{{ awx_alternate_dns_servers }}"
    {% endif %}
    environment:
      http_proxy: {{ http_proxy | default('') }}
      https_proxy: {{ https_proxy | default('') }}
      no_proxy: {{ no_proxy | default('') }}

  task:
    image: {{ awx_docker_actual_image }}
    container_name: awx_task
    depends_on:
      - redis
      - memcached
      - web
      {% if pg_hostname is not defined %}
      - postgres
      {% endif %}
    command: /usr/bin/launch_awx_task.sh
    hostname: {{ awx_task_hostname }}
    user: root
    restart: unless-stopped
    volumes:
      - supervisor-socket:/var/run/supervisor
      - rsyslog-socket:/var/run/awx-rsyslog/
      - rsyslog-config:/var/lib/awx/rsyslog/
      - "{{ docker_compose_dir }}/SECRET_KEY:/etc/tower/SECRET_KEY"
      - "{{ docker_compose_dir }}/environment.sh:/etc/tower/conf.d/environment.sh"
      - "{{ docker_compose_dir }}/credentials.py:/etc/tower/conf.d/credentials.py"
      - "{{ docker_compose_dir }}/redis_socket:/var/run/redis/:rw"
      - "{{ docker_compose_dir }}/memcached_socket:/var/run/memcached/:rw"
    {% if project_data_dir is defined %}
      - "{{ project_data_dir +':/var/lib/awx/projects:rw' }}"
    {% endif %}
    {% if custom_venv_dir is defined %}
      - "{{ custom_venv_dir +':'+ custom_venv_dir +':rw' }}"
    {% endif %}
    {% if ca_trust_dir is defined %}
      - "{{ ca_trust_dir +':/etc/pki/ca-trust/source/anchors:ro' }}"
    {% endif %}
    {% if ssl_certificate is defined %}
      - "{{ ssl_certificate +':/etc/nginx/awxweb.pem:ro' }}"
    {% endif %}
    {% if (awx_container_search_domains is defined) and (',' in awx_container_search_domains) %}
    {% set awx_container_search_domains_list = awx_container_search_domains.split(',') %}
    dns_search:
    {% for awx_container_search_domain in awx_container_search_domains_list %}
      - {{ awx_container_search_domain }}
    {% endfor %}
    {% elif awx_container_search_domains is defined %}
    dns_search: "{{ awx_container_search_domains }}"
    {% endif %}
    {% if (awx_alternate_dns_servers is defined) and (',' in awx_alternate_dns_servers) %}
    {% set awx_alternate_dns_servers_list = awx_alternate_dns_servers.split(',') %}
    dns:
    {% for awx_alternate_dns_server in awx_alternate_dns_servers_list %}
      - {{ awx_alternate_dns_server }}
    {% endfor %}
    {% elif awx_alternate_dns_servers is defined %}
    dns: "{{ awx_alternate_dns_servers }}"
    {% endif %}
    environment:
      http_proxy: {{ http_proxy | default('') }}
      https_proxy: {{ https_proxy | default('') }}
      no_proxy: {{ no_proxy | default('') }}
      SUPERVISOR_WEB_CONFIG_PATH: '/etc/supervisord.conf'

  redis:
    image: {{ redis_image }}
    container_name: awx_redis
    restart: unless-stopped
    environment:
      http_proxy: {{ http_proxy | default('') }}
      https_proxy: {{ https_proxy | default('') }}
      no_proxy: {{ no_proxy | default('') }}
    command: ["/usr/local/etc/redis/redis.conf"]
    volumes:
      - "{{ docker_compose_dir }}/redis.conf:/usr/local/etc/redis/redis.conf:ro"
      - "{{ docker_compose_dir }}/redis_socket:/var/run/redis/:rw"
      - "{{ docker_compose_dir }}/memcached_socket:/var/run/memcached/:rw"

  memcached:
    image: "{{ memcached_image }}:{{ memcached_version }}"
    container_name: awx_memcached
    command: ["-s", "/var/run/memcached/memcached.sock", "-a", "0666"]
    restart: unless-stopped
    environment:
      http_proxy: {{ http_proxy | default('') }}
      https_proxy: {{ https_proxy | default('') }}
      no_proxy: {{ no_proxy | default('') }}
    volumes:
      - "{{ docker_compose_dir }}/memcached_socket:/var/run/memcached/:rw"

  {% if pg_hostname is not defined %}
  postgres:
    image: {{ postgresql_image }}
    container_name: awx_postgres
    restart: unless-stopped
    volumes:
      - {{ postgres_data_dir }}/10/data/:/var/lib/postgresql/data/pgdata:Z
    environment:
      POSTGRES_USER: {{ pg_username }}
      POSTGRES_PASSWORD: {{ pg_password }}
      POSTGRES_DB: {{ pg_database }}
      PGDATA: /var/lib/postgresql/data/pgdata
      http_proxy: {{ http_proxy | default('') }}
      https_proxy: {{ https_proxy | default('') }}
      no_proxy: {{ no_proxy | default('') }}
  {% endif %}

{% if docker_compose_subnet is defined %}
networks:
  default:
    driver: bridge
    ipam:
      driver: default
      config:
      - subnet:  {{ docker_compose_subnet }}
{% endif %}

volumes:
  supervisor-socket:
  rsyslog-socket:
  rsyslog-config: