Skip to content

Commit 8abeeb7

Browse files
Merge pull request #10 from DEFRA/fix-entrypoint
Add Application Entrypoint
2 parents dcceb7e + 1977d90 commit 8abeeb7

4 files changed

Lines changed: 19 additions & 0 deletions

File tree

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ENV LOG_CONFIG="logging-dev.json"
1010

1111
USER root
1212

13+
# curl is required for CDP health checks
1314
# Install curl via Debian 13 (trixie) backport to patch CVE-2025-0725
1415
RUN echo "deb https://deb.debian.org/debian bookworm-backports main" > /etc/apt/sources.list.d/bookworm-backports.list \
1516
&& apt update \

app/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
class AppConfig(BaseSettings):
66
model_config = SettingsConfigDict()
7+
python_env: str | None = None
78
host: str | None = None
89
port: int | None = None
910
log_config: str | None = None

app/main.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
from contextlib import asynccontextmanager
22
from logging import getLogger
33

4+
import uvicorn
45
from fastapi import FastAPI
56

67
from app.common.mongo import get_mongo_client
78
from app.common.tracing import TraceIdMiddleware
9+
from app.config import config
810
from app.example.router import router as example_router
911
from app.health.router import router as health_router
1012

@@ -31,3 +33,17 @@ async def lifespan(_: FastAPI):
3133
# Setup Routes
3234
app.include_router(health_router)
3335
app.include_router(example_router)
36+
37+
38+
def main() -> None:
39+
uvicorn.run(
40+
"app.main:app",
41+
host=config.host,
42+
port=config.port,
43+
log_config=config.log_config,
44+
reload=config.python_env == "development"
45+
)
46+
47+
48+
if __name__ == "__main__":
49+
main()

compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ services:
5555
PORT: ${PORT:-8085}
5656
AWS_ENDPOINT_URL: ${AWS_ENDPOINT_URL:-http://localstack:4566}
5757
MONGO_URI: ${MONGO_URI:-mongodb://mongodb:27017/}
58+
HOST: ${HOST:-0.0.0.0}
5859
develop:
5960
watch:
6061
- action: sync

0 commit comments

Comments
 (0)