This repository was archived by the owner on Dec 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdeploy-prod.yml
More file actions
56 lines (49 loc) · 1.58 KB
/
Copy pathdeploy-prod.yml
File metadata and controls
56 lines (49 loc) · 1.58 KB
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
---
- name: Deploy application to production
hosts: all
become: true
vars:
app_directory: /easydeploy
docker_compose_file: compose.yml
services:
- backend
- runner
- web_app
tasks:
- name: Ensure app directory exists
file:
path: "{{ app_directory }}"
state: directory
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: '0755'
- name: Copy project files to server
synchronize:
src: ./
dest: "{{ app_directory }}"
rsync_opts:
- "--exclude=node_modules"
- "--exclude=.git"
- name: Install Docker if not present
apt:
name: docker.io
state: present
update_cache: yes
- name: Install Docker Compose if not present
get_url:
url: https://github.com/docker/compose/releases/download/v2.32.1/docker-compose-linux-x86_64
dest: /usr/local/bin/docker-compose
mode: '0755'
when: not ansible_facts['cmdline']['docker-compose']
- name: Stop Running Docker Compose Services if any
command: docker compose -f "{{ app_directory }}/{{ docker_compose_file }}" down
args:
chdir: "{{ app_directory }}"
- name: Start services with Docker Compose
command: docker compose -f "{{ app_directory }}/{{ docker_compose_file }}" up -d --remove-orphans
args:
chdir: "{{ app_directory }}"
- name: Ensure all services are running
command: docker compose -f "{{ app_directory }}/{{ docker_compose_file }}" ps
args:
chdir: "{{ app_directory }}"