aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2024-08-19 00:27:43 +0100
committerGravatar Joe Banks <[email protected]>2024-08-19 00:28:03 +0100
commit47f248cfd7754aebc82dbbff9efe3fe84edb90b1 (patch)
treeacfc9bc75d24b063232db33076c8fbc296c8cce2
parentOnly deploy backend in CI (diff)
Caddy local support
-rw-r--r--docker-compose.yml13
-rw-r--r--thallium-backend/src/app.py2
-rw-r--r--thallium-backend/src/routes/__init__.py2
-rw-r--r--thallium-backend/src/routes/debug.py7
-rw-r--r--thallium-backend/src/settings.py2
-rw-r--r--thallium-caddy/.gitignore2
-rw-r--r--thallium-caddy/Caddyfile6
-rw-r--r--thallium-caddy/data/.gitkeep0
8 files changed, 32 insertions, 2 deletions
diff --git a/docker-compose.yml b/docker-compose.yml
index 48bc52e..5719724 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -28,6 +28,7 @@ services:
environment:
BACKEND_DATABASE_URL: postgresql+psycopg_async://thallium:thallium@postgres:5432/thallium
BACKEND_TOKEN: suitable-for-development-only
+ BACKEND_APP_PREFIX: /api
ports:
- "8000:8000"
depends_on:
@@ -47,3 +48,15 @@ services:
- /app/node_modules
ports:
- "5173:5173"
+
+ thallium-caddy:
+ image: caddy:2-alpine
+ restart: unless-stopped
+ volumes:
+ - ./thallium-caddy/Caddyfile:/etc/caddy/Caddyfile:ro
+ - ./thallium-caddy/data:/data
+ ports:
+ - "80:80"
+ depends_on:
+ - thallium-backend
+ - thallium-frontend
diff --git a/thallium-backend/src/app.py b/thallium-backend/src/app.py
index 5907348..6060ec3 100644
--- a/thallium-backend/src/app.py
+++ b/thallium-backend/src/app.py
@@ -9,7 +9,7 @@ from src.settings import CONFIG
log = logging.getLogger(__name__)
-fastapi_app = FastAPI(debug=CONFIG.debug)
+fastapi_app = FastAPI(debug=CONFIG.debug, root_path=CONFIG.app_prefix)
fastapi_app.include_router(top_level_router)
diff --git a/thallium-backend/src/routes/__init__.py b/thallium-backend/src/routes/__init__.py
index b321e52..afa02af 100644
--- a/thallium-backend/src/routes/__init__.py
+++ b/thallium-backend/src/routes/__init__.py
@@ -3,6 +3,6 @@ from fastapi import APIRouter
from src.routes.debug import router as debug_router
from src.settings import CONFIG
-top_level_router = APIRouter(prefix="/api")
+top_level_router = APIRouter()
if CONFIG.debug:
top_level_router.include_router(debug_router)
diff --git a/thallium-backend/src/routes/debug.py b/thallium-backend/src/routes/debug.py
index 7fe42da..fac40d7 100644
--- a/thallium-backend/src/routes/debug.py
+++ b/thallium-backend/src/routes/debug.py
@@ -15,6 +15,13 @@ async def get_templates(client: PrintfulClient) -> dict:
return resp.json()
[email protected]("/variants/{variant_id}")
+async def get_variant(client: PrintfulClient, variant_id: int) -> dict:
+ """Return all templates in printful."""
+ resp = await client.get(f"/products/variant/{variant_id}")
+ return resp.json()
+
+
@router.get("/oauth-scopes-v1")
async def get_oauth_scopes(client: PrintfulClient) -> dict:
"""Return all templates in printful."""
diff --git a/thallium-backend/src/settings.py b/thallium-backend/src/settings.py
index db292ba..f6e144c 100644
--- a/thallium-backend/src/settings.py
+++ b/thallium-backend/src/settings.py
@@ -28,6 +28,8 @@ class _Config(
super_admin_token: pydantic.SecretStr
printful_token: pydantic.SecretStr
+ app_prefix: str = "/"
+
CONFIG = _Config()
diff --git a/thallium-caddy/.gitignore b/thallium-caddy/.gitignore
new file mode 100644
index 0000000..06b2ab9
--- /dev/null
+++ b/thallium-caddy/.gitignore
@@ -0,0 +1,2 @@
+data/*
+!data/.gitkeep
diff --git a/thallium-caddy/Caddyfile b/thallium-caddy/Caddyfile
new file mode 100644
index 0000000..a0078fd
--- /dev/null
+++ b/thallium-caddy/Caddyfile
@@ -0,0 +1,6 @@
+:80 {
+ handle_path /api/* {
+ reverse_proxy thallium-backend:8000
+ }
+ reverse_proxy /* thallium-frontend:5173
+}
diff --git a/thallium-caddy/data/.gitkeep b/thallium-caddy/data/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/thallium-caddy/data/.gitkeep