Compare commits

...

14 Commits

Author SHA1 Message Date
Amit Salunke 4683f39e60 Merge pull request 'update updaetd the local docker file and updated the security in dev docker file' (#7) from updated-yml-files into main
Reviewed-on: https://git.zedobject.local/AcuPedia/acupedia-ops/pulls/7
Reviewed-by: Amit Salunke <amit@noreply.localhost>
2026-11-04 04:53:23 +00:00
Urvish Prajapati 76289bef57 update updaetd the local docker file and updated the security in dev docker file 2026-10-30 12:01:30 +05:30
Amit Salunke 6504fd3e68 Merge pull request 'fix(security): secure redis instance, harden prod compose, and fix minio media proxy' (#6) from redis-issue-fix into main
Reviewed-on: https://10.10.0.4/AcuPedia/acupedia-ops/pulls/6
Reviewed-by: Amit Salunke <amit@noreply.localhost>
2026-10-20 04:49:59 +00:00
Amit Salunke 2ffc763c40 Merge pull request 'added new config file for qa setup and manual for that' (#5) from qa-setup-update into main
Reviewed-on: https://10.10.0.4/AcuPedia/acupedia-ops/pulls/5
2026-10-20 04:49:24 +00:00
Urvish Prajapati 1fd8a94385 fix(security): secure redis instance, harden prod compose, and fix minio media proxy
- Enforce Redis authentication (--requirepass) and restrict binding to localhost

- Remove public port exposures (0.0.0.0) for Redis, Postgres, MinIO, and Backend

- Add comprehensive docker-compose.prod.yml using clean environment interpolation

- Proxy both /accupedia-media/ and /acupedia-media/ in Nginx gateway to resolve 404 image errors
2026-10-19 16:44:28 +05:30
Urvish Prajapati 808183637a updated nginx config file 2026-10-15 12:13:07 +05:30
Urvish Prajapati cf7661094d Updated A record for QA api 2026-10-13 16:02:23 +05:30
Urvish Prajapati bb1f6c5ada added new config file for qa setup and manual for that 2026-10-12 16:49:14 +05:30
Amit Salunke a751488d9d Merge pull request 'feat(ops): add script to generate container git metadata and update manual setup guide' (#4) from git-info-in-container into main
Reviewed-on: https://10.10.0.4/AcuPedia/acupedia-ops/pulls/4
2026-10-12 04:45:00 +00:00
Urvish Prajapati 3cc4f81726 feat(ops): add script to generate container git metadata and update manual setup guide
- Add scripts/generate-git-info.sh to capture branch and commit info for api, store, and admin
- Update MANUAL_SETUP_GUIDE.md with pre-build git info generation and container verification steps
- Resolve merge conflict markers in database validation section
2026-10-09 14:04:25 +05:30
Amit Salunke b6f39d8d82 Added few playbooks 2026-09-26 22:18:46 +05:30
Amit Salunke 2a16c328cb setting up deployment 2026-09-25 14:48:40 +05:30
Amit Salunke 90eb11bd2f Merge pull request 'feat(ops): add containerized nginx gateway and secure media proxy' (#3) from nginx-update into main
Reviewed-on: https://10.10.0.4/AcuPedia/acupedia-ops/pulls/3
Reviewed-by: Amit Salunke <amit@noreply.localhost>
2026-09-22 05:29:44 +00:00
Amit Salunke 5fcde8dc4b Merge pull request 'feat(ops): add media seeding step and configure presigned media endpoint' (#2) from vps-data-fix into main
Reviewed-on: https://10.10.0.4/AcuPedia/acupedia-ops/pulls/2
Reviewed-by: Amit Salunke <amit@noreply.localhost>
2026-09-21 04:54:53 +00:00
43 changed files with 1252 additions and 170 deletions

View File

@ -1,4 +1,4 @@
# Local AccuPedia workspace. # Local AcuPedia workspace.
# Copy this file to .env and adjust for your machine. # Copy this file to .env and adjust for your machine.
# #
# Do NOT commit .env. # Do NOT commit .env.

View File

@ -39,11 +39,18 @@ With the clean Acupedia naming conventions:
- **Database**: `acupedia_db` - **Database**: `acupedia_db`
- **User**: `db_admin` / Password: `C1234spl` - **User**: `db_admin` / Password: `C1234spl`
- **Volumes**: `acupedia-postgres-data`, `acupedia-minio-data` - **Volumes**: `acupedia-postgres-data`, `acupedia-minio-data`
- **MinIO Bucket**: `accupedia-media` - **MinIO Bucket**: `acupedia-media`
### Step 2.1: Generate Container Git Info Metadata (Recommended)
Before building, run the script to capture the branch and commit of `api`, `store`, and `admin`:
### Start the containers:
```bash ```bash
cd ~/acupedia/acupedia_ops cd ~/acupedia/acupedia_ops
./scripts/generate-git-info.sh
```
### Step 2.2: Start the Containers
```bash
docker compose -f docker-compose.dev.yml up -d --build docker compose -f docker-compose.dev.yml up -d --build
``` ```
@ -89,7 +96,7 @@ docker compose -f docker-compose.dev.yml exec backend \
--- ---
### Step 3.4: Seed Clinical Media Assets (Images to MinIO) ### Step 3.4: Seed Clinical Media Assets (Images to MinIO)
Seeds all 787 anatomical images, channel pathways, and charts across the 4 visual modules into MinIO object storage (`accupedia-media` bucket) and links them to their respective content items in PostgreSQL: Seeds all 787 anatomical images, channel pathways, and charts across the 4 visual modules into MinIO object storage (`acupedia-media` bucket) and links them to their respective content items in PostgreSQL:
**Option A (Recommended — Automated 1-line loop for all 4 modules):** **Option A (Recommended — Automated 1-line loop for all 4 modules):**
```bash ```bash
@ -140,13 +147,8 @@ docker compose -f docker-compose.dev.yml exec backend \
--- ---
<<<<<<< HEAD
### Step 3.6: Validate Database Integrity ### Step 3.6: Validate Database Integrity
Verifies all 9 required tables exist, counts roles, permissions, modules, published content items, and seeded media assets: Verifies all 9 required tables exist, counts roles, permissions, modules, published content items, and seeded media assets:
=======
### Step 3.5: Validate Database Integrity
Verifies all 9 required tables exist, counts roles, permissions, modules, and published content items:
>>>>>>> origin/main
```bash ```bash
docker compose -f docker-compose.dev.yml exec backend \ docker compose -f docker-compose.dev.yml exec backend \
@ -191,3 +193,25 @@ After running the manual steps above, test your endpoints:
| **Admin Portal** | `3001` | `http://<IP_OR_DOMAIN>:3001/admin/` | | **Admin Portal** | `3001` | `http://<IP_OR_DOMAIN>:3001/admin/` |
| **MinIO Console** | `9001` | `http://<IP_OR_DOMAIN>:9001` (`minioadmin` / `minioadmin`) | | **MinIO Console** | `9001` | `http://<IP_OR_DOMAIN>:9001` (`minioadmin` / `minioadmin`) |
| **MailHog UI** | `8025` | `http://<IP_OR_DOMAIN>:8025` | | **MailHog UI** | `8025` | `http://<IP_OR_DOMAIN>:8025` |
### Git Identity Verification (Inspect Container Branch & Commit)
To verify which branch and commit are running inside each container:
```bash
# 1. API Backend
docker compose -f docker-compose.dev.yml exec backend cat /app/.git_api_info
# 2. Storefront
docker compose -f docker-compose.dev.yml exec store cat /app/.git_store_info
# 3. Admin Portal
docker compose -f docker-compose.dev.yml exec admin cat /app/.git_admin_info
```
Example output:
```text
Branch: main
Commit: 29279bfd72a6fa296d1aa05a825bd88ca1f36c91
```

View File

@ -1,6 +1,6 @@
# acupedia-ops # acupedia-ops
Operational tooling for AccuPedia. Operational tooling for AcuPedia.
The repository owns: The repository owns:
@ -260,3 +260,14 @@ python3 diff.py \
--no-new-file-content \ --no-new-file-content \
--no-removed-file-content --no-removed-file-content
``` ```
## Remote host preparation
Remote dev/staging/prod hosts use Ansible via `ansible-runner`, with Docker Compose as the host-local runtime. Inventories support separate `backend`, `database`, `redis`, and `proxy` hosts or a single host in multiple groups.
```bash
pip install -e ".[deployment]"
acupedia-ops remote preflight --env dev
acupedia-ops remote prepare --env dev
```
See `docs/remote-deployment.md` before configuring production hosts. Secrets must not be committed to inventory or environment configuration files.

View File

@ -1,2 +1,2 @@
"""AccuPedia operational tooling.""" """AcuPedia operational tooling."""
__version__ = "0.1.0" __version__ = "0.1.0"

View File

@ -1,14 +1,110 @@
from __future__ import annotations from __future__ import annotations
from typing import Any
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Callable, Mapping
from acupedia_ops.common.paths import ansible_root from acupedia_ops.common.paths import ansible_root
def run_playbook(*, playbook: str, inventory: str, extra_vars: dict[str, Any] | None = None) -> None:
try: try:
import ansible_runner import ansible_runner
except ImportError as exc: except ImportError as exc:
raise RuntimeError('Install deployment support with: pip install -e ".[deployment]"') from exc raise RuntimeError(
root = ansible_root(); inventory_path = root / "inventories" / inventory; playbook_path = root / "playbooks" / playbook 'Install deployment support with: pip install -e ".[deployment]"'
if not inventory_path.exists(): raise FileNotFoundError(f"Inventory not found: {inventory_path}") ) from exc
if not playbook_path.exists(): raise FileNotFoundError(f"Playbook not found: {playbook_path}")
result = ansible_runner.run(private_data_dir=str(root), inventory=str(inventory_path), playbook=str(playbook_path), extravars=extra_vars or {}) @dataclass(frozen=True, slots=True)
if result.rc != 0: raise RuntimeError(f"Ansible playbook failed with exit code {result.rc}: {playbook_path}") class AnsibleRunResult:
status: str
rc: int
playbook: Path
inventory: Path
artifact_dir: Path | None
stats: Mapping[str, Any]
def _resolve_inventory(inventory: str | Path) -> Path:
candidate = Path(inventory).expanduser()
if candidate.exists():
return candidate.resolve()
candidate = ansible_root() / "inventories" / str(inventory)
if candidate.exists():
return candidate.resolve()
raise FileNotFoundError(f"Inventory not found: {candidate}")
def run_playbook(
*,
playbook: str | Path,
inventory: str | Path,
extra_vars: Mapping[str, Any] | None = None,
limit: str | None = None,
tags: str | None = None,
skip_tags: str | None = None,
check: bool = False,
verbosity: int = 0,
artifact_dir: Path | None = None,
envvars: Mapping[str, str] | None = None,
quiet: bool = False,
event_handler: Callable[[dict[str, Any]], bool | None] | None = None,
status_handler: Callable[[str, dict[str, Any]], None] | None = None,
) -> AnsibleRunResult:
root = ansible_root().resolve()
inventory_path = _resolve_inventory(inventory)
playbook_path = Path(playbook)
if not playbook_path.is_absolute():
playbook_path = root / "playbooks" / playbook_path
playbook_path = playbook_path.resolve()
if not playbook_path.exists():
raise FileNotFoundError(f"Playbook not found: {playbook_path}")
cmdline_parts: list[str] = []
if limit:
cmdline_parts += ["--limit", limit]
if tags:
cmdline_parts += ["--tags", tags]
if skip_tags:
cmdline_parts += ["--skip-tags", skip_tags]
if check:
cmdline_parts.append("--check")
if verbosity:
cmdline_parts.append("-" + "v" * min(verbosity, 4))
kwargs: dict[str, Any] = {
"private_data_dir": str(root),
"inventory": str(inventory_path),
"playbook": str(playbook_path),
"extravars": dict(extra_vars or {}),
"envvars": dict(envvars or {}),
"quiet": quiet,
}
if cmdline_parts:
kwargs["cmdline"] = " ".join(cmdline_parts)
if artifact_dir is not None:
artifact_dir.mkdir(parents=True, exist_ok=True)
kwargs["artifact_dir"] = str(artifact_dir)
if event_handler is not None:
kwargs["event_handler"] = event_handler
if status_handler is not None:
kwargs["status_handler"] = status_handler
result = ansible_runner.run(**kwargs)
rc = int(result.rc or 0)
status = str(result.status or ("successful" if rc == 0 else "failed"))
resolved_artifact_dir = Path(result.artifact_dir) if getattr(result, "artifact_dir", None) else artifact_dir
run_result = AnsibleRunResult(
status=status,
rc=rc,
playbook=playbook_path,
inventory=inventory_path,
artifact_dir=resolved_artifact_dir,
stats=dict(getattr(result, "stats", {}) or {}),
)
if rc != 0:
suffix = f"; artifacts: {resolved_artifact_dir}" if resolved_artifact_dir else ""
raise RuntimeError(
f"Ansible playbook failed with exit code {rc}: {playbook_path}{suffix}"
)
return run_result

View File

@ -28,20 +28,20 @@ def resolve_api_root(api_root: Path | None = None) -> Path:
raw = os.environ.get("ACUPEDIA_API_PATH", "").strip() raw = os.environ.get("ACUPEDIA_API_PATH", "").strip()
if not raw: if not raw:
raise RuntimeError( raise RuntimeError(
"AccuPedia API path is required. Supply --api-root or set " "AcuPedia API path is required. Supply --api-root or set "
"ACUPEDIA_API_PATH." "ACUPEDIA_API_PATH."
) )
root = resolve_workspace_path(raw, base_path=base) root = resolve_workspace_path(raw, base_path=base)
if not root.is_dir(): if not root.is_dir():
raise FileNotFoundError(f"AccuPedia API repository not found: {root}") raise FileNotFoundError(f"AcuPedia API repository not found: {root}")
if not (root / "app").is_dir(): if not (root / "app").is_dir():
raise ValueError(f"Invalid AccuPedia API repository; missing: {root / 'app'}") raise ValueError(f"Invalid AcuPedia API repository; missing: {root / 'app'}")
if not (root / "pyproject.toml").is_file(): if not (root / "pyproject.toml").is_file():
raise ValueError( raise ValueError(
f"Invalid AccuPedia API repository; missing: {root / 'pyproject.toml'}" f"Invalid AcuPedia API repository; missing: {root / 'pyproject.toml'}"
) )
return root return root

View File

@ -11,6 +11,7 @@ from acupedia_ops.common.paths import repo_root
from acupedia_ops.data.image.clean_image_borders import process_path from acupedia_ops.data.image.clean_image_borders import process_path
from acupedia_ops.deployment.backend import deploy_backend from acupedia_ops.deployment.backend import deploy_backend
from acupedia_ops.deployment.database import deploy_database from acupedia_ops.deployment.database import deploy_database
from acupedia_ops.deployment.remote import preflight_remote, prepare_remote
from acupedia_ops.deployment.gitea_runner import provision_runner, remove_runner from acupedia_ops.deployment.gitea_runner import provision_runner, remove_runner
from acupedia_ops.local.bootstrap import local_bootstrap from acupedia_ops.local.bootstrap import local_bootstrap
from acupedia_ops.local.database import reset_local_database from acupedia_ops.local.database import reset_local_database
@ -33,7 +34,7 @@ LOCAL_COMPONENTS = ("api", "mobile", "web", "admin")
def _build_parser() -> argparse.ArgumentParser: def _build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
prog="acupedia-ops", prog="acupedia-ops",
description="AccuPedia operational tooling", description="AcuPedia operational tooling",
) )
parser.add_argument( parser.add_argument(
"--env-file", "--env-file",
@ -196,6 +197,17 @@ def _build_parser() -> argparse.ArgumentParser:
database = deploy_sub.add_parser("database") database = deploy_sub.add_parser("database")
database.add_argument("--env", required=True, choices=("dev", "staging", "prod")) database.add_argument("--env", required=True, choices=("dev", "staging", "prod"))
# Remote host lifecycle ---------------------------------------------
remote = subparsers.add_parser("remote")
remote_sub = remote.add_subparsers(dest="remote_command", required=True)
for remote_name in ("preflight", "prepare"):
remote_cmd = remote_sub.add_parser(remote_name)
remote_cmd.add_argument("--env", required=True, choices=("dev", "staging", "prod"))
remote_cmd.add_argument("--limit")
remote_cmd.add_argument("-v", "--verbose", action="count", default=0)
if remote_name == "prepare":
remote_cmd.add_argument("--check", action="store_true")
# Gitea runner lifecycle -------------------------------------------- # Gitea runner lifecycle --------------------------------------------
runner = subparsers.add_parser("runner") runner = subparsers.add_parser("runner")
runner_sub = runner.add_subparsers(dest="runner_command", required=True) runner_sub = runner.add_subparsers(dest="runner_command", required=True)
@ -393,6 +405,14 @@ def main() -> None:
deploy_database(environment=args.env) deploy_database(environment=args.env)
return return
if args.command == "remote" and args.remote_command == "preflight":
preflight_remote(environment=args.env, limit=args.limit, verbosity=args.verbose)
return
if args.command == "remote" and args.remote_command == "prepare":
prepare_remote(environment=args.env, limit=args.limit, check=args.check, verbosity=args.verbose)
return
if args.command == "runner" and args.runner_command == "provision": if args.command == "runner" and args.runner_command == "provision":
token = args.registration_token token = args.registration_token
if not token: if not token:

View File

@ -14,7 +14,7 @@ def workspace_base_path(
*, *,
required: bool = True, required: bool = True,
) -> Path | None: ) -> Path | None:
"""Return the AccuPedia workspace base path. """Return the AcuPedia workspace base path.
Resolution order: Resolution order:
1. explicit value 1. explicit value
@ -31,7 +31,7 @@ def workspace_base_path(
if not raw: if not raw:
if required: if required:
raise RuntimeError( raise RuntimeError(
f"{WORKSPACE_BASE_ENV} is required for relative AccuPedia paths." f"{WORKSPACE_BASE_ENV} is required for relative AcuPedia paths."
) )
return None return None
@ -49,7 +49,7 @@ def resolve_workspace_path(
*, *,
base_path: Path | None = None, base_path: Path | None = None,
) -> Path: ) -> Path:
"""Resolve an AccuPedia path deterministically. """Resolve an AcuPedia path deterministically.
Absolute paths are used as-is. Absolute paths are used as-is.
Relative paths are always resolved against ACUPEDIA_WORKSPACE_BASE_PATH, Relative paths are always resolved against ACUPEDIA_WORKSPACE_BASE_PATH,

View File

@ -1,85 +1,45 @@
from __future__ import annotations from __future__ import annotations
import os
import subprocess
from pathlib import Path from pathlib import Path
from typing import Sequence from typing import Any, Sequence
import yaml
from acupedia_ops.common.paths import repo_root
from acupedia_ops.ansible.runner import run_playbook
def _repo_root() -> Path: def _repo_root() -> Path:
return Path(__file__).resolve().parents[2] """Backward-compatible repository root helper."""
return repo_root()
def _ansible_playbook() -> str: def _parse_extra_vars(values: Sequence[str]) -> dict[str, Any]:
return os.environ.get("ANSIBLE_PLAYBOOK_BIN", "ansible-playbook") result: dict[str, Any] = {}
for value in values:
parsed = yaml.safe_load(value)
if isinstance(parsed, dict):
result.update(parsed)
continue
if "=" not in value:
raise ValueError(f"Invalid --extra-var {value!r}; expected key=value or YAML mapping")
key, raw = value.split("=", 1)
result[key] = yaml.safe_load(raw)
return result
def provision_runner( def provision_runner(*, inventory: Path, registration_token: str, limit: str | None = None,
*, extra_vars: Sequence[str] = (), force_reregister: bool = False) -> None:
inventory: Path, variables = _parse_extra_vars(extra_vars)
registration_token: str, variables["gitea_runner_registration_token"] = registration_token
limit: str | None = None,
extra_vars: Sequence[str] = (),
force_reregister: bool = False,
) -> None:
repo_root = _repo_root()
playbook = repo_root / "ansible" / "playbooks" / "gitea-runner.yml"
command = [
_ansible_playbook(),
"-i",
str(inventory),
str(playbook),
"--extra-vars",
f"gitea_runner_registration_token={registration_token}",
]
if force_reregister: if force_reregister:
command.extend( variables["gitea_runner_force_reregister"] = True
[ run_playbook(playbook="gitea-runner.yml", inventory=inventory, extra_vars=variables, limit=limit)
"--extra-vars",
"gitea_runner_force_reregister=true",
]
)
for value in extra_vars:
command.extend(["--extra-vars", value])
if limit:
command.extend(["--limit", limit])
subprocess.run(command, cwd=repo_root, check=True)
def remove_runner( def remove_runner(*, inventory: Path, limit: str | None = None, remove_data: bool = False,
*, extra_vars: Sequence[str] = ()) -> None:
inventory: Path, variables = _parse_extra_vars(extra_vars)
limit: str | None = None,
remove_data: bool = False,
extra_vars: Sequence[str] = (),
) -> None:
repo_root = _repo_root()
playbook = repo_root / "ansible" / "playbooks" / "gitea-runner-remove.yml"
command = [
_ansible_playbook(),
"-i",
str(inventory),
str(playbook),
]
if remove_data: if remove_data:
command.extend( variables["gitea_runner_remove_data"] = True
[ run_playbook(playbook="gitea-runner-remove.yml", inventory=inventory, extra_vars=variables, limit=limit)
"--extra-vars",
"gitea_runner_remove_data=true",
]
)
for value in extra_vars:
command.extend(["--extra-vars", value])
if limit:
command.extend(["--limit", limit])
subprocess.run(command, cwd=repo_root, check=True)

View File

@ -0,0 +1,12 @@
from __future__ import annotations
from acupedia_ops.ansible.runner import AnsibleRunResult, run_playbook
def preflight_remote(*, environment: str, limit: str | None = None, verbosity: int = 0) -> AnsibleRunResult:
return run_playbook(playbook="preflight.yml", inventory=environment, limit=limit, verbosity=verbosity)
def prepare_remote(*, environment: str, limit: str | None = None, check: bool = False,
verbosity: int = 0) -> AnsibleRunResult:
return run_playbook(playbook="prepare.yml", inventory=environment, limit=limit, check=check, verbosity=verbosity)

View File

@ -23,6 +23,7 @@ def run_component(
component: str, component: str,
) -> None: ) -> None:
config = workspace.components[component] config = workspace.components[component]
print(config)
if not config.run_command: if not config.run_command:
raise RuntimeError( raise RuntimeError(
f"No run command configured for local component: {component}" f"No run command configured for local component: {component}"

View File

@ -0,0 +1,3 @@
---
acupedia_environment: dev
acupedia_root: /opt/acupedia

View File

@ -1,5 +1,23 @@
--- ---
# A single dev host may belong to every service group. Replace the example host
# and address before use.
all: all:
hosts:
acupedia-dev:
ansible_host: 10.10.0.20
children: children:
docker_hosts:
hosts:
acupedia-dev:
backend: backend:
hosts: {} hosts:
acupedia-dev:
database:
hosts:
acupedia-dev:
redis:
hosts:
acupedia-dev:
proxy:
hosts:
acupedia-dev:

View File

@ -19,4 +19,4 @@ all:
vars: vars:
ansible_user: ops ansible_user: ops
gitea_runner_instance_url: "https://gitea.example.com" gitea_runner_instance_url: "https://git.zedobject.local"

View File

@ -0,0 +1,3 @@
---
acupedia_environment: prod
acupedia_root: /opt/acupedia

View File

@ -1,5 +1,19 @@
--- ---
# Service groups are intentionally independent: production services may live
# on separate hosts. A host may also be placed in multiple groups.
all: all:
children: children:
docker_hosts:
children:
backend: {}
database: {}
redis: {}
proxy: {}
backend: backend:
hosts: {} hosts: {}
database:
hosts: {}
redis:
hosts: {}
proxy:
hosts: {}

View File

@ -0,0 +1,3 @@
---
acupedia_environment: staging
acupedia_root: /opt/acupedia

View File

@ -1,5 +1,18 @@
--- ---
# Replace addresses/hosts with the staging topology.
all: all:
children: children:
docker_hosts:
children:
backend: {}
database: {}
redis: {}
proxy: {}
backend: backend:
hosts: {} hosts: {}
database:
hosts: {}
redis:
hosts: {}
proxy:
hosts: {}

View File

@ -1,5 +1,5 @@
--- ---
- name: Deploy AccuPedia backend - name: Deploy AcuPedia backend
hosts: backend hosts: backend
gather_facts: true gather_facts: true
tasks: tasks:

View File

@ -1,5 +1,5 @@
--- ---
- name: Deploy AccuPedia database changes - name: Deploy AcuPedia database changes
hosts: backend hosts: backend
gather_facts: true gather_facts: true
tasks: tasks:

View File

@ -1,5 +1,5 @@
--- ---
- name: Provision AccuPedia infrastructure - name: Provision AcuPedia infrastructure
hosts: all hosts: all
gather_facts: true gather_facts: true
tasks: tasks:

View File

@ -0,0 +1,14 @@
---
- name: Validate AcuPedia remote hosts
hosts: docker_hosts
gather_facts: true
tasks:
- name: Verify supported operating system
ansible.builtin.assert:
that:
- ansible_os_family == "Debian"
fail_msg: "Initial AcuPedia remote setup supports Debian/Ubuntu hosts only."
- name: Verify privilege escalation
ansible.builtin.command: /usr/bin/true
become: true
changed_when: false

View File

@ -0,0 +1,7 @@
---
- name: Prepare AcuPedia Docker hosts
hosts: docker_hosts
gather_facts: true
roles:
- role: common
- role: docker

View File

@ -0,0 +1,15 @@
---
acupedia_system_user: acupedia
acupedia_system_group: acupedia
acupedia_root: /opt/acupedia
acupedia_directories:
- "{{ acupedia_root }}"
- "{{ acupedia_root }}/compose"
- "{{ acupedia_root }}/config"
- "{{ acupedia_root }}/data"
- "{{ acupedia_root }}/backups"
- "{{ acupedia_root }}/releases"
acupedia_common_packages:
- ca-certificates
- curl
- git

View File

@ -0,0 +1,40 @@
---
- name: Assert supported operating system
ansible.builtin.assert:
that:
- ansible_os_family == "Debian"
fail_msg: "Initial AcuPedia remote setup supports Debian/Ubuntu hosts only."
- name: Install common packages
ansible.builtin.apt:
name: "{{ acupedia_common_packages }}"
state: present
update_cache: true
become: true
- name: Create AcuPedia system group
ansible.builtin.group:
name: "{{ acupedia_system_group }}"
system: true
state: present
become: true
- name: Create AcuPedia system user
ansible.builtin.user:
name: "{{ acupedia_system_user }}"
group: "{{ acupedia_system_group }}"
system: true
create_home: false
shell: /usr/sbin/nologin
state: present
become: true
- name: Create AcuPedia directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ acupedia_system_user }}"
group: "{{ acupedia_system_group }}"
mode: "0750"
loop: "{{ acupedia_directories }}"
become: true

View File

@ -0,0 +1,6 @@
---
acupedia_docker_packages:
- docker.io
- docker-compose-v2
acupedia_docker_service: docker
acupedia_docker_users: []

View File

@ -0,0 +1,28 @@
---
- name: Install Docker Engine and Compose plugin
ansible.builtin.apt:
name: "{{ acupedia_docker_packages }}"
state: present
update_cache: true
become: true
- name: Enable and start Docker
ansible.builtin.service:
name: "{{ acupedia_docker_service }}"
enabled: true
state: started
become: true
- name: Add explicitly configured users to Docker group
ansible.builtin.user:
name: "{{ item }}"
groups: docker
append: true
loop: "{{ acupedia_docker_users }}"
become: true
- name: Verify Docker Compose plugin
ansible.builtin.command: docker compose version
register: acupedia_compose_version
changed_when: false
become: true

View File

@ -1,6 +1,6 @@
environment: dev environment: dev
backend: backend:
application_name: accupedia-api application_name: acupedia-api
database: database:
run_migrations: true run_migrations: true
infra: {} infra: {}

View File

@ -87,7 +87,7 @@ server {
return 301 https://acupedia.in$request_uri; return 301 https://acupedia.in$request_uri;
} }
# MinIO S3 Presigned Media Proxy (/accupedia-media/) # MinIO S3 Presigned Media Proxy (/accupedia-media/ and /acupedia-media/)
location /accupedia-media/ { location /accupedia-media/ {
proxy_pass http://minio_storage; proxy_pass http://minio_storage;
proxy_set_header Host $http_host; proxy_set_header Host $http_host;
@ -96,6 +96,14 @@ server {
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
} }
location /acupedia-media/ {
proxy_pass http://minio_storage;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# FastAPI Swagger Docs & OpenAPI Schema # FastAPI Swagger Docs & OpenAPI Schema
location /docs { location /docs {
proxy_pass http://backend_api/docs; proxy_pass http://backend_api/docs;

View File

@ -0,0 +1,178 @@
# ==============================================================================
# Acupedia Platform — QA Containerized Nginx Gateway Configuration
# File: config/nginx/acupedia.qa.conf
#
# Domain: qa.acupedia.in (and optional qa-api.acupedia.in)
#
# Container Upstreams:
# - Backend API -> backend:8000
# - Storefront -> store:80
# - Admin Suite -> admin:80
# - MinIO S3 -> minio:9000
# ==============================================================================
# ------------------------------------------------------------------------------
# Upstream Definitions (Docker Internal DNS on acupedia-net)
# ------------------------------------------------------------------------------
upstream backend_api {
server backend:8000;
keepalive 32;
}
upstream store_app {
server store:80;
keepalive 16;
}
upstream admin_app {
server admin:80;
keepalive 16;
}
upstream minio_storage {
server minio:9000;
keepalive 32;
}
# ==============================================================================
# 1. HTTP to HTTPS Global Redirect (Ports 80 -> 443)
# ==============================================================================
server {
listen 80;
listen [::]:80;
server_name qa.acupedia.in qa-api.acupedia.in;
# Let's Encrypt ACME challenge (used for certbot renewal)
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
# Redirect all HTTP requests to HTTPS
location / {
return 301 https://$host$request_uri;
}
}
# ==============================================================================
# 2. QA Dedicated API Subdomain (qa-api.acupedia.in) - Optional
# ==============================================================================
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name qa-api.acupedia.in;
# SSL Certificates (Mounted from host /etc/letsencrypt)
ssl_certificate /etc/letsencrypt/live/qa.acupedia.in/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/qa.acupedia.in/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;
client_max_body_size 50M;
# Common Proxy Headers
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 60s;
proxy_send_timeout 120s;
proxy_read_timeout 120s;
# Mobile App redirects
location /cart {
return 301 https://qa.acupedia.in$request_uri;
}
location /checkout {
return 301 https://qa.acupedia.in$request_uri;
}
# MinIO S3 Presigned Media Proxy (/acupedia-media/)
location /acupedia-media/ {
proxy_pass http://minio_storage;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# FastAPI Swagger Docs & OpenAPI Schema
location /docs {
proxy_pass http://backend_api/docs;
}
location /openapi.json {
proxy_pass http://backend_api/openapi.json;
}
# Route all API traffic to FastAPI Backend on port 8000
location / {
proxy_pass http://backend_api;
}
}
# ==============================================================================
# 3. QA Main Domain: Storefront (/), Admin (/admin), API (/api/), Docs (/docs)
# ==============================================================================
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name qa.acupedia.in;
# SSL Certificates (Mounted from host /etc/letsencrypt)
ssl_certificate /etc/letsencrypt/live/qa.acupedia.in/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/qa.acupedia.in/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;
client_max_body_size 50M;
# Common Proxy Headers
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 60s;
proxy_send_timeout 120s;
proxy_read_timeout 120s;
# Admin Panel (/admin)
location /admin {
proxy_pass http://admin_app;
}
# Backend API access via same-origin (qa.acupedia.in/api/ -> avoids CORS)
location /api/ {
proxy_pass http://backend_api/api/;
}
# FastAPI Swagger Docs (/docs)
location /docs {
proxy_pass http://backend_api/docs;
}
location /openapi.json {
proxy_pass http://backend_api/openapi.json;
}
# MinIO S3 Presigned Media Proxy (/acupedia-media/)
location /acupedia-media/ {
proxy_pass http://minio_storage;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Storefront Customer Web App (/)
location / {
proxy_pass http://store_app;
}
}

View File

@ -1,6 +1,6 @@
environment: prod environment: prod
backend: backend:
application_name: accupedia-api application_name: acupedia-api
database: database:
run_migrations: true run_migrations: true
infra: {} infra: {}

View File

@ -1,6 +1,6 @@
environment: staging environment: staging
backend: backend:
application_name: accupedia-api application_name: acupedia-api
database: database:
run_migrations: true run_migrations: true
infra: {} infra: {}

View File

@ -11,7 +11,8 @@ services:
POSTGRES_USER: ${POSTGRES_USER:-db_admin} POSTGRES_USER: ${POSTGRES_USER:-db_admin}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-C1234spl} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-C1234spl}
ports: ports:
- "${POSTGRES_PORT:-5432}:5432" # Bound strictly to 127.0.0.1 (Localhost only - safe from other LAN/remote PCs)
- "127.0.0.1:${POSTGRES_PORT:-5432}:5432"
volumes: volumes:
- acupedia-postgres-data:/var/lib/postgresql/data - acupedia-postgres-data:/var/lib/postgresql/data
healthcheck: healthcheck:
@ -29,8 +30,10 @@ services:
image: redis:7-alpine image: redis:7-alpine
container_name: acupedia-redis container_name: acupedia-redis
restart: unless-stopped restart: unless-stopped
command: redis-server --requirepass "${REDIS_PASSWORD:-AcupediaSecureRedis2026!#}"
ports: ports:
- "${REDIS_PORT:-6379}:6379" # Bound strictly to 127.0.0.1
- "127.0.0.1:${REDIS_PORT:-6379}:6379"
volumes: volumes:
- acupedia-redis-data:/data - acupedia-redis-data:/data
networks: networks:
@ -48,8 +51,9 @@ services:
MINIO_ROOT_USER: ${MINIO_ACCESS_KEY:-minioadmin} MINIO_ROOT_USER: ${MINIO_ACCESS_KEY:-minioadmin}
MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY:-minioadmin} MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY:-minioadmin}
ports: ports:
- "${MINIO_PORT:-9000}:9000" # Bound strictly to 127.0.0.1 - Nginx proxies public /acupedia-media/ requests
- "${MINIO_CONSOLE_PORT:-9001}:9001" - "127.0.0.1:${MINIO_PORT:-9000}:9000"
- "127.0.0.1:${MINIO_CONSOLE_PORT:-9001}:9001"
volumes: volumes:
- acupedia-minio-data:/data - acupedia-minio-data:/data
networks: networks:
@ -63,8 +67,9 @@ services:
container_name: acupedia-mailhog container_name: acupedia-mailhog
restart: unless-stopped restart: unless-stopped
ports: ports:
- "1025:1025" # SMTP port # Bound strictly to 127.0.0.1 so email UI is not exposed publicly
- "8025:8025" # Web UI port - "127.0.0.1:1025:1025" # SMTP port
- "127.0.0.1:8025:8025" # Web UI port
networks: networks:
- acupedia-net - acupedia-net
@ -72,6 +77,7 @@ services:
# 5. Acupedia Backend API (FastAPI) # 5. Acupedia Backend API (FastAPI)
# ============================================================ # ============================================================
backend: backend:
image: acupedia-ops-backend:latest
build: build:
context: ${ACUPEDIA_API_PATH:-../../acupedia-api} context: ${ACUPEDIA_API_PATH:-../../acupedia-api}
dockerfile: Dockerfile dockerfile: Dockerfile
@ -96,19 +102,20 @@ services:
MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY:-minioadmin} MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY:-minioadmin}
MINIO_SECRET_KEY: ${MINIO_SECRET_KEY:-minioadmin} MINIO_SECRET_KEY: ${MINIO_SECRET_KEY:-minioadmin}
MINIO_SECURE: "false" MINIO_SECURE: "false"
MINIO_BUCKET: ${MINIO_BUCKET_NAME:-accupedia-media} MINIO_BUCKET: ${MINIO_BUCKET_NAME:-acupedia-media}
MEDIA_STORAGE_SECURE: ${MEDIA_STORAGE_SECURE:-true} MEDIA_STORAGE_SECURE: ${MEDIA_STORAGE_SECURE:-true}
MEDIA_PRESIGN_ENDPOINT: ${MEDIA_PRESIGN_ENDPOINT:-http://localhost:9000} MEDIA_PRESIGN_ENDPOINT: ${MEDIA_PRESIGN_ENDPOINT:-https://qa.acupedia.in}
MEDIA_STORAGE_ACCESS_KEY: ${MINIO_ACCESS_KEY:-minioadmin} MEDIA_STORAGE_ACCESS_KEY: ${MINIO_ACCESS_KEY:-minioadmin}
MEDIA_STORAGE_SECRET_KEY: ${MINIO_SECRET_KEY:-minioadmin} MEDIA_STORAGE_SECRET_KEY: ${MINIO_SECRET_KEY:-minioadmin}
MEDIA_STORAGE_BUCKET: ${MINIO_BUCKET_NAME:-accupedia-media} MEDIA_STORAGE_BUCKET: ${MINIO_BUCKET_NAME:-acupedia-media}
MEDIA_STORAGE_REGION: us-east-1 MEDIA_STORAGE_REGION: us-east-1
MEDIA_URL_TTL_SECONDS: 900 MEDIA_URL_TTL_SECONDS: 900
REDIS_HOST: redis REDIS_HOST: redis
REDIS_PORT: 6379 REDIS_PORT: 6379
REDIS_URL: redis://redis:6379/0 REDIS_PASSWORD: ${REDIS_PASSWORD:-AcupediaSecureRedis2026!#}
REDIS_URL: redis://:${REDIS_PASSWORD:-AcupediaSecureRedis2026!#}@redis:6379/0
CACHE_ENABLED: "true" CACHE_ENABLED: "true"
CACHE_REDIS_URL: redis://redis:6379/0 CACHE_REDIS_URL: redis://:${REDIS_PASSWORD:-AcupediaSecureRedis2026!#}@redis:6379/0
SMTP_HOST: mailhog SMTP_HOST: mailhog
SMTP_PORT: 1025 SMTP_PORT: 1025
JWT_SECRET: ${JWT_SECRET:-b4f8c9b3d0a2f4c9b3d0a2f4c9b3d0a2f4c9b3d0a2f4c9b3d0a2f4c9b3d0a2f4} JWT_SECRET: ${JWT_SECRET:-b4f8c9b3d0a2f4c9b3d0a2f4c9b3d0a2f4c9b3d0a2f4c9b3d0a2f4c9b3d0a2f4}
@ -116,9 +123,11 @@ services:
RAZORPAY_KEY_ID: ${RAZORPAY_KEY_ID:-rzp_test_TRwmEntw35BIrL} RAZORPAY_KEY_ID: ${RAZORPAY_KEY_ID:-rzp_test_TRwmEntw35BIrL}
RAZORPAY_KEY_SECRET: ${RAZORPAY_KEY_SECRET:-vsB1RYs6J1S4EtK0u8zuZuaL} RAZORPAY_KEY_SECRET: ${RAZORPAY_KEY_SECRET:-vsB1RYs6J1S4EtK0u8zuZuaL}
RESEND_API_KEY: ${RESEND_API_KEY:-re_YHvSXRCz_LrQYzEYEDVwoRiAgfJRsH6ya} RESEND_API_KEY: ${RESEND_API_KEY:-re_YHvSXRCz_LrQYzEYEDVwoRiAgfJRsH6ya}
CONTENT_PREVIEW_ENABLED: ${CONTENT_PREVIEW_ENABLED:-true}
ENVIRONMENT: ${ENVIRONMENT:-production} ENVIRONMENT: ${ENVIRONMENT:-production}
ports: ports:
- "${BACKEND_PORT:-8000}:8000" # Bound to localhost only (Nginx proxies all public API traffic)
- "127.0.0.1:${BACKEND_PORT:-8000}:8000"
volumes: volumes:
- ${CONTENT_PATH:-../../acupedia_content/acupedia-content}:/app/content:ro - ${CONTENT_PATH:-../../acupedia_content/acupedia-content}:/app/content:ro
networks: networks:
@ -128,6 +137,7 @@ services:
# 6. Storefront Web App (Vite/React on Port 3000) # 6. Storefront Web App (Vite/React on Port 3000)
# ============================================================ # ============================================================
store: store:
image: acupedia-ops-store:latest
build: build:
context: ${ACUPEDIA_STORE_PATH:-../../acupedia_store_ui} context: ${ACUPEDIA_STORE_PATH:-../../acupedia_store_ui}
dockerfile: Dockerfile dockerfile: Dockerfile
@ -138,7 +148,8 @@ services:
depends_on: depends_on:
- backend - backend
ports: ports:
- "${STORE_PORT:-3000}:80" # Bound to localhost only (Nginx handles public traffic via qa.acupedia.in/)
- "127.0.0.1:${STORE_PORT:-3000}:80"
networks: networks:
- acupedia-net - acupedia-net
@ -146,6 +157,7 @@ services:
# 7. Admin Portal Web App (Vite/React on Port 3001) # 7. Admin Portal Web App (Vite/React on Port 3001)
# ============================================================ # ============================================================
admin: admin:
image: acupedia-ops-admin:latest
build: build:
context: ${ACUPEDIA_ADMIN_PATH:-../../acupedia_web_ui} context: ${ACUPEDIA_ADMIN_PATH:-../../acupedia_web_ui}
dockerfile: Dockerfile dockerfile: Dockerfile
@ -156,12 +168,13 @@ services:
depends_on: depends_on:
- backend - backend
ports: ports:
- "${ADMIN_PORT:-3001}:80" # Bound to localhost only (Nginx handles public traffic via qa.acupedia.in/admin)
- "127.0.0.1:${ADMIN_PORT:-3001}:80"
networks: networks:
- acupedia-net - acupedia-net
# ============================================================ # ============================================================
# 8. Central Nginx Reverse Proxy (Containerized Gateway) # 8. Central Nginx Reverse Proxy (QA Containerized Gateway)
# ============================================================ # ============================================================
nginx: nginx:
image: nginx:alpine image: nginx:alpine
@ -173,12 +186,13 @@ services:
- admin - admin
- minio - minio
ports: ports:
# The ONLY services exposed to the network/internet
- "${HTTP_PORT:-80}:80" - "${HTTP_PORT:-80}:80"
- "${HTTPS_PORT:-443}:443" - "${HTTPS_PORT:-443}:443"
volumes: volumes:
- ./config/nginx/acupedia.conf:/etc/nginx/conf.d/default.conf:ro - ./config/nginx/acupedia.qa.conf:/etc/nginx/conf.d/default.conf:ro
- /etc/letsencrypt:/etc/letsencrypt:ro - ${CERTS_PATH:-./certs}:/etc/letsencrypt:ro
- /var/www/certbot:/var/www/certbot - ./certbot:/var/www/certbot
networks: networks:
- acupedia-net - acupedia-net

View File

@ -1,32 +1,35 @@
version: '3.8'
services: services:
postgres: postgres:
image: postgres:16-alpine image: postgres:16-alpine
container_name: acupedia-postgres
restart: unless-stopped restart: unless-stopped
environment: environment:
POSTGRES_DB: ${POSTGRES_DB:-acupedia_db} POSTGRES_DB: ${POSTGRES_DB:-acupedia_db}
POSTGRES_USER: ${POSTGRES_USER:-db_admin} POSTGRES_USER: ${POSTGRES_USER:-db_admin}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-C1234spl} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-C1234spl}
ports: ports:
- "${POSTGRES_PORT:-5432}:5432" - "127.0.0.1:${POSTGRES_PORT:-5432}:5432"
volumes: volumes:
- acupedia-postgres-data:/var/lib/postgresql/data - acupedia-postgres-data:/var/lib/postgresql/data
healthcheck: healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-acupedia} -d ${POSTGRES_DB:-acupedia_db}"] test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-db_admin} -d ${POSTGRES_DB:-acupedia_db}"]
interval: 5s interval: 5s
timeout: 5s timeout: 5s
retries: 20 retries: 20
networks: networks:
- acupedia-net - acupedia-net
redis: redis:
image: redis:8.10.1-alpine image: redis:8.10.1-alpine
container_name: acupedia-redis
restart: unless-stopped restart: unless-stopped
ports: ports:
- "${REDIS_PORT:-6379}:6379" - "127.0.0.1:${REDIS_PORT:-6379}:6379"
volumes: volumes:
- acupedia-redis-data:/data - acupedia-redis-data:/data
networks: networks:
- acupedia-net - acupedia-net
minio: minio:
image: minio/minio image: minio/minio
container_name: acupedia-minio container_name: acupedia-minio
@ -35,28 +38,34 @@ services:
environment: environment:
MINIO_ROOT_USER: ${MINIO_ACCESS_KEY:-minioadmin} MINIO_ROOT_USER: ${MINIO_ACCESS_KEY:-minioadmin}
MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY:-minioadmin} MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY:-minioadmin}
# Localhost endpoints for MinIO S3 API and Web Console
MINIO_SERVER_URL: "http://localhost:${MINIO_PORT:-9000}"
MINIO_BROWSER_REDIRECT_URL: "http://localhost:${MINIO_CONSOLE_PORT:-9001}"
ports: ports:
- "${MINIO_PORT:-9000}:9000" # Bound strictly to 127.0.0.1 for local development
- "${MINIO_CONSOLE_PORT:-9001}:9001" - "127.0.0.1:${MINIO_PORT:-9000}:9000"
- "127.0.0.1:${MINIO_CONSOLE_PORT:-9001}:9001"
volumes: volumes:
- acupedia-minio-data:/data - acupedia-minio-data:/data
networks: networks:
- acupedia-net - acupedia-net
# mailhog:
# image: mailhog/mailhog:latest mailhog:
# container_name: acupedia-mailhog image: mailhog/mailhog:latest
# restart: unless-stopped container_name: acupedia-mailhog
# ports: restart: unless-stopped
# - "1025:1025" # SMTP port ports:
# - "8025:8025" # Web UI port - "127.0.0.1:1025:1025" # SMTP port
# networks: - "127.0.0.1:8025:8025" # Web UI port (http://localhost:8025)
# - acupedia-net networks:
- acupedia-net
redisinsight: redisinsight:
image: redis/redisinsight:latest image: redis/redisinsight:latest
container_name: redis-insight container_name: redis-insight
restart: always restart: always
ports: ports:
- "5540:5540" - "127.0.0.1:5540:5540"
volumes: volumes:
- acupedia-redisinsight-data:/data - acupedia-redisinsight-data:/data
depends_on: depends_on:

View File

@ -1,51 +1,204 @@
version: '3.8'
services: services:
# ============================================================
# 1. PostgreSQL Database
# ============================================================
postgres: postgres:
image: ${ACUPEDIA_POSTGRES_IMAGE:?Set ACUPEDIA_POSTGRES_IMAGE} image: postgres:16-alpine
container_name: acupedia-postgres
restart: unless-stopped restart: unless-stopped
environment: environment:
POSTGRES_DB: ${POSTGRES_DB:-acupedia} POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER:-acupedia} POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
ports: ports:
- "${POSTGRES_PORT:-5432}:5432" # Bound strictly to 127.0.0.1 (Localhost only - safe from public internet)
- "127.0.0.1:${POSTGRES_PORT:-5432}:5432"
volumes: volumes:
- acupedia-postgres-data:/var/lib/postgresql/data - acupedia-postgres-data:/var/lib/postgresql/data
healthcheck: healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-acupedia} -d ${POSTGRES_DB:-acupedia}"] test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 5s interval: 5s
timeout: 5s timeout: 5s
retries: 20 retries: 20
networks:
- acupedia-net
# ============================================================
# 2. Redis Cache (Secured & Internal)
# ============================================================
redis: redis:
image: ${ACUPEDIA_REDIS_IMAGE:?Set ACUPEDIA_REDIS_IMAGE} image: redis:7-alpine
container_name: acupedia-redis
restart: unless-stopped restart: unless-stopped
command: redis-server --requirepass "${REDIS_PASSWORD}"
ports: ports:
- "${REDIS_PORT:-6379}:6379" - "127.0.0.1:${REDIS_PORT:-6379}:6379"
volumes: volumes:
- acupedia-redis-data:/data - acupedia-redis-data:/data
networks:
- acupedia-net
# ============================================================
# 3. MinIO Object Storage
# ============================================================
minio: minio:
image: ${ACUPEDIA_MINIO_IMAGE:?Set ACUPEDIA_MINIO_IMAGE} image: minio/minio
container_name: acupedia-minio
restart: unless-stopped restart: unless-stopped
command: server /data --console-address ":9001" command: server /data --console-address ":9001"
environment: environment:
MINIO_ROOT_USER: ${MINIO_ACCESS_KEY:?Set MINIO_ACCESS_KEY} MINIO_ROOT_USER: ${MINIO_ACCESS_KEY}
MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY:?Set MINIO_SECRET_KEY} MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY}
ports: ports:
- "${MINIO_PORT:-9000}:9000" # Bound strictly to 127.0.0.1 - Nginx proxies public /acupedia-media/ requests
- "${MINIO_CONSOLE_PORT:-9001}:9001" - "127.0.0.1:${MINIO_PORT:-9000}:9000"
- "127.0.0.1:${MINIO_CONSOLE_PORT:-9001}:9001"
volumes: volumes:
- acupedia-minio-data:/data - acupedia-minio-data:/data
networks:
- acupedia-net
acupedia-content: # ============================================================
image: gcr.io/google-containers/pause:3.9 # 4. MailHog SMTP Server (Optional / Dev fallback)
container_name: acupedia-content # ============================================================
mailhog:
image: mailhog/mailhog:latest
container_name: acupedia-mailhog
restart: unless-stopped
ports:
# Bound strictly to 127.0.0.1 so test mail UI is not exposed publicly
- "127.0.0.1:1025:1025"
- "127.0.0.1:8025:8025"
networks:
- acupedia-net
# ============================================================
# 5. Acupedia Backend API (FastAPI)
# ============================================================
backend:
build:
context: ${ACUPEDIA_API_PATH:-../acupedia-api}
dockerfile: Dockerfile
container_name: acupedia-api
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_started
minio:
condition: service_started
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
DATABASE_HOST: postgres
DATABASE_PORT: 5432
DATABASE_URL: ${DATABASE_URL}
SYNC_DATABASE_URL: ${SYNC_DATABASE_URL}
MINIO_ENDPOINT: ${MINIO_ENDPOINT}
MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY}
MINIO_SECRET_KEY: ${MINIO_SECRET_KEY}
MINIO_SECURE: "${MINIO_SECURE:-false}"
MINIO_BUCKET: ${MINIO_BUCKET_NAME:-accupedia-media}
MEDIA_STORAGE_SECURE: ${MEDIA_STORAGE_SECURE:-true}
MEDIA_PRESIGN_ENDPOINT: ${MEDIA_PRESIGN_ENDPOINT:-https://api.acupedia.in}
MEDIA_STORAGE_ACCESS_KEY: ${MINIO_ACCESS_KEY}
MEDIA_STORAGE_SECRET_KEY: ${MINIO_SECRET_KEY}
MEDIA_STORAGE_BUCKET: ${MINIO_BUCKET_NAME:-accupedia-media}
MEDIA_STORAGE_REGION: ${MEDIA_STORAGE_REGION:-us-east-1}
MEDIA_URL_TTL_SECONDS: ${MEDIA_URL_TTL_SECONDS:-900}
REDIS_HOST: redis
REDIS_PORT: ${REDIS_PORT:-6379}
REDIS_PASSWORD: ${REDIS_PASSWORD}
REDIS_URL: redis://:${REDIS_PASSWORD}@redis:6379/0
CACHE_ENABLED: "true"
CACHE_REDIS_URL: redis://:${REDIS_PASSWORD}@redis:6379/0
SMTP_HOST: ${SMTP_HOST:-mailhog}
SMTP_PORT: ${SMTP_PORT:-1025}
JWT_SECRET: ${JWT_SECRET}
ACCESS_TOKEN_EXPIRE_MINUTES: ${ACCESS_TOKEN_EXPIRE_MINUTES:-1440}
RAZORPAY_KEY_ID: ${RAZORPAY_KEY_ID}
RAZORPAY_KEY_SECRET: ${RAZORPAY_KEY_SECRET}
RESEND_API_KEY: ${RESEND_API_KEY}
ENVIRONMENT: production
ports:
# Bound to localhost for local testing (Nginx proxies all public API traffic)
- "127.0.0.1:${BACKEND_PORT:-8000}:8000"
volumes: volumes:
- acupedia-content-data:/app/data - ${CONTENT_PATH:-../acupedia-content}:/app/content:ro
networks:
- acupedia-net
# ============================================================
# 6. Storefront Web App (Vite/React)
# ============================================================
store:
build:
context: ${ACUPEDIA_STORE_PATH:-../acupedia_store_ui}
dockerfile: Dockerfile
args:
VITE_BASE_PATH: ${VITE_STORE_BASE_PATH:-/store/}
container_name: acupedia-store
restart: unless-stopped
depends_on:
- backend
ports:
# Bound to localhost only (Nginx handles public traffic)
- "127.0.0.1:${STORE_PORT:-3000}:80"
networks:
- acupedia-net
# ============================================================
# 7. Admin Portal Web App (Vite/React)
# ============================================================
admin:
build:
context: ${ACUPEDIA_ADMIN_PATH:-../acupedia_web_ui}
dockerfile: Dockerfile
args:
VITE_BASE_PATH: ${VITE_ADMIN_BASE_PATH:-/admin/}
container_name: acupedia-admin
restart: unless-stopped
depends_on:
- backend
ports:
# Bound to localhost only (Nginx handles public traffic)
- "127.0.0.1:${ADMIN_PORT:-3001}:80"
networks:
- acupedia-net
# ============================================================
# 8. Central Nginx Reverse Proxy (Only public gateway)
# ============================================================
nginx:
image: nginx:alpine
container_name: acupedia-nginx
restart: unless-stopped
depends_on:
- backend
- store
- admin
- minio
ports:
# The ONLY services exposed to the public internet
- "${HTTP_PORT:-80}:80"
- "${HTTPS_PORT:-443}:443"
volumes:
- ./config/nginx/acupedia.conf:/etc/nginx/conf.d/default.conf:ro
- /etc/letsencrypt:/etc/letsencrypt:ro
- /var/www/certbot:/var/www/certbot
networks:
- acupedia-net
volumes: volumes:
acupedia-postgres-data: acupedia-postgres-data:
acupedia-redis-data: driver: local
acupedia-minio-data: acupedia-minio-data:
acupedia-content-data: driver: local
acupedia-redis-data:
driver: local
networks:
acupedia-net:
driver: bridge

View File

@ -0,0 +1,282 @@
# Acupedia Platform — Windows QA Setup & Deployment Guide
This guide details the complete, one-time setup and regular deployment workflow for the **Windows QA Machine** (`Desktop\AcuPedia`) using the dedicated QA domain: **`qa.acupedia.in`**.
In this model:
- **No source code is shared or built on the QA machine.**
- All Docker container images are built on the Linux dev machine, exported to a compressed archive (`.tar.gz`), and transferred alongside a PostgreSQL database dump (`backup.sql`), the QA Nginx configuration (`acupedia.qa.conf`), and Let's Encrypt SSL certificates for `qa.acupedia.in`.
- Production (`acupedia.in`) and QA (`qa.acupedia.in`) environments remain **100% decoupled**.
---
## 📋 Table of Contents
1. [Overview & Prerequisites](#1-overview--prerequisites)
2. [DNS Setup: Adding the A Record for `qa.acupedia.in`](#2-dns-setup-adding-the-a-record-for-qaacupediain)
3. [Generating Let's Encrypt SSL Certificates for `qa.acupedia.in`](#3-generating-lets-encrypt-ssl-certificates-for-qaacupediain)
4. [What to Prepare on Linux Dev Machine (Packaging)](#4-what-to-prepare-on-linux-dev-machine-packaging)
5. [Target Directory Structure on Windows QA (`Desktop\AcuPedia`)](#5-target-directory-structure-on-windows-qa-desktopacupedia)
6. [Updating Nginx Configuration (`acupedia.qa.conf`)](#6-updating-nginx-configuration-acupediaqaconf)
7. [Step-by-Step QA Machine Setup (PowerShell)](#7-step-by-step-qa-machine-setup-powershell)
8. [SSL Certificate Auto-Renewal & Scheduled Task](#8-ssl-certificate-auto-renewal--scheduled-task)
9. [Accessing the QA Environment via HTTPS](#9-accessing-the-qa-environment-via-https)
10. [Quick Update Runbook (Future Deployments)](#10-quick-update-runbook-future-deployments)
---
## 1. Overview & Prerequisites
### Prerequisites on Windows QA Machine:
- **OS**: Windows 10/11 Pro or Enterprise (64-bit)
- **Docker Desktop**: Installed and running with **WSL 2 backend** enabled.
- **PowerShell**: Run as Administrator for initial setup.
- **Target Folder**: `Desktop\AcuPedia` (i.e. `$HOME\Desktop\AcuPedia`)
---
## 2. DNS Setup: Adding the A Record for `qa.acupedia.in`
In your DNS provider dashboard (Cloudflare, GoDaddy, Route53, Namecheap, etc.), add the DNS record pointing to your QA environment IP:
| Type | Name / Host | Value / Target | TTL |
| :--- | :--- | :--- | :--- |
| **A** | `qa` | `<QA_MACHINE_PUBLIC_OR_ROUTER_IP>` | Auto / 300s |
| **A** | `api-qa` *(optional)* | `<QA_MACHINE_PUBLIC_OR_ROUTER_IP>` | Auto / 300s |
> [!TIP]
> **If the QA machine is inside an office LAN without a public IP:**
> You can point `qa.acupedia.in` to the QA machine's local IP (e.g., `192.168.1.50`) in your office router DNS or client `hosts` files:
> `192.168.1.50 qa.acupedia.in api-qa.acupedia.in`
---
## 3. Generating Let's Encrypt SSL Certificates for `qa.acupedia.in`
Once the DNS record is pointing to the machine:
### Option A: Generate via Certbot on Linux Dev/VPS Machine (Recommended)
Run on your Linux machine:
```bash
sudo certbot certonly --standalone \
-d qa.acupedia.in \
-d api-qa.acupedia.in
```
The certificates will be generated at `/etc/letsencrypt/live/qa.acupedia.in/`:
- `fullchain.pem`
- `privkey.pem`
- `/etc/letsencrypt/options-ssl-nginx.conf`
- `/etc/letsencrypt/ssl-dhparams.pem`
### Option B: Generate using Docker Certbot on the Windows QA Machine
If ports 80 and 443 are forwarded to the Windows machine, run in PowerShell:
```powershell
docker run -it --rm -p 80:80 `
-v ${PWD}\certs:/etc/letsencrypt `
certbot/certbot certonly --standalone `
-d qa.acupedia.in -d api-qa.acupedia.in
```
---
## 4. What to Prepare on Linux Dev Machine (Packaging)
Build and export the deployment bundle on Linux before transferring to QA:
### Step 4.1: Generate Git Info & Build Images
```bash
cd ~/acupedia/acupedia_ops
./scripts/generate-git-info.sh
docker compose -f docker-compose.dev.yml build backend store admin
```
### Step 4.2: Export Docker Images to `.tar.gz`
```bash
docker save \
acupedia-ops-backend:latest \
acupedia-ops-store:latest \
acupedia-ops-admin:latest | gzip > ~/acupedia_images.tar.gz
```
### Step 4.3: Export Seeded Database Dump (`backup.sql`)
```bash
docker exec -t acupedia-postgres pg_dump -U db_admin -d acupedia_db > ~/backup.sql
```
### Step 4.4: Gather Config & Certificates
- QA Nginx configuration: `config/nginx/acupedia.qa.conf`
- Let's Encrypt certificates for `qa.acupedia.in`:
- `fullchain.pem`
- `privkey.pem`
- `options-ssl-nginx.conf`
- `ssl-dhparams.pem`
---
## 5. Target Directory Structure on Windows QA (`Desktop\AcuPedia`)
Place all transferred files on the Windows QA machine in this exact structure:
```text
Desktop\AcuPedia\
├── docker-compose.dev.yml # Compose file
├── .env # Environment variables
├── backup.sql # PostgreSQL database dump
├── acupedia_images.tar.gz # Exported Docker images archive
├── config\
│ └── nginx\
│ └── acupedia.qa.conf # QA Nginx gateway configuration (qa.acupedia.in)
└── certs\
├── options-ssl-nginx.conf # Let's Encrypt SSL options
├── ssl-dhparams.pem # Diffie-Hellman parameters
└── live\
└── qa.acupedia.in\
├── fullchain.pem # SSL fullchain certificate
└── privkey.pem # SSL private key
```
---
## 6. Updating Nginx Configuration (`acupedia.qa.conf`)
### Step 6.1: Verify the Compose File Volume Mount
In `Desktop\AcuPedia\docker-compose.dev.yml`, ensure the `nginx` service mounts the new `acupedia.qa.conf` and certificate directory:
```yaml
# 8. Central Nginx Reverse Proxy (QA Gateway)
nginx:
image: nginx:alpine
container_name: acupedia-nginx
restart: unless-stopped
depends_on:
- backend
- store
- admin
- minio
ports:
- "80:80"
- "443:443"
volumes:
- ./config/nginx/acupedia.qa.conf:/etc/nginx/conf.d/default.conf:ro
- ./certs:/etc/letsencrypt:ro
- ./certbot:/var/www/certbot
networks:
- acupedia-net
```
### Step 6.2: What `acupedia.qa.conf` Routes
The QA Nginx configuration handles all routes under `qa.acupedia.in`:
- `https://qa.acupedia.in/` $\rightarrow$ Storefront Frontend (`store:80`)
- `https://qa.acupedia.in/admin` $\rightarrow$ Admin Portal (`admin:80`)
- `https://qa.acupedia.in/api/` $\rightarrow$ Backend FastAPI (`backend:8000`)
- `https://qa.acupedia.in/docs` $\rightarrow$ FastAPI Swagger UI (`backend:8000/docs`)
- `https://qa.acupedia.in/acupedia-media/` $\rightarrow$ MinIO S3 Presigned Media (`minio:9000`)
- *(Optional)* `https://api-qa.acupedia.in/` $\rightarrow$ Dedicated API Subdomain (`backend:8000`)
---
## 7. Step-by-Step QA Machine Setup (PowerShell)
Open **PowerShell as Administrator** and navigate to the directory:
```powershell
cd $HOME\Desktop\AcuPedia
```
### Step 7.1: Load Docker Images
```powershell
docker load -i .\acupedia_images.tar.gz
```
*Verify with:* `docker images` — `acupedia-ops-backend`, `acupedia-ops-store`, and `acupedia-ops-admin` should be listed.
### Step 7.2: Start Database & Storage Containers
```powershell
docker compose -f docker-compose.dev.yml up -d postgres redis minio mailhog
```
Wait 10 seconds for PostgreSQL to report healthy:
```powershell
docker ps
```
### Step 7.3: Restore Database Dump
```powershell
Get-Content .\backup.sql | docker exec -i acupedia-postgres psql -U db_admin -d acupedia_db
```
### Step 7.4: Start All Services (Including QA Nginx)
```powershell
docker compose -f docker-compose.dev.yml up -d
```
### Step 7.5: Verify Container Health & Embedded Git Metadata
```powershell
# 1. Check all container statuses
docker ps
# 2. Inspect embedded Git branch & commit in each container
docker exec acupedia-api cat /app/.git_api_info
docker exec acupedia-store cat /app/.git_store_info
docker exec acupedia-admin cat /app/.git_admin_info
# 3. Check Nginx logs to ensure SSL loaded with 0 errors
docker logs acupedia-nginx --tail 20
```
---
## 8. SSL Certificate Auto-Renewal & Scheduled Task
Certificates from Let's Encrypt are valid for 90 days.
### Method 1: Automated Renewal via Windows Task Scheduler (If Publicly Accessible)
Run once in Administrator PowerShell:
```powershell
$Action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-Command `"cd `$HOME\Desktop\AcuPedia; docker run --rm -v `$PWD\certs:/etc/letsencrypt -v `$PWD\certbot:/var/www/certbot certbot/certbot renew --webroot -w /var/www/certbot; docker restart acupedia-nginx`""
$Trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Sunday -At 3am
Register-ScheduledTask -TaskName "AcupediaQACertbotRenewal" -Action $Action -Trigger $Trigger -User "SYSTEM"
```
### Method 2: Manual Certificate Update (If Behind Office Router)
When certificates renew on your Linux server, simply replace the two files on Windows:
- `Desktop\AcuPedia\certs\live\qa.acupedia.in\fullchain.pem`
- `Desktop\AcuPedia\certs\live\qa.acupedia.in\privkey.pem`
Then reload Nginx:
```powershell
docker restart acupedia-nginx
```
---
## 9. Accessing the QA Environment via HTTPS
Once running, any developer, tester, or mobile device can access the environment over secure HTTPS:
| Application | URL | Description |
| :--- | :--- | :--- |
| **Storefront Web App** | `https://qa.acupedia.in/` | Customer storefront (React/Vite) |
| **Admin Portal** | `https://qa.acupedia.in/admin/` | Management console |
| **Backend Swagger Docs** | `https://qa.acupedia.in/docs` | Interactive API documentation |
| **Backend API Root** | `https://qa.acupedia.in/api/` | REST API endpoints |
| **Dedicated API (Optional)** | `https://api-qa.acupedia.in/` | Dedicated subdomain API |
---
## 10. Quick Update Runbook (Future Deployments)
When a new update or bugfix is ready for QA, follow this 3-step routine:
### On Linux (Dev Machine):
```bash
./scripts/generate-git-info.sh
docker compose -f docker-compose.dev.yml build backend store admin
docker save acupedia-ops-backend:latest acupedia-ops-store:latest acupedia-ops-admin:latest | gzip > acupedia_images.tar.gz
# Send acupedia_images.tar.gz to QA machine
```
### On Windows QA (PowerShell):
```powershell
cd $HOME\Desktop\AcuPedia
docker load -i .\acupedia_images.tar.gz
docker compose -f docker-compose.dev.yml up -d --no-build backend store admin
docker ps
```
The QA environment is now updated, and running `docker exec acupedia-api cat /app/.git_api_info` confirms the exact new Git commit!

View File

@ -1,6 +1,6 @@
# Local development # Local development
`acupedia-ops local ...` coordinates the local AccuPedia workspace. It does not `acupedia-ops local ...` coordinates the local AcuPedia workspace. It does not
replace the native development tools used by each repository. replace the native development tools used by each repository.
## Workspace model ## Workspace model

39
docs/remote-deployment.md Normal file
View File

@ -0,0 +1,39 @@
# Remote deployment foundation
AcuPedia remote environments are provisioned with Ansible through `ansible-runner`. Docker Compose is the runtime deployment mechanism on each target host.
## Topology
Inventory groups describe service roles: `backend`, `database`, `redis`, and `proxy`. `docker_hosts` is the aggregate group used for common host preparation. A host can belong to one or several service groups, so dev can be a single machine while production can split services across machines.
Compose is host-local. Do not assume Docker Compose service DNS works between separate servers; cross-host service endpoints must use private network DNS/IP addresses and appropriate access controls.
## Initial setup
Install deployment dependencies locally:
```bash
pip install -e ".[deployment]"
```
Edit `ansible/inventories/<environment>/hosts.yml`, including `ansible_user` or SSH variables as required. Do not commit passwords, tokens, database credentials, or application secrets to inventory.
Validate SSH, facts, supported OS, and privilege escalation:
```bash
acupedia-ops remote preflight --env dev
```
Prepare the hosts idempotently:
```bash
acupedia-ops remote prepare --env dev
```
Use `--limit <host-or-group>` to restrict execution and `--check` with `prepare` for Ansible check mode. `-v` through `-vvvv` increases Ansible verbosity.
## Host state created by prepare
The initial implementation supports Debian/Ubuntu hosts. It installs common packages, creates the `acupedia` system account and `/opt/acupedia` hierarchy, installs Docker Engine from the distribution packages, installs the Docker Compose v2 plugin, enables Docker, and verifies `docker compose`.
The application/database/Redis/proxy Compose deployments are deliberately not part of this foundation and remain separate subsequent roles.

View File

@ -5,13 +5,14 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "acupedia-ops" name = "acupedia-ops"
version = "0.2.0" version = "0.2.0"
description = "Operational data-processing and deployment tooling for AccuPedia" description = "Operational data-processing and deployment tooling for AcuPedia"
readme = "README.md" readme = "README.md"
requires-python = ">=3.11" requires-python = ">=3.11"
dependencies = [ dependencies = [
"numpy>=2.0,<3.0", "numpy>=2.0,<3.0",
"opencv-python-headless>=4.10,<5.0", "opencv-python-headless>=4.10,<5.0",
"PyYAML>=6.0,<7.0", "PyYAML>=6.0,<7.0",
"ansible-runner>=2.4,<3.0",
] ]
[project.optional-dependencies] [project.optional-dependencies]

49
scripts/generate-git-info.sh Executable file
View File

@ -0,0 +1,49 @@
#!/usr/bin/env bash
# ============================================================
# Generate Git metadata files for API, Storefront, and Admin
# ============================================================
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OPS_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
cd "${OPS_DIR}"
# Load environment file if present to resolve custom repo paths
if [ -f .env ]; then
export $(grep -v '^#' .env | grep -v '^\s*$' | xargs -d '\n' 2>/dev/null || true)
fi
API_PATH="${ACUPEDIA_API_PATH:-../../acupedia-api}"
STORE_PATH="${ACUPEDIA_STORE_PATH:-../../acupedia_store_ui}"
ADMIN_PATH="${ACUPEDIA_ADMIN_PATH:-../../acupedia_web_ui}"
# 1. Acupedia API
if [ -d "${API_PATH}/.git" ]; then
echo "Branch: $(git -C "${API_PATH}" rev-parse --abbrev-ref HEAD)" > "${API_PATH}/.git_api_info"
echo "Commit: $(git -C "${API_PATH}" rev-parse HEAD)" >> "${API_PATH}/.git_api_info"
echo "✅ Generated: ${API_PATH}/.git_api_info"
else
echo "⚠️ Skipping API: ${API_PATH}/.git not found"
fi
# 2. Acupedia Storefront
if [ -d "${STORE_PATH}/.git" ]; then
echo "Branch: $(git -C "${STORE_PATH}" rev-parse --abbrev-ref HEAD)" > "${STORE_PATH}/.git_store_info"
echo "Commit: $(git -C "${STORE_PATH}" rev-parse HEAD)" >> "${STORE_PATH}/.git_store_info"
echo "✅ Generated: ${STORE_PATH}/.git_store_info"
else
echo "⚠️ Skipping Storefront: ${STORE_PATH}/.git not found"
fi
# 3. Acupedia Admin (Web UI)
if [ -d "${ADMIN_PATH}/.git" ]; then
echo "Branch: $(git -C "${ADMIN_PATH}" rev-parse --abbrev-ref HEAD)" > "${ADMIN_PATH}/.git_admin_info"
echo "Commit: $(git -C "${ADMIN_PATH}" rev-parse HEAD)" >> "${ADMIN_PATH}/.git_admin_info"
echo "✅ Generated: ${ADMIN_PATH}/.git_admin_info"
else
echo "⚠️ Skipping Admin: ${ADMIN_PATH}/.git not found"
fi
echo "Done! You can now run: docker compose -f docker-compose.dev.yml up --build"

59
seaweedfs.yml Normal file
View File

@ -0,0 +1,59 @@
version: '3.9'
services:
master:
image: chrislusf/seaweedfs # use a remote image
ports:
- 9333:9333
- 19333:19333
- 9324:9324
command: 'master -ip=master -ip.bind=0.0.0.0 -metricsPort=9324'
volume:
image: chrislusf/seaweedfs # use a remote image
ports:
- 8080:8080
- 18080:18080
- 9325:9325
command: 'volume -ip=volume -master="master:9333" -ip.bind=0.0.0.0 -port=8080 -metricsPort=9325'
depends_on:
- master
filer:
image: chrislusf/seaweedfs # use a remote image
ports:
- 8888:8888
- 18888:18888
- 9326:9326
command: 'filer -ip=filer -master="master:9333" -ip.bind=0.0.0.0 -metricsPort=9326'
tty: true
stdin_open: true
depends_on:
- master
- volume
s3:
image: chrislusf/seaweedfs # use a remote image
ports:
- 8333:8333
- 9327:9327
command: 's3 -filer="filer:8888" -ip.bind=0.0.0.0 -metricsPort=9327'
depends_on:
- master
- volume
- filer
webdav:
image: chrislusf/seaweedfs # use a remote image
ports:
- 7333:7333
command: 'webdav -filer="filer:8888"'
depends_on:
- master
- volume
- filer
admin:
image: chrislusf/seaweedfs:dev # use a remote dev image
ports:
- 23646:23646
command: 'admin -master=master:9333'
depends_on:
- master
- volume
- filer

View File

@ -5,8 +5,8 @@ from acupedia_ops.common.config import load_config
def test_load_config(tmp_path: Path) -> None: def test_load_config(tmp_path: Path) -> None:
(tmp_path / "dev.yaml").write_text( (tmp_path / "dev.yaml").write_text(
"backend:\n application_name: accupedia-api\n", "backend:\n application_name: acupedia-api\n",
encoding="utf-8", encoding="utf-8",
) )
config = load_config("dev", config_root=tmp_path) config = load_config("dev", config_root=tmp_path)
assert config.values["backend"]["application_name"] == "accupedia-api" assert config.values["backend"]["application_name"] == "acupedia-api"

View File

@ -11,6 +11,7 @@ name = "acupedia-ops"
version = "0.2.0" version = "0.2.0"
source = { editable = "." } source = { editable = "." }
dependencies = [ dependencies = [
{ name = "ansible-runner" },
{ name = "numpy", version = "2.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" }, { name = "numpy", version = "2.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" },
{ name = "numpy", version = "2.5.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" }, { name = "numpy", version = "2.5.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
{ name = "opencv-python-headless" }, { name = "opencv-python-headless" },
@ -27,6 +28,7 @@ dev = [
[package.metadata] [package.metadata]
requires-dist = [ requires-dist = [
{ name = "ansible-runner", specifier = ">=2.4,<3.0" },
{ name = "ansible-runner", marker = "extra == 'deployment'", specifier = ">=2.4,<3.0" }, { name = "ansible-runner", marker = "extra == 'deployment'", specifier = ">=2.4,<3.0" },
{ name = "numpy", specifier = ">=2.0,<3.0" }, { name = "numpy", specifier = ">=2.0,<3.0" },
{ name = "opencv-python-headless", specifier = ">=4.10,<5.0" }, { name = "opencv-python-headless", specifier = ">=4.10,<5.0" },