sample Docker/-compose file
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
__pycache__
|
__pycache__
|
||||||
.venv
|
.venv
|
||||||
.vscode
|
.vscode
|
||||||
|
.env
|
||||||
9
Dockerfile
Normal file
9
Dockerfile
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
FROM python:3.11
|
||||||
|
|
||||||
|
WORKDIR /code
|
||||||
|
|
||||||
|
COPY ./requirements.txt /tmp/requirements.txt
|
||||||
|
|
||||||
|
RUN pip install --no-cache-dir --upgrade -r /tmp/requirements.txt
|
||||||
|
|
||||||
|
CMD ["fastapi", "run", "app/main.py", "--proxy-headers", "--port", "80", "--reload"]
|
||||||
@@ -19,7 +19,7 @@ from starlette.middleware import Middleware
|
|||||||
from starlette_context import context, plugins
|
from starlette_context import context, plugins
|
||||||
from starlette_context.middleware import RawContextMiddleware
|
from starlette_context.middleware import RawContextMiddleware
|
||||||
|
|
||||||
if os.path.isfile("first_run") and (os.environ.get("RELOAD_ON_FIRST_RUN").lower() == "true"):
|
if os.path.isfile("first_run") and (os.environ.get("RELOAD_ON_FIRST_RUN", "").lower() == "true"):
|
||||||
print("First run ... load data")
|
print("First run ... load data")
|
||||||
with SessionLocal() as db:
|
with SessionLocal() as db:
|
||||||
asyncio.run(admin.create_upload_file(include_non_singable=True, db=db))
|
asyncio.run(admin.create_upload_file(include_non_singable=True, db=db))
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import os
|
|||||||
# openssl rand -hex 32
|
# openssl rand -hex 32
|
||||||
|
|
||||||
scopes_db = {
|
scopes_db = {
|
||||||
os.environ['ADMIN_EMAIL'] : ["admin"]
|
os.environ.get('ADMIN_EMAIL', "") : ["admin"]
|
||||||
}
|
}
|
||||||
|
|
||||||
credentials_exception = HTTPException(
|
credentials_exception = HTTPException(
|
||||||
@@ -22,6 +22,10 @@ credentials_exception = HTTPException(
|
|||||||
async def get_current_user(
|
async def get_current_user(
|
||||||
security_scopes: SecurityScopes, request: Request
|
security_scopes: SecurityScopes, request: Request
|
||||||
):
|
):
|
||||||
|
|
||||||
|
if os.environ.get("NO_LOGIN", "").lower() == "true":
|
||||||
|
return {"sub": "test"}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
username: str = request.headers.get("x-auth-request-user") # type: ignore
|
username: str = request.headers.get("x-auth-request-user") # type: ignore
|
||||||
if username is None:
|
if username is None:
|
||||||
|
|||||||
19
docker-compose.yml
Normal file
19
docker-compose.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
version: "3.7"
|
||||||
|
|
||||||
|
services:
|
||||||
|
liederwahl-dev:
|
||||||
|
build: .
|
||||||
|
container_name: liederwahl-dev
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- .:/code
|
||||||
|
- liederwahl-dev:/data
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
environment:
|
||||||
|
- LIST_URL=${LIST_URL}
|
||||||
|
- NO_LOGIN=true
|
||||||
|
- RELOAD_ON_FIRST_RUN=false
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
liederwahl-dev:
|
||||||
Reference in New Issue
Block a user