Added google tag
Added ansible Added deploy.sh
This commit is contained in:
2
ansible/.gitignore
vendored
Normal file
2
ansible/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
app/package.json
|
||||
app/pyproject.toml
|
||||
14
ansible/playbook.yml
Executable file
14
ansible/playbook.yml
Executable file
@ -0,0 +1,14 @@
|
||||
#################################################
|
||||
# DO Community Playbooks: Docker
|
||||
#################################################
|
||||
---
|
||||
- hosts: monoco
|
||||
become: true
|
||||
vars_files:
|
||||
- vars/default.yml
|
||||
|
||||
roles:
|
||||
- upload
|
||||
- network
|
||||
- mozimo
|
||||
- caddy
|
||||
5
ansible/roles/caddy/handlers/main.yaml
Normal file
5
ansible/roles/caddy/handlers/main.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
# Handlers for Caddy role
|
||||
- name: Reload Caddy configuration
|
||||
ansible.builtin.command: "docker exec -w /etc/caddy {{ caddy_container }} caddy reload"
|
||||
listen: "Reload Caddy"
|
||||
29
ansible/roles/caddy/tasks/main.yaml
Normal file
29
ansible/roles/caddy/tasks/main.yaml
Normal file
@ -0,0 +1,29 @@
|
||||
---
|
||||
- name: Read current Caddyfile
|
||||
ansible.builtin.slurp:
|
||||
path: "{{ caddyfile_path }}"
|
||||
register: caddyfile_raw
|
||||
|
||||
- name: Decode Caddyfile content
|
||||
set_fact:
|
||||
caddyfile_content: "{{ caddyfile_raw['content'] | b64decode }}"
|
||||
|
||||
- name: Build snippet block from variables
|
||||
set_fact:
|
||||
snippet_block: |
|
||||
{{ host }} {
|
||||
reverse_proxy {{ docker_container }}:{{ docker_port }}
|
||||
}
|
||||
|
||||
- name: Check if snippet already exists
|
||||
set_fact:
|
||||
snippet_present: "{{ snippet_block in caddyfile_content }}"
|
||||
|
||||
- name: Add snippet if missing
|
||||
ansible.builtin.blockinfile:
|
||||
path: "{{ caddyfile_path }}"
|
||||
marker: "# {mark} Ansible managed Caddy snippet for {{ host }}"
|
||||
block: "{{ snippet_block }}"
|
||||
create: yes
|
||||
when: not snippet_present
|
||||
notify: "Reload Caddy"
|
||||
24
ansible/roles/mozimo/tasks/main.yaml
Normal file
24
ansible/roles/mozimo/tasks/main.yaml
Normal file
@ -0,0 +1,24 @@
|
||||
---
|
||||
# Tasks for docker role
|
||||
- name: Log in to Docker registry
|
||||
docker_login:
|
||||
registry: "{{ registry }}"
|
||||
username: "{{ username }}"
|
||||
password: "{{ password }}"
|
||||
|
||||
- name: Pull Mozimo image
|
||||
docker_image:
|
||||
name: "{{ docker_image }}"
|
||||
source: pull
|
||||
state: present
|
||||
force_source: yes
|
||||
|
||||
- name: Create Mozimo container
|
||||
docker_container:
|
||||
name: "{{ docker_container }}"
|
||||
image: "{{ docker_image }}"
|
||||
state: started
|
||||
restart_policy: "unless-stopped"
|
||||
env_file: "{{ host_directory }}/.env"
|
||||
networks:
|
||||
- name: "{{ docker_network }}"
|
||||
8
ansible/roles/network/tasks/main.yaml
Normal file
8
ansible/roles/network/tasks/main.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: Ensure 'mozimo' Docker network exists
|
||||
docker_network:
|
||||
name: "{{ docker_network }}"
|
||||
state: present
|
||||
connected:
|
||||
- name: caddy
|
||||
appends: yes
|
||||
11
ansible/roles/upload/tasks/main.yaml
Normal file
11
ansible/roles/upload/tasks/main.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
# Tasks for upload role
|
||||
- name: Ensure Host Directory exists
|
||||
file:
|
||||
path: "{{ host_directory }}"
|
||||
state: directory
|
||||
|
||||
- name: Upload the .env file
|
||||
template:
|
||||
src: "files/.env"
|
||||
dest: "{{ host_directory }}/.env"
|
||||
23
ansible/vars/default.yml
Normal file
23
ansible/vars/default.yml
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
registry: registry.tanshu.com
|
||||
username: ta-registry
|
||||
password: ff28a01f00c0f39315d94cd9dcb1e554968dba25676a8ea5f2be34e96a9a099f
|
||||
|
||||
title: mozimo
|
||||
tag: latest
|
||||
|
||||
host_directory: "/var/lib/{{ title }}"
|
||||
|
||||
host: "www.mozimo.in"
|
||||
|
||||
docker_network: "{{ title }}_net"
|
||||
|
||||
docker_image: "{{ registry }}/{{ title }}:{{ tag }}"
|
||||
docker_container: "{{ title }}"
|
||||
docker_port: 3000
|
||||
|
||||
instagram_token: IGQWRQSUY4b3RQWU9ZARHlVVUFDaWxJZAWFOUVllM0NxMk1zSHJ5X2JGc2dpRUxyTjBaeDNhUm0yaFZAQeUotVU9VUmFEQkJxU25CdFp3bURSZAGtnLXhCZAHVId21SWUNiNjVzc0pjZAlhPNDRxTDFzZAEQ0ZAXoyVlpUaHcZD
|
||||
|
||||
|
||||
caddy_container: caddy
|
||||
caddyfile_path: /var/lib/caddy/conf/Caddyfile
|
||||
13
deploy.sh
Executable file
13
deploy.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit ; pwd -P )
|
||||
cd "$parent_path" || exit
|
||||
if [ 1 -eq "$#" ]
|
||||
then
|
||||
make build-production TAG="$1"
|
||||
else
|
||||
make build-production
|
||||
fi
|
||||
|
||||
cd "$parent_path/ansible" || exit
|
||||
ansible-playbook playbook.yml
|
||||
@ -64,6 +64,7 @@ export default function RootLayout({
|
||||
<html lang="en">
|
||||
<head>
|
||||
{/* Mobile viewport meta tag */}
|
||||
<meta name="google-site-verification" content="vV-fEo3yXs8m0NUhB6JWhYI4pSH0uYVkbT8pgUWuU1I" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5, user-scalable=yes" />
|
||||
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
|
||||
Reference in New Issue
Block a user