Deployment added.
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
NODE_ENV=production
|
||||
PORT=3000
|
||||
HOST=0.0.0.0
|
||||
PB_DATA_DIR=/app/pb_data
|
||||
PB_ADMIN_EMAIL={{ pb_admin_email }}
|
||||
PB_ADMIN_PASSWORD={{ pb_admin_password }}
|
||||
@@ -0,0 +1,20 @@
|
||||
{{ host }}{% if apex_host is defined and apex_host %}, {{ apex_host }}{% endif %} {
|
||||
# PocketBase Admin UI and REST API
|
||||
handle /_/* {
|
||||
reverse_proxy {{ container_name }}:8090
|
||||
}
|
||||
handle /api/* {
|
||||
reverse_proxy {{ container_name }}:8090
|
||||
}
|
||||
|
||||
# TanStack Start Frontend Application
|
||||
handle {
|
||||
reverse_proxy {{ container_name }}:3000
|
||||
}
|
||||
}
|
||||
|
||||
{% if admin_host is defined and admin_host %}
|
||||
{{ admin_host }} {
|
||||
reverse_proxy {{ container_name }}:8090
|
||||
}
|
||||
{% endif %}
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
- name: Deploy Hops n Grains Microbrewery
|
||||
hosts: monoco
|
||||
become: true
|
||||
vars_files:
|
||||
- vars/default.yml
|
||||
|
||||
roles:
|
||||
- network
|
||||
- hops
|
||||
- caddy
|
||||
@@ -0,0 +1,3 @@
|
||||
---
|
||||
collections:
|
||||
- name: community.docker
|
||||
@@ -0,0 +1,3 @@
|
||||
---
|
||||
caddy_container: caddy
|
||||
caddy_caddyfile_path: /var/lib/caddy/conf/Caddyfile
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- name: Reload Caddy configuration
|
||||
ansible.builtin.command: "docker exec -w /etc/caddy {{ caddy_container }} caddy reload"
|
||||
listen: "Reload Caddy"
|
||||
changed_when: true
|
||||
@@ -0,0 +1,26 @@
|
||||
---
|
||||
- name: Read snippet from template file
|
||||
ansible.builtin.set_fact:
|
||||
caddy_snippet_block: "{{ lookup('template', 'files/Caddyfile.j2') }}"
|
||||
|
||||
- name: Read current Caddyfile
|
||||
ansible.builtin.slurp:
|
||||
path: "{{ caddy_caddyfile_path }}"
|
||||
register: caddy_caddyfile_raw
|
||||
|
||||
- name: Decode Caddyfile content
|
||||
ansible.builtin.set_fact:
|
||||
caddy_caddyfile_content: "{{ caddy_caddyfile_raw['content'] | b64decode }}"
|
||||
|
||||
- name: Check if snippet already exists
|
||||
ansible.builtin.set_fact:
|
||||
caddy_snippet_present: "{{ caddy_snippet_block in caddy_caddyfile_content }}"
|
||||
|
||||
- name: Add or update snippet in Caddyfile
|
||||
ansible.builtin.blockinfile:
|
||||
path: "{{ caddy_caddyfile_path }}"
|
||||
marker: "# {mark} Ansible managed Caddy snippet for {{ host }}"
|
||||
block: "{{ caddy_snippet_block }}"
|
||||
create: true
|
||||
mode: "0644"
|
||||
notify: Reload Caddy configuration
|
||||
@@ -0,0 +1,43 @@
|
||||
---
|
||||
- name: Log in to private Docker registry
|
||||
community.docker.docker_login:
|
||||
registry: "{{ registry }}"
|
||||
username: "{{ username }}"
|
||||
password: "{{ password }}"
|
||||
|
||||
- name: Pull Hops n Grains image
|
||||
community.docker.docker_image:
|
||||
name: "{{ image_name }}"
|
||||
source: pull
|
||||
state: present
|
||||
force_source: true
|
||||
|
||||
- name: Ensure Host Directory exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ host_data_path }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
|
||||
- name: Ensure PocketBase data directory exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ host_data_path }}/pb_data"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
|
||||
- name: Upload the .env file
|
||||
ansible.builtin.template:
|
||||
src: "files/.env"
|
||||
dest: "{{ host_data_path }}/.env"
|
||||
mode: "0600"
|
||||
|
||||
- name: Create and run Hops n Grains container
|
||||
community.docker.docker_container:
|
||||
name: "{{ container_name }}"
|
||||
image: "{{ image_name }}"
|
||||
state: started
|
||||
restart_policy: "unless-stopped"
|
||||
env_file: "{{ host_data_path }}/.env"
|
||||
volumes:
|
||||
- "{{ host_data_path }}/pb_data:/app/pb_data"
|
||||
networks:
|
||||
- name: "{{ docker_network }}"
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: Ensure Docker network exists
|
||||
community.docker.docker_network:
|
||||
name: "{{ docker_network }}"
|
||||
state: present
|
||||
connected:
|
||||
- "{{ caddy_container }}"
|
||||
appends: true
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
registry: registry.tanshu.com
|
||||
username: ta-registry
|
||||
password: ff28a01f00c0f39315d94cd9dcb1e554968dba25676a8ea5f2be34e96a9a099f
|
||||
|
||||
title: hops
|
||||
tag: latest
|
||||
|
||||
image_name: "{{ registry }}/hops:{{ tag }}"
|
||||
|
||||
app_name: hops
|
||||
host_directory: "{{ app_name }}"
|
||||
host_data_path: "/var/lib/{{ host_directory }}"
|
||||
container_name: "{{ app_name }}"
|
||||
docker_network: "{{ app_name }}_net"
|
||||
|
||||
# Public host for frontend & PocketBase routing
|
||||
host: www.hopsngrains.com
|
||||
apex_host: hopsngrains.com
|
||||
admin_host: admin.hopsngrains.com
|
||||
|
||||
# Caddy configuration
|
||||
caddy_container: caddy
|
||||
caddy_caddyfile_path: /var/lib/caddy/conf/Caddyfile
|
||||
|
||||
# PocketBase Initial Superuser Credentials
|
||||
pb_admin_email: admin@hopsngrains.com
|
||||
pb_admin_password: HopsPassword1234!
|
||||
Reference in New Issue
Block a user