Skip to content

Commit

Permalink
Caddy local support
Browse files Browse the repository at this point in the history
  • Loading branch information
jb3 committed Aug 18, 2024
1 parent b1da08b commit 47f248c
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 2 deletions.
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
2 changes: 1 addition & 1 deletion thallium-backend/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

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)


Expand Down
2 changes: 1 addition & 1 deletion thallium-backend/src/routes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
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)
7 changes: 7 additions & 0 deletions thallium-backend/src/routes/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ async def get_templates(client: PrintfulClient) -> dict:
return resp.json()


@router.get("/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."""
Expand Down
2 changes: 2 additions & 0 deletions thallium-backend/src/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class _Config(
super_admin_token: pydantic.SecretStr
printful_token: pydantic.SecretStr

app_prefix: str = "/"


CONFIG = _Config()

Expand Down
2 changes: 2 additions & 0 deletions thallium-caddy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data/*
!data/.gitkeep
6 changes: 6 additions & 0 deletions thallium-caddy/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:80 {
handle_path /api/* {
reverse_proxy thallium-backend:8000
}
reverse_proxy /* thallium-frontend:5173
}
Empty file added thallium-caddy/data/.gitkeep
Empty file.

0 comments on commit 47f248c

Please sign in to comment.