-
Notifications
You must be signed in to change notification settings - Fork 2
/
deploy-app.yml
64 lines (55 loc) · 1.98 KB
/
deploy-app.yml
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
---
# Archive Docker Image
- name: Extract Docker Image
hosts: localhost
tasks:
- name: Archive docker image
docker_image:
name: "digital-sky-app-prod"
tag: "1.0"
archive_path: "/tmp/digital-sky-app-prod-1.0-di.tar"
when: archive_docker_image
# Deploy API service
- name: Deploy server
hosts: digital_sky_app_hosts
user: "core"
gather_facts: True
tasks:
- name: Create service directory
file:
path: "{{services_root_directory}}/{{app_service_name}}"
state: directory
mode: 0755
- name: Copy image to server
copy:
src: "/tmp/{{app_image_name}}-{{app_artifact_version}}-di.tar"
dest: "{{services_root_directory}}/{{app_service_name}}/{{app_image_name}}-{{app_artifact_version}}-di.tar"
when: archive_docker_image
- name: Load image from archive
docker_image:
name: "{{app_image_name}}"
tag: "{{app_artifact_version}}"
load_path: "{{services_root_directory}}/{{app_service_name}}/{{app_image_name}}-{{app_artifact_version}}-di.tar"
when: archive_docker_image
- name: Remove image archive
file:
path: "{{services_root_directory}}/{{app_service_name}}/{{app_image_name}}-{{app_artifact_version}}-di.tar"
state: absent
when: archive_docker_image
- name: Resolve env properties
template:
src: "{{app_service_name}}-env-properties.j2"
dest: "{{services_root_directory}}/{{app_service_name}}/env-properties.txt"
mode: 0644
force: yes
- name: Re-create service container
docker_container:
name: "{{app_service_name}}"
image: "{{app_image_name}}:{{app_artifact_version}}"
env_file: "{{services_root_directory}}/{{app_service_name}}/env-properties.txt"
state: started
recreate: yes
volumes:
- "{{certs_root_directory}}:/etc/nginx/certs"
published_ports:
- "{{app_service_host_port}}:{{app_service_container_port}}"