Added google tag

Added ansible
Added deploy.sh
This commit is contained in:
2025-10-04 14:53:45 +00:00
parent 67411b3972
commit 7b1ee49d11
10 changed files with 130 additions and 0 deletions

2
ansible/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
app/package.json
app/pyproject.toml

14
ansible/playbook.yml Executable file
View File

@ -0,0 +1,14 @@
#################################################
# DO Community Playbooks: Docker
#################################################
---
- hosts: monoco
become: true
vars_files:
- vars/default.yml
roles:
- upload
- network
- mozimo
- caddy

View 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"

View 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"

View 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 }}"

View File

@ -0,0 +1,8 @@
---
- name: Ensure 'mozimo' Docker network exists
docker_network:
name: "{{ docker_network }}"
state: present
connected:
- name: caddy
appends: yes

View 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
View 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
View 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

View File

@ -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" />