Compare commits
No commits in common. "main" and "vps-data-fix" have entirely different histories.
main
...
vps-data-f
|
|
@ -1,4 +1,4 @@
|
|||
# Local AcuPedia workspace.
|
||||
# Local AccuPedia workspace.
|
||||
# Copy this file to .env and adjust for your machine.
|
||||
#
|
||||
# Do NOT commit .env.
|
||||
|
|
|
|||
|
|
@ -39,18 +39,11 @@ With the clean Acupedia naming conventions:
|
|||
- **Database**: `acupedia_db`
|
||||
- **User**: `db_admin` / Password: `C1234spl`
|
||||
- **Volumes**: `acupedia-postgres-data`, `acupedia-minio-data`
|
||||
- **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`:
|
||||
- **MinIO Bucket**: `accupedia-media`
|
||||
|
||||
### Start the containers:
|
||||
```bash
|
||||
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
|
||||
```
|
||||
|
||||
|
|
@ -96,7 +89,7 @@ docker compose -f docker-compose.dev.yml exec backend \
|
|||
---
|
||||
|
||||
### 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 (`acupedia-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 (`accupedia-media` bucket) and links them to their respective content items in PostgreSQL:
|
||||
|
||||
**Option A (Recommended — Automated 1-line loop for all 4 modules):**
|
||||
```bash
|
||||
|
|
@ -147,8 +140,13 @@ docker compose -f docker-compose.dev.yml exec backend \
|
|||
|
||||
---
|
||||
|
||||
<<<<<<< HEAD
|
||||
### Step 3.6: Validate Database Integrity
|
||||
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
|
||||
docker compose -f docker-compose.dev.yml exec backend \
|
||||
|
|
@ -193,25 +191,3 @@ After running the manual steps above, test your endpoints:
|
|||
| **Admin Portal** | `3001` | `http://<IP_OR_DOMAIN>:3001/admin/` |
|
||||
| **MinIO Console** | `9001` | `http://<IP_OR_DOMAIN>:9001` (`minioadmin` / `minioadmin`) |
|
||||
| **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
|
||||
```
|
||||
|
||||
|
|
|
|||
13
README.md
13
README.md
|
|
@ -1,6 +1,6 @@
|
|||
# acupedia-ops
|
||||
|
||||
Operational tooling for AcuPedia.
|
||||
Operational tooling for AccuPedia.
|
||||
|
||||
The repository owns:
|
||||
|
||||
|
|
@ -260,14 +260,3 @@ python3 diff.py \
|
|||
--no-new-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.
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
"""AcuPedia operational tooling."""
|
||||
"""AccuPedia operational tooling."""
|
||||
__version__ = "0.1.0"
|
||||
|
|
|
|||
|
|
@ -1,110 +1,14 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, Mapping
|
||||
|
||||
from typing import Any
|
||||
from acupedia_ops.common.paths import ansible_root
|
||||
|
||||
try:
|
||||
import ansible_runner
|
||||
except ImportError as exc:
|
||||
raise RuntimeError(
|
||||
'Install deployment support with: pip install -e ".[deployment]"'
|
||||
) from exc
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
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
|
||||
def run_playbook(*, playbook: str, inventory: str, extra_vars: dict[str, Any] | None = None) -> None:
|
||||
try:
|
||||
import ansible_runner
|
||||
except ImportError as exc:
|
||||
raise RuntimeError('Install deployment support with: pip install -e ".[deployment]"') from exc
|
||||
root = ansible_root(); inventory_path = root / "inventories" / inventory; playbook_path = root / "playbooks" / playbook
|
||||
if not inventory_path.exists(): raise FileNotFoundError(f"Inventory not found: {inventory_path}")
|
||||
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 {})
|
||||
if result.rc != 0: raise RuntimeError(f"Ansible playbook failed with exit code {result.rc}: {playbook_path}")
|
||||
|
|
|
|||
|
|
@ -28,20 +28,20 @@ def resolve_api_root(api_root: Path | None = None) -> Path:
|
|||
raw = os.environ.get("ACUPEDIA_API_PATH", "").strip()
|
||||
if not raw:
|
||||
raise RuntimeError(
|
||||
"AcuPedia API path is required. Supply --api-root or set "
|
||||
"AccuPedia API path is required. Supply --api-root or set "
|
||||
"ACUPEDIA_API_PATH."
|
||||
)
|
||||
root = resolve_workspace_path(raw, base_path=base)
|
||||
|
||||
if not root.is_dir():
|
||||
raise FileNotFoundError(f"AcuPedia API repository not found: {root}")
|
||||
raise FileNotFoundError(f"AccuPedia API repository not found: {root}")
|
||||
|
||||
if not (root / "app").is_dir():
|
||||
raise ValueError(f"Invalid AcuPedia API repository; missing: {root / 'app'}")
|
||||
raise ValueError(f"Invalid AccuPedia API repository; missing: {root / 'app'}")
|
||||
|
||||
if not (root / "pyproject.toml").is_file():
|
||||
raise ValueError(
|
||||
f"Invalid AcuPedia API repository; missing: {root / 'pyproject.toml'}"
|
||||
f"Invalid AccuPedia API repository; missing: {root / 'pyproject.toml'}"
|
||||
)
|
||||
|
||||
return root
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ from acupedia_ops.common.paths import repo_root
|
|||
from acupedia_ops.data.image.clean_image_borders import process_path
|
||||
from acupedia_ops.deployment.backend import deploy_backend
|
||||
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.local.bootstrap import local_bootstrap
|
||||
from acupedia_ops.local.database import reset_local_database
|
||||
|
|
@ -34,7 +33,7 @@ LOCAL_COMPONENTS = ("api", "mobile", "web", "admin")
|
|||
def _build_parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="acupedia-ops",
|
||||
description="AcuPedia operational tooling",
|
||||
description="AccuPedia operational tooling",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--env-file",
|
||||
|
|
@ -197,17 +196,6 @@ def _build_parser() -> argparse.ArgumentParser:
|
|||
database = deploy_sub.add_parser("database")
|
||||
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 --------------------------------------------
|
||||
runner = subparsers.add_parser("runner")
|
||||
runner_sub = runner.add_subparsers(dest="runner_command", required=True)
|
||||
|
|
@ -405,14 +393,6 @@ def main() -> None:
|
|||
deploy_database(environment=args.env)
|
||||
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":
|
||||
token = args.registration_token
|
||||
if not token:
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ def workspace_base_path(
|
|||
*,
|
||||
required: bool = True,
|
||||
) -> Path | None:
|
||||
"""Return the AcuPedia workspace base path.
|
||||
"""Return the AccuPedia workspace base path.
|
||||
|
||||
Resolution order:
|
||||
1. explicit value
|
||||
|
|
@ -31,7 +31,7 @@ def workspace_base_path(
|
|||
if not raw:
|
||||
if required:
|
||||
raise RuntimeError(
|
||||
f"{WORKSPACE_BASE_ENV} is required for relative AcuPedia paths."
|
||||
f"{WORKSPACE_BASE_ENV} is required for relative AccuPedia paths."
|
||||
)
|
||||
return None
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ def resolve_workspace_path(
|
|||
*,
|
||||
base_path: Path | None = None,
|
||||
) -> Path:
|
||||
"""Resolve an AcuPedia path deterministically.
|
||||
"""Resolve an AccuPedia path deterministically.
|
||||
|
||||
Absolute paths are used as-is.
|
||||
Relative paths are always resolved against ACUPEDIA_WORKSPACE_BASE_PATH,
|
||||
|
|
|
|||
|
|
@ -1,45 +1,85 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from typing import Any, Sequence
|
||||
|
||||
import yaml
|
||||
|
||||
from acupedia_ops.common.paths import repo_root
|
||||
from acupedia_ops.ansible.runner import run_playbook
|
||||
from typing import Sequence
|
||||
|
||||
|
||||
def _repo_root() -> Path:
|
||||
"""Backward-compatible repository root helper."""
|
||||
return repo_root()
|
||||
return Path(__file__).resolve().parents[2]
|
||||
|
||||
|
||||
def _parse_extra_vars(values: Sequence[str]) -> dict[str, Any]:
|
||||
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 _ansible_playbook() -> str:
|
||||
return os.environ.get("ANSIBLE_PLAYBOOK_BIN", "ansible-playbook")
|
||||
|
||||
|
||||
def provision_runner(*, inventory: Path, registration_token: str, limit: str | None = None,
|
||||
extra_vars: Sequence[str] = (), force_reregister: bool = False) -> None:
|
||||
variables = _parse_extra_vars(extra_vars)
|
||||
variables["gitea_runner_registration_token"] = registration_token
|
||||
def provision_runner(
|
||||
*,
|
||||
inventory: Path,
|
||||
registration_token: str,
|
||||
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:
|
||||
variables["gitea_runner_force_reregister"] = True
|
||||
run_playbook(playbook="gitea-runner.yml", inventory=inventory, extra_vars=variables, limit=limit)
|
||||
command.extend(
|
||||
[
|
||||
"--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(*, inventory: Path, limit: str | None = None, remove_data: bool = False,
|
||||
extra_vars: Sequence[str] = ()) -> None:
|
||||
variables = _parse_extra_vars(extra_vars)
|
||||
def remove_runner(
|
||||
*,
|
||||
inventory: Path,
|
||||
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:
|
||||
variables["gitea_runner_remove_data"] = True
|
||||
run_playbook(playbook="gitea-runner-remove.yml", inventory=inventory, extra_vars=variables, limit=limit)
|
||||
command.extend(
|
||||
[
|
||||
"--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)
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
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)
|
||||
|
|
@ -23,7 +23,6 @@ def run_component(
|
|||
component: str,
|
||||
) -> None:
|
||||
config = workspace.components[component]
|
||||
print(config)
|
||||
if not config.run_command:
|
||||
raise RuntimeError(
|
||||
f"No run command configured for local component: {component}"
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
---
|
||||
acupedia_environment: dev
|
||||
acupedia_root: /opt/acupedia
|
||||
|
|
@ -1,23 +1,5 @@
|
|||
---
|
||||
# A single dev host may belong to every service group. Replace the example host
|
||||
# and address before use.
|
||||
all:
|
||||
hosts:
|
||||
acupedia-dev:
|
||||
ansible_host: 10.10.0.20
|
||||
children:
|
||||
docker_hosts:
|
||||
hosts:
|
||||
acupedia-dev:
|
||||
backend:
|
||||
hosts:
|
||||
acupedia-dev:
|
||||
database:
|
||||
hosts:
|
||||
acupedia-dev:
|
||||
redis:
|
||||
hosts:
|
||||
acupedia-dev:
|
||||
proxy:
|
||||
hosts:
|
||||
acupedia-dev:
|
||||
hosts: {}
|
||||
|
|
|
|||
|
|
@ -19,4 +19,4 @@ all:
|
|||
|
||||
vars:
|
||||
ansible_user: ops
|
||||
gitea_runner_instance_url: "https://git.zedobject.local"
|
||||
gitea_runner_instance_url: "https://gitea.example.com"
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
---
|
||||
acupedia_environment: prod
|
||||
acupedia_root: /opt/acupedia
|
||||
|
|
@ -1,19 +1,5 @@
|
|||
---
|
||||
# Service groups are intentionally independent: production services may live
|
||||
# on separate hosts. A host may also be placed in multiple groups.
|
||||
all:
|
||||
children:
|
||||
docker_hosts:
|
||||
children:
|
||||
backend: {}
|
||||
database: {}
|
||||
redis: {}
|
||||
proxy: {}
|
||||
backend:
|
||||
hosts: {}
|
||||
database:
|
||||
hosts: {}
|
||||
redis:
|
||||
hosts: {}
|
||||
proxy:
|
||||
hosts: {}
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
---
|
||||
acupedia_environment: staging
|
||||
acupedia_root: /opt/acupedia
|
||||
|
|
@ -1,18 +1,5 @@
|
|||
---
|
||||
# Replace addresses/hosts with the staging topology.
|
||||
all:
|
||||
children:
|
||||
docker_hosts:
|
||||
children:
|
||||
backend: {}
|
||||
database: {}
|
||||
redis: {}
|
||||
proxy: {}
|
||||
backend:
|
||||
hosts: {}
|
||||
database:
|
||||
hosts: {}
|
||||
redis:
|
||||
hosts: {}
|
||||
proxy:
|
||||
hosts: {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- name: Deploy AcuPedia backend
|
||||
- name: Deploy AccuPedia backend
|
||||
hosts: backend
|
||||
gather_facts: true
|
||||
tasks:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- name: Deploy AcuPedia database changes
|
||||
- name: Deploy AccuPedia database changes
|
||||
hosts: backend
|
||||
gather_facts: true
|
||||
tasks:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- name: Provision AcuPedia infrastructure
|
||||
- name: Provision AccuPedia infrastructure
|
||||
hosts: all
|
||||
gather_facts: true
|
||||
tasks:
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
---
|
||||
- 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
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
---
|
||||
- name: Prepare AcuPedia Docker hosts
|
||||
hosts: docker_hosts
|
||||
gather_facts: true
|
||||
roles:
|
||||
- role: common
|
||||
- role: docker
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
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
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
---
|
||||
- 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
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
acupedia_docker_packages:
|
||||
- docker.io
|
||||
- docker-compose-v2
|
||||
acupedia_docker_service: docker
|
||||
acupedia_docker_users: []
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
---
|
||||
- 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
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
environment: dev
|
||||
backend:
|
||||
application_name: acupedia-api
|
||||
application_name: accupedia-api
|
||||
database:
|
||||
run_migrations: true
|
||||
infra: {}
|
||||
|
|
|
|||
|
|
@ -1,166 +0,0 @@
|
|||
# ==============================================================================
|
||||
# Acupedia Platform — Central Containerized Nginx Gateway Configuration
|
||||
# File: config/nginx/acupedia.conf
|
||||
#
|
||||
# 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 acupedia.in www.acupedia.in 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. Dedicated API Subdomain (api.acupedia.in)
|
||||
# ==============================================================================
|
||||
server {
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
server_name api.acupedia.in;
|
||||
|
||||
# SSL Certificates (Mounted from host /etc/letsencrypt)
|
||||
ssl_certificate /etc/letsencrypt/live/acupedia.in/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/acupedia.in/privkey.pem;
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
||||
|
||||
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;
|
||||
|
||||
# If opened in a browser from the mobile app, redirect to main storefront
|
||||
location /cart {
|
||||
return 301 https://acupedia.in$request_uri;
|
||||
}
|
||||
|
||||
location /checkout {
|
||||
return 301 https://acupedia.in$request_uri;
|
||||
}
|
||||
|
||||
# MinIO S3 Presigned Media Proxy (/accupedia-media/ and /acupedia-media/)
|
||||
location /accupedia-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;
|
||||
}
|
||||
|
||||
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. Main Domain: Storefront (/) and Admin Panel (/admin)
|
||||
# ==============================================================================
|
||||
server {
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
server_name acupedia.in www.acupedia.in;
|
||||
|
||||
# SSL Certificates (Mounted from host /etc/letsencrypt)
|
||||
ssl_certificate /etc/letsencrypt/live/acupedia.in/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/acupedia.in/privkey.pem;
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
||||
|
||||
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 (acupedia.in/api/ -> avoids CORS)
|
||||
location /api/ {
|
||||
proxy_pass http://backend_api/api/;
|
||||
}
|
||||
|
||||
# Storefront Customer Web App (/)
|
||||
location / {
|
||||
proxy_pass http://store_app;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,178 +0,0 @@
|
|||
# ==============================================================================
|
||||
# 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
environment: prod
|
||||
backend:
|
||||
application_name: acupedia-api
|
||||
application_name: accupedia-api
|
||||
database:
|
||||
run_migrations: true
|
||||
infra: {}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
environment: staging
|
||||
backend:
|
||||
application_name: acupedia-api
|
||||
application_name: accupedia-api
|
||||
database:
|
||||
run_migrations: true
|
||||
infra: {}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ services:
|
|||
POSTGRES_USER: ${POSTGRES_USER:-db_admin}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-C1234spl}
|
||||
ports:
|
||||
# Bound strictly to 127.0.0.1 (Localhost only - safe from other LAN/remote PCs)
|
||||
- "127.0.0.1:${POSTGRES_PORT:-5432}:5432"
|
||||
- "${POSTGRES_PORT:-5432}:5432"
|
||||
volumes:
|
||||
- acupedia-postgres-data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
|
|
@ -30,10 +29,8 @@ services:
|
|||
image: redis:7-alpine
|
||||
container_name: acupedia-redis
|
||||
restart: unless-stopped
|
||||
command: redis-server --requirepass "${REDIS_PASSWORD:-AcupediaSecureRedis2026!#}"
|
||||
ports:
|
||||
# Bound strictly to 127.0.0.1
|
||||
- "127.0.0.1:${REDIS_PORT:-6379}:6379"
|
||||
- "${REDIS_PORT:-6379}:6379"
|
||||
volumes:
|
||||
- acupedia-redis-data:/data
|
||||
networks:
|
||||
|
|
@ -51,9 +48,8 @@ services:
|
|||
MINIO_ROOT_USER: ${MINIO_ACCESS_KEY:-minioadmin}
|
||||
MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY:-minioadmin}
|
||||
ports:
|
||||
# Bound strictly to 127.0.0.1 - Nginx proxies public /acupedia-media/ requests
|
||||
- "127.0.0.1:${MINIO_PORT:-9000}:9000"
|
||||
- "127.0.0.1:${MINIO_CONSOLE_PORT:-9001}:9001"
|
||||
- "${MINIO_PORT:-9000}:9000"
|
||||
- "${MINIO_CONSOLE_PORT:-9001}:9001"
|
||||
volumes:
|
||||
- acupedia-minio-data:/data
|
||||
networks:
|
||||
|
|
@ -67,9 +63,8 @@ services:
|
|||
container_name: acupedia-mailhog
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
# Bound strictly to 127.0.0.1 so email UI is not exposed publicly
|
||||
- "127.0.0.1:1025:1025" # SMTP port
|
||||
- "127.0.0.1:8025:8025" # Web UI port
|
||||
- "1025:1025" # SMTP port
|
||||
- "8025:8025" # Web UI port
|
||||
networks:
|
||||
- acupedia-net
|
||||
|
||||
|
|
@ -77,7 +72,6 @@ services:
|
|||
# 5. Acupedia Backend API (FastAPI)
|
||||
# ============================================================
|
||||
backend:
|
||||
image: acupedia-ops-backend:latest
|
||||
build:
|
||||
context: ${ACUPEDIA_API_PATH:-../../acupedia-api}
|
||||
dockerfile: Dockerfile
|
||||
|
|
@ -102,20 +96,18 @@ services:
|
|||
MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY:-minioadmin}
|
||||
MINIO_SECRET_KEY: ${MINIO_SECRET_KEY:-minioadmin}
|
||||
MINIO_SECURE: "false"
|
||||
MINIO_BUCKET: ${MINIO_BUCKET_NAME:-acupedia-media}
|
||||
MEDIA_STORAGE_SECURE: ${MEDIA_STORAGE_SECURE:-true}
|
||||
MEDIA_PRESIGN_ENDPOINT: ${MEDIA_PRESIGN_ENDPOINT:-https://qa.acupedia.in}
|
||||
MINIO_BUCKET: ${MINIO_BUCKET_NAME:-accupedia-media}
|
||||
MEDIA_PRESIGN_ENDPOINT: ${MEDIA_PRESIGN_ENDPOINT:-http://localhost:9000}
|
||||
MEDIA_STORAGE_ACCESS_KEY: ${MINIO_ACCESS_KEY:-minioadmin}
|
||||
MEDIA_STORAGE_SECRET_KEY: ${MINIO_SECRET_KEY:-minioadmin}
|
||||
MEDIA_STORAGE_BUCKET: ${MINIO_BUCKET_NAME:-acupedia-media}
|
||||
MEDIA_STORAGE_BUCKET: ${MINIO_BUCKET_NAME:-accupedia-media}
|
||||
MEDIA_STORAGE_REGION: us-east-1
|
||||
MEDIA_URL_TTL_SECONDS: 900
|
||||
REDIS_HOST: redis
|
||||
REDIS_PORT: 6379
|
||||
REDIS_PASSWORD: ${REDIS_PASSWORD:-AcupediaSecureRedis2026!#}
|
||||
REDIS_URL: redis://:${REDIS_PASSWORD:-AcupediaSecureRedis2026!#}@redis:6379/0
|
||||
REDIS_URL: redis://redis:6379/0
|
||||
CACHE_ENABLED: "true"
|
||||
CACHE_REDIS_URL: redis://:${REDIS_PASSWORD:-AcupediaSecureRedis2026!#}@redis:6379/0
|
||||
CACHE_REDIS_URL: redis://redis:6379/0
|
||||
SMTP_HOST: mailhog
|
||||
SMTP_PORT: 1025
|
||||
JWT_SECRET: ${JWT_SECRET:-b4f8c9b3d0a2f4c9b3d0a2f4c9b3d0a2f4c9b3d0a2f4c9b3d0a2f4c9b3d0a2f4}
|
||||
|
|
@ -123,11 +115,9 @@ services:
|
|||
RAZORPAY_KEY_ID: ${RAZORPAY_KEY_ID:-rzp_test_TRwmEntw35BIrL}
|
||||
RAZORPAY_KEY_SECRET: ${RAZORPAY_KEY_SECRET:-vsB1RYs6J1S4EtK0u8zuZuaL}
|
||||
RESEND_API_KEY: ${RESEND_API_KEY:-re_YHvSXRCz_LrQYzEYEDVwoRiAgfJRsH6ya}
|
||||
CONTENT_PREVIEW_ENABLED: ${CONTENT_PREVIEW_ENABLED:-true}
|
||||
ENVIRONMENT: ${ENVIRONMENT:-production}
|
||||
ports:
|
||||
# Bound to localhost only (Nginx proxies all public API traffic)
|
||||
- "127.0.0.1:${BACKEND_PORT:-8000}:8000"
|
||||
- "${BACKEND_PORT:-8000}:8000"
|
||||
volumes:
|
||||
- ${CONTENT_PATH:-../../acupedia_content/acupedia-content}:/app/content:ro
|
||||
networks:
|
||||
|
|
@ -137,7 +127,6 @@ services:
|
|||
# 6. Storefront Web App (Vite/React on Port 3000)
|
||||
# ============================================================
|
||||
store:
|
||||
image: acupedia-ops-store:latest
|
||||
build:
|
||||
context: ${ACUPEDIA_STORE_PATH:-../../acupedia_store_ui}
|
||||
dockerfile: Dockerfile
|
||||
|
|
@ -148,8 +137,7 @@ services:
|
|||
depends_on:
|
||||
- backend
|
||||
ports:
|
||||
# Bound to localhost only (Nginx handles public traffic via qa.acupedia.in/)
|
||||
- "127.0.0.1:${STORE_PORT:-3000}:80"
|
||||
- "${STORE_PORT:-3000}:80"
|
||||
networks:
|
||||
- acupedia-net
|
||||
|
||||
|
|
@ -157,7 +145,6 @@ services:
|
|||
# 7. Admin Portal Web App (Vite/React on Port 3001)
|
||||
# ============================================================
|
||||
admin:
|
||||
image: acupedia-ops-admin:latest
|
||||
build:
|
||||
context: ${ACUPEDIA_ADMIN_PATH:-../../acupedia_web_ui}
|
||||
dockerfile: Dockerfile
|
||||
|
|
@ -168,31 +155,7 @@ services:
|
|||
depends_on:
|
||||
- backend
|
||||
ports:
|
||||
# Bound to localhost only (Nginx handles public traffic via qa.acupedia.in/admin)
|
||||
- "127.0.0.1:${ADMIN_PORT:-3001}:80"
|
||||
networks:
|
||||
- acupedia-net
|
||||
|
||||
# ============================================================
|
||||
# 8. Central Nginx Reverse Proxy (QA Containerized 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 network/internet
|
||||
- "${HTTP_PORT:-80}:80"
|
||||
- "${HTTPS_PORT:-443}:443"
|
||||
volumes:
|
||||
- ./config/nginx/acupedia.qa.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
- ${CERTS_PATH:-./certs}:/etc/letsencrypt:ro
|
||||
- ./certbot:/var/www/certbot
|
||||
- "${ADMIN_PORT:-3001}:80"
|
||||
networks:
|
||||
- acupedia-net
|
||||
|
||||
|
|
|
|||
|
|
@ -1,35 +1,32 @@
|
|||
version: '3.8'
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
container_name: acupedia-postgres
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_DB: ${POSTGRES_DB:-acupedia_db}
|
||||
POSTGRES_USER: ${POSTGRES_USER:-db_admin}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-C1234spl}
|
||||
ports:
|
||||
- "127.0.0.1:${POSTGRES_PORT:-5432}:5432"
|
||||
- "${POSTGRES_PORT:-5432}:5432"
|
||||
volumes:
|
||||
- acupedia-postgres-data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-db_admin} -d ${POSTGRES_DB:-acupedia_db}"]
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-acupedia} -d ${POSTGRES_DB:-acupedia_db}"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 20
|
||||
networks:
|
||||
- acupedia-net
|
||||
|
||||
redis:
|
||||
image: redis:8.10.1-alpine
|
||||
container_name: acupedia-redis
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "127.0.0.1:${REDIS_PORT:-6379}:6379"
|
||||
- "${REDIS_PORT:-6379}:6379"
|
||||
volumes:
|
||||
- acupedia-redis-data:/data
|
||||
networks:
|
||||
- acupedia-net
|
||||
|
||||
minio:
|
||||
image: minio/minio
|
||||
container_name: acupedia-minio
|
||||
|
|
@ -38,34 +35,28 @@ services:
|
|||
environment:
|
||||
MINIO_ROOT_USER: ${MINIO_ACCESS_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:
|
||||
# Bound strictly to 127.0.0.1 for local development
|
||||
- "127.0.0.1:${MINIO_PORT:-9000}:9000"
|
||||
- "127.0.0.1:${MINIO_CONSOLE_PORT:-9001}:9001"
|
||||
- "${MINIO_PORT:-9000}:9000"
|
||||
- "${MINIO_CONSOLE_PORT:-9001}:9001"
|
||||
volumes:
|
||||
- acupedia-minio-data:/data
|
||||
networks:
|
||||
- acupedia-net
|
||||
|
||||
mailhog:
|
||||
image: mailhog/mailhog:latest
|
||||
container_name: acupedia-mailhog
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "127.0.0.1:1025:1025" # SMTP port
|
||||
- "127.0.0.1:8025:8025" # Web UI port (http://localhost:8025)
|
||||
networks:
|
||||
- acupedia-net
|
||||
|
||||
# mailhog:
|
||||
# image: mailhog/mailhog:latest
|
||||
# container_name: acupedia-mailhog
|
||||
# restart: unless-stopped
|
||||
# ports:
|
||||
# - "1025:1025" # SMTP port
|
||||
# - "8025:8025" # Web UI port
|
||||
# networks:
|
||||
# - acupedia-net
|
||||
redisinsight:
|
||||
image: redis/redisinsight:latest
|
||||
container_name: redis-insight
|
||||
restart: always
|
||||
ports:
|
||||
- "127.0.0.1:5540:5540"
|
||||
- "5540:5540"
|
||||
volumes:
|
||||
- acupedia-redisinsight-data:/data
|
||||
depends_on:
|
||||
|
|
|
|||
|
|
@ -1,204 +1,51 @@
|
|||
version: '3.8'
|
||||
services:
|
||||
# ============================================================
|
||||
# 1. PostgreSQL Database
|
||||
# ============================================================
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
container_name: acupedia-postgres
|
||||
image: ${ACUPEDIA_POSTGRES_IMAGE:?Set ACUPEDIA_POSTGRES_IMAGE}
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_DB: ${POSTGRES_DB}
|
||||
POSTGRES_USER: ${POSTGRES_USER}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
POSTGRES_DB: ${POSTGRES_DB:-acupedia}
|
||||
POSTGRES_USER: ${POSTGRES_USER:-acupedia}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD}
|
||||
ports:
|
||||
# Bound strictly to 127.0.0.1 (Localhost only - safe from public internet)
|
||||
- "127.0.0.1:${POSTGRES_PORT:-5432}:5432"
|
||||
- "${POSTGRES_PORT:-5432}:5432"
|
||||
volumes:
|
||||
- acupedia-postgres-data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-acupedia} -d ${POSTGRES_DB:-acupedia}"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 20
|
||||
networks:
|
||||
- acupedia-net
|
||||
|
||||
# ============================================================
|
||||
# 2. Redis Cache (Secured & Internal)
|
||||
# ============================================================
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: acupedia-redis
|
||||
image: ${ACUPEDIA_REDIS_IMAGE:?Set ACUPEDIA_REDIS_IMAGE}
|
||||
restart: unless-stopped
|
||||
command: redis-server --requirepass "${REDIS_PASSWORD}"
|
||||
ports:
|
||||
- "127.0.0.1:${REDIS_PORT:-6379}:6379"
|
||||
- "${REDIS_PORT:-6379}:6379"
|
||||
volumes:
|
||||
- acupedia-redis-data:/data
|
||||
networks:
|
||||
- acupedia-net
|
||||
|
||||
# ============================================================
|
||||
# 3. MinIO Object Storage
|
||||
# ============================================================
|
||||
minio:
|
||||
image: minio/minio
|
||||
container_name: acupedia-minio
|
||||
image: ${ACUPEDIA_MINIO_IMAGE:?Set ACUPEDIA_MINIO_IMAGE}
|
||||
restart: unless-stopped
|
||||
command: server /data --console-address ":9001"
|
||||
environment:
|
||||
MINIO_ROOT_USER: ${MINIO_ACCESS_KEY}
|
||||
MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY}
|
||||
MINIO_ROOT_USER: ${MINIO_ACCESS_KEY:?Set MINIO_ACCESS_KEY}
|
||||
MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY:?Set MINIO_SECRET_KEY}
|
||||
ports:
|
||||
# Bound strictly to 127.0.0.1 - Nginx proxies public /acupedia-media/ requests
|
||||
- "127.0.0.1:${MINIO_PORT:-9000}:9000"
|
||||
- "127.0.0.1:${MINIO_CONSOLE_PORT:-9001}:9001"
|
||||
- "${MINIO_PORT:-9000}:9000"
|
||||
- "${MINIO_CONSOLE_PORT:-9001}:9001"
|
||||
volumes:
|
||||
- acupedia-minio-data:/data
|
||||
networks:
|
||||
- acupedia-net
|
||||
|
||||
# ============================================================
|
||||
# 4. MailHog SMTP Server (Optional / Dev fallback)
|
||||
# ============================================================
|
||||
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"
|
||||
acupedia-content:
|
||||
image: gcr.io/google-containers/pause:3.9
|
||||
container_name: acupedia-content
|
||||
volumes:
|
||||
- ${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
|
||||
- acupedia-content-data:/app/data
|
||||
|
||||
volumes:
|
||||
acupedia-postgres-data:
|
||||
driver: local
|
||||
acupedia-minio-data:
|
||||
driver: local
|
||||
acupedia-redis-data:
|
||||
driver: local
|
||||
|
||||
networks:
|
||||
acupedia-net:
|
||||
driver: bridge
|
||||
acupedia-minio-data:
|
||||
acupedia-content-data:
|
||||
|
|
|
|||
|
|
@ -1,282 +0,0 @@
|
|||
# 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!
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# Local development
|
||||
|
||||
`acupedia-ops local ...` coordinates the local AcuPedia workspace. It does not
|
||||
`acupedia-ops local ...` coordinates the local AccuPedia workspace. It does not
|
||||
replace the native development tools used by each repository.
|
||||
|
||||
## Workspace model
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
# 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.
|
||||
|
|
@ -5,14 +5,13 @@ build-backend = "setuptools.build_meta"
|
|||
[project]
|
||||
name = "acupedia-ops"
|
||||
version = "0.2.0"
|
||||
description = "Operational data-processing and deployment tooling for AcuPedia"
|
||||
description = "Operational data-processing and deployment tooling for AccuPedia"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.11"
|
||||
dependencies = [
|
||||
"numpy>=2.0,<3.0",
|
||||
"opencv-python-headless>=4.10,<5.0",
|
||||
"PyYAML>=6.0,<7.0",
|
||||
"ansible-runner>=2.4,<3.0",
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
#!/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"
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
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
|
||||
|
|
@ -5,8 +5,8 @@ from acupedia_ops.common.config import load_config
|
|||
|
||||
def test_load_config(tmp_path: Path) -> None:
|
||||
(tmp_path / "dev.yaml").write_text(
|
||||
"backend:\n application_name: acupedia-api\n",
|
||||
"backend:\n application_name: accupedia-api\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
config = load_config("dev", config_root=tmp_path)
|
||||
assert config.values["backend"]["application_name"] == "acupedia-api"
|
||||
assert config.values["backend"]["application_name"] == "accupedia-api"
|
||||
|
|
|
|||
2
uv.lock
2
uv.lock
|
|
@ -11,7 +11,6 @@ name = "acupedia-ops"
|
|||
version = "0.2.0"
|
||||
source = { editable = "." }
|
||||
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.5.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
|
||||
{ name = "opencv-python-headless" },
|
||||
|
|
@ -28,7 +27,6 @@ dev = [
|
|||
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "ansible-runner", specifier = ">=2.4,<3.0" },
|
||||
{ name = "ansible-runner", marker = "extra == 'deployment'", specifier = ">=2.4,<3.0" },
|
||||
{ name = "numpy", specifier = ">=2.0,<3.0" },
|
||||
{ name = "opencv-python-headless", specifier = ">=4.10,<5.0" },
|
||||
|
|
|
|||
Loading…
Reference in New Issue