Skip to content

Commit

Permalink
Docker Optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnGrubba committed Jul 2, 2024
1 parent 104a5da commit 80f5916
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@
- ⚠️ Make sure to always have a backup of your user data.

> [!NOTE]
> You can find the Documentation <a href="https://johngrubba.github.io/ezauth/" target="_blank">here</a>
> You can find the Documentation <a href="https://johngrubba.github.io/ezauth/" target="_blank">here</a>
## Developement

To enable a efficient development process, you can start the Service with hot reloading enabled. This will automatically restart the service when a file is changed.

```sh
docker compose -f .\docker-compose.dev.yml up -d --build
```
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ services:
- ./config:/src/app/config
db:
image: mongo
ports:
- '27017:27017'
expose:
- 27017
restart: always
environment:
- MONGO_INITDB_ROOT_USERNAME=admin
Expand Down
8 changes: 4 additions & 4 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
FROM python:3.12
FROM python:3.12-slim

WORKDIR /src/app

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

WORKDIR /src/app

COPY ./requirements.txt /src/app/requirements.txt

RUN pip install --no-cache-dir --upgrade -r /src/app/requirements.txt

COPY . /src/app

CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "80", "--log-level", "info"]
CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "80", "--log-level", "critical"]
4 changes: 1 addition & 3 deletions src/api/internal.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from fastapi import APIRouter, Header, HTTPException, Depends, BackgroundTasks
from typing import Annotated
from tools import broadcast_emails, InternalConfig
from api.model import BroadCastEmailRequest
from threading import Lock

email_task_running = Lock()


async def check_internal_key(internal_api_key: Annotated[str, Header()]):
async def check_internal_key(internal_api_key: str = Header(default=None)):
if not internal_api_key:
raise HTTPException(status_code=401)
if internal_api_key != InternalConfig.internal_api_key:
Expand All @@ -18,7 +17,6 @@ async def check_internal_key(internal_api_key: Annotated[str, Header()]):
prefix="/internal",
tags=["Internal API"],
dependencies=[Depends(check_internal_key)],
responses={401: {"description": "Unauthorized"}},
)


Expand Down

0 comments on commit 80f5916

Please sign in to comment.