saltstack-magento-example/salt/srv/salt/base/php-fpm-docker/init.sls

53 lines
1.4 KiB
Plaintext

Copy Dockerfile:
file.managed:
- name: /storage/php-fpm-docker/Dockerfile
- source: salt://php-fpm-docker/files/Dockerfile
- makedirs: True
Build php-fpm-docker:
docker_image.present:
- name: php-fpm-docker
- build: /storage/php-fpm-docker
- tag: latest
Remove Dockerfile from /srv:
file.absent:
- name: /storage/php-fpm-docker
{% for vhost, config in pillar["vhosts"].items() %}
Copy php-fpm configuration for {{ vhost }}:
file.managed:
- name: /usr/local/etc/vhost-conf/{{ vhost }}/php.conf
- source: salt://php-fpm-docker/files/www.conf
- template: jinja
- vhost: {{ vhost }}
- php_max_children: {{ config.php_max_children }}
- makedirs: True
Prepare webroot volume for {{ vhost }}:
docker_volume.present:
- name: webroot-{{ vhost }}
- driver: local
Run php-fpm container for {{ vhost }}:
docker_container.running:
- name: php-fpm-{{ vhost }}
- image: php-fpm-docker
- start: True
- restart: always
- networks:
- network-{{ vhost }}
- binds:
- webroot-{{ vhost }}:/app:rw,Z
- /usr/local/etc/vhost-conf/{{ vhost }}/php.conf:/usr/local/etc/php-fpm.d/www.conf:ro
Fix permissions on the directory for {{ vhost }}:
file.directory:
- name: /var/lib/docker/volumes/webroot-{{ vhost }}/_data
- user: 33
- group: 33
- mode: 755 # will not recurse mode as stated below
- recurse:
- user
- group
{% endfor %}