feat: container registry deploy (build in CI, pull on server)
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
[defaults]
|
||||
inventory = inventory/hosts.yml
|
||||
host_key_checking = False
|
||||
remote_user = root
|
||||
private_key_file = ~/.ssh/id_rsa
|
||||
interpreter_python = /usr/bin/python3
|
||||
stdout_callback = yaml
|
||||
@@ -0,0 +1,10 @@
|
||||
all:
|
||||
hosts:
|
||||
prod:
|
||||
ansible_host: <SERVER_IP>
|
||||
ansible_user: root
|
||||
ansible_port: 22
|
||||
vars:
|
||||
registry: gitea.d3m0k1d.ru
|
||||
registry_user: <REGISTRY_USER>
|
||||
registry_password: <REGISTRY_PASSWORD>
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
- name: Deploy Frontend
|
||||
hosts: prod
|
||||
vars:
|
||||
deploy_path: /opt/app
|
||||
|
||||
tasks:
|
||||
- name: Ensure deployment directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ deploy_path }}"
|
||||
state: directory
|
||||
|
||||
- name: Copy docker-compose
|
||||
ansible.builtin.copy:
|
||||
src: "{{ playbook_dir }}/../docker-compose.yml"
|
||||
dest: "{{ deploy_path }}/docker-compose.yml"
|
||||
|
||||
- name: Login to registry
|
||||
ansible.builtin.shell:
|
||||
cmd: echo "{{ registry_password }}" | docker login "{{ registry }}" -u "{{ registry_user }}" --password-stdin
|
||||
|
||||
- name: Pull images
|
||||
ansible.builtin.shell:
|
||||
cmd: docker compose pull
|
||||
chdir: "{{ deploy_path }}"
|
||||
environment:
|
||||
REGISTRY: "{{ registry }}"
|
||||
TAG: "{{ tag }}"
|
||||
|
||||
- name: Restart services
|
||||
ansible.builtin.shell:
|
||||
cmd: docker compose up -d --remove-orphans
|
||||
chdir: "{{ deploy_path }}"
|
||||
environment:
|
||||
REGISTRY: "{{ registry }}"
|
||||
TAG: "{{ tag }}"
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
roles: []
|
||||
|
||||
collections: []
|
||||
@@ -1,7 +1,5 @@
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: dockerfile
|
||||
image: ${REGISTRY}/hellreign/frontend:${TAG}
|
||||
ports:
|
||||
- "80:80"
|
||||
|
||||
Reference in New Issue
Block a user