Moved to Angular v20 and Tailwind v4 plus all related dependencies

Renamed Docker directory.

Also serving static files from FastAPI.
This commit is contained in:
2025-06-25 08:19:37 +00:00
parent 05b395af00
commit cb2b650375
253 changed files with 8626 additions and 1995 deletions

2
ansible/.gitignore vendored Normal file
View File

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

15
ansible/files/.env Normal file
View File

@ -0,0 +1,15 @@
TITLE={{ title }}
HOST=0.0.0.0
PORT=80
LOG_LEVEL=WARN
DEBUG=false
SQLALCHEMY_DATABASE_URI=postgresql+psycopg://postgres:123456@{{ db }}:5432/brewman_{{ name }}
MODULE_NAME=brewman.main
PROJECT_NAME=brewman
PUBLIC_KEY={{ public_key }}
PRIVATE_KEY={{ private_key }}
MIDDLEWARE_SECRET_KEY={{ middleware_key }}
ALGORITHM=EdDSA
JWT_TOKEN_EXPIRE_MINUTES=30
ALEMBIC_LOG_LEVEL=INFO
ALEMBIC_SQLALCHEMY_LOG_LEVEL=WARN

24
ansible/files/Caddyfile Normal file
View File

@ -0,0 +1,24 @@
{{ host }} {
# Match and proxy API routes
@apiRoutes {
path_regexp ^/(api|token|refresh|attendance-report|fingerprint-report|db-image)
}
handle @apiRoutes {
reverse_proxy @apiRoutes {{ host_directory }}:80
}
# Match requests that end with .js, .css, .ico, or .html
@staticFiles {
path_regexp \.(js|css|ico|html)$
}
handle @staticFiles {
rewrite * /static{uri}
reverse_proxy {{ host_directory }}:80
}
# All other frontend routes → /static/index.html
handle {
rewrite * /static/index.html
reverse_proxy {{ host_directory }}:80
}
}

37
ansible/files/keygen.sh Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
# File names
PRIVATE_KEY_FILE="ed25519-private.pem"
PUBLIC_KEY_FILE="ed25519-public.pem"
# Generate private key
openssl genpkey -algorithm Ed25519 -out "$PRIVATE_KEY_FILE"
if [ $? -ne 0 ]; then
echo "❌ Failed to generate private key"
exit 1
fi
# Extract public key
openssl pkey -in "$PRIVATE_KEY_FILE" -pubout -out "$PUBLIC_KEY_FILE"
if [ $? -ne 0 ]; then
echo "❌ Failed to extract public key"
exit 1
fi
# Function to convert PEM to one-liner with \n
format_pem_for_env() {
awk '{printf "%s\\n", $0}' "$1"
}
# Output .env formatted variables
echo "✅ Keys generated. Add the following to your .env file:"
echo ""
echo "PRIVATE_KEY=\"$(format_pem_for_env $PRIVATE_KEY_FILE)\""
echo ""
echo "PUBLIC_KEY=\"$(format_pem_for_env $PUBLIC_KEY_FILE)\""
echo ""
echo "ALGORITHM=EdDSA"
rm -f "$PRIVATE_KEY_FILE" "$PUBLIC_KEY_FILE"
echo "Temporary key files removed."
echo "Done."

15
ansible/hosts Normal file
View File

@ -0,0 +1,15 @@
# - Comments begin with the '#' character
# - Blank lines are ignored
# - Groups of hosts are delimited by [header] elements
# - You can enter hostnames or ip addresses
# - A hostname/ip can be a member of multiple groups
[brewman]
acc ansible_host=monoco var_file=vars/acc.yml
exp ansible_host=monoco var_file=vars/exp.yml
hops ansible_host=monoco var_file=vars/hops.yml
mhl ansible_host=monoco var_file=vars/mhl.yml
hinchco ansible_host=monoco var_file=vars/hinchco.yml
[all:vars]
ansible_python_interpreter=/usr/bin/python3

12
ansible/playbook.yml Executable file
View File

@ -0,0 +1,12 @@
#################################################
# DO Community Playbooks: Docker
#################################################
---
- hosts: brewman
become: true
vars_files:
- vars/default.yml
- "{{ var_file }}"
roles:
- brewman

View File

@ -0,0 +1,52 @@
---
# Tasks for docker role
- name: Log in to Docker registry
docker_login:
registry: "{{ registry }}"
username: "{{ username }}"
password: "{{ password }}"
- name: Pull Brewman image
docker_image:
name: "{{ image_name }}"
source: pull
state: present
force_source: yes
- name: Ensure Host Directory exists
file:
path: "/var/lib/{{ host_directory }}"
state: directory
- name: Upload the .env file
template:
src: "files/.env"
dest: "/var/lib/{{ host_directory }}/.env"
- name: Upload the Caddyfile template
template:
src: "files/Caddyfile"
dest: "/var/lib/{{ host_directory }}/Caddyfile"
- name: Create Docker network for Brewman
docker_network:
name: "brewman_{{ name }}_net"
state: present
- name: Create brewman container
docker_container:
name: "{{ host_directory }}"
image: "{{ image_name }}"
state: started
restart_policy: "unless-stopped"
env_file: "/var/lib/{{ host_directory }}/.env"
volumes:
- "/var/lib/{{ host_directory }}/frontend:/frontend"
- name: Connect DB container to Brewman network
docker_network:
name: "brewman_{{ name }}_net"
connected:
- "{{ db }}"
- "{{ proxy }}"
- "{{ host_directory }}"

12
ansible/vars/acc.yml Normal file
View File

@ -0,0 +1,12 @@
---
name: acc
title: "The Great Bear"
public_key: -----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAB+3c94GO2p6+cCOfaA1J0oQVbmZQieYaOqNbgHR70JM=\n-----END PUBLIC KEY-----
private_key: -----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEICdULYmhJhsQJPoCScBBYM+PdI0LrOu0jzOajvgZXElI\n-----END PRIVATE KEY-----
middleware_key: cb71666b9c
host: acc.hopsngrains.com
host_directory: "brewman-{{ name }}"
db_name: "brewman_{{ name }}"

9
ansible/vars/default.yml Normal file
View File

@ -0,0 +1,9 @@
---
registry: registry.tanshu.com
username: ta-registry
password: ff28a01f00c0f39315d94cd9dcb1e554968dba25676a8ea5f2be34e96a9a099f
tag: latest
image_name: "{{ registry }}/brewman:{{ tag }}"
db: postgres
proxy: caddy

11
ansible/vars/exp.yml Normal file
View File

@ -0,0 +1,11 @@
---
name: exp
title: Tanshu
public_key: -----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEABj/Hq4mOHC8fwTL+MJOr7HDFU+LmGfmQFOt90a+ZGtg=\n-----END PUBLIC KEY-----
private_key: -----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIGyEz6qjXMPtjWaYpacAyUewO7uBPWwmwDpGpZz8L2QX\n-----END PRIVATE KEY-----
middleware_key: da6fcd999b
host: exp.tanshu.com
host_directory: "brewman-{{ name }}"
db_name: "brewman_{{ name }}"

11
ansible/vars/hinchco.yml Normal file
View File

@ -0,0 +1,11 @@
---
name: hinchco
title: Mozimo
public_key: -----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAQUHP86TdF2/HRgpSOATueKxP16KONO+iTef1nITnlwc=\n-----END PUBLIC KEY-----
private_key: -----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIPWikH3em6asm4WVSO6qsljphHFg8Vqme8qso4ZUAHux\n-----END PRIVATE KEY-----
middleware_key: 1e36e7f678
host: acc.hinchco.in
host_directory: "brewman-{{ name }}"
db_name: "brewman_{{ name }}"

12
ansible/vars/hops.yml Normal file
View File

@ -0,0 +1,12 @@
---
name: hops
title: "HnG Panchkula"
public_key: -----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEA5CKg54LzOC2Ud+8Lu/bjXeGQiyINpLMFpWU3KL34RpU=\n-----END PUBLIC KEY-----
private_key: -----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIBEjfprZzihARk6Kgzt/UH6KyaU5FpYgvkF03z+Y50BW\n-----END PRIVATE KEY-----
middleware_key: 9c2bdd24be
host: hops.hopsngrains.com
host_directory: "brewman-{{ name }}"
db_name: "brewman_{{ name }}"

11
ansible/vars/mhl.yml Normal file
View File

@ -0,0 +1,11 @@
---
name: mhl
title: "HnG Mohali"
public_key: -----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAerD1T7kXn4cDp8dw1xQapPMyrlq7WHq0PpnIWqzTq8c=\n-----END PUBLIC KEY-----
private_key: -----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIFguJkIzoUkxHSxvFWr6qiCwE0ia4AsqTwhLqexVOCEh\n-----END PRIVATE KEY-----
middleware_key: 9183bdcfb0
host: mhl.hopsngrains.com
host_directory: "brewman-{{ name }}"
db_name: "brewman_{{ name }}"