Compare commits
3 Commits
404b228cbf
...
824536ddbe
Author | SHA1 | Date | |
---|---|---|---|
824536ddbe
|
|||
7fbdd0606c
|
|||
581f6b7b8f
|
@@ -1,7 +1,12 @@
|
||||
docker
|
||||
.dir-locals.el
|
||||
.dockerignore
|
||||
.gitignore
|
||||
**/.mypy_cache
|
||||
**/.ruff_cache
|
||||
.venv
|
||||
**/__pycache__
|
||||
poetry.lock
|
||||
Dockerfile
|
||||
docker-compose.yml
|
||||
config
|
||||
.venv
|
||||
docker
|
||||
poetry.lock
|
||||
tests
|
||||
Dockerfile
|
||||
|
@@ -1,9 +1,13 @@
|
||||
FROM python:3.11-slim as builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
|
||||
RUN apt update && apt install -y proj-bin
|
||||
COPY ./pyproject.toml /app
|
||||
|
||||
RUN apt update && \
|
||||
apt install -y --no-install-recommends proj-bin && \
|
||||
apt clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN pip install --upgrade poetry && \
|
||||
poetry config virtualenvs.create false && \
|
||||
@@ -15,7 +19,11 @@ FROM python:3.11-slim as runtime
|
||||
COPY . /app
|
||||
COPY --from=builder /app/requirements.txt /app
|
||||
|
||||
RUN apt update && apt install -y postgresql libpq5
|
||||
RUN apt update && \
|
||||
apt install -y --no-install-recommends postgresql libpq5 && \
|
||||
apt clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN pip install --no-cache-dir -r /app/requirements.txt
|
||||
|
||||
WORKDIR /app
|
||||
|
@@ -50,7 +50,7 @@ class TracingSettings(BaseModel):
|
||||
class Settings(BaseSettings):
|
||||
app_name: str
|
||||
|
||||
idfm_api_key: SecretStr = Field(..., env="API_KEY")
|
||||
idfm_api_key: SecretStr = Field(..., env="IDFM_API_KEY")
|
||||
clear_static_data: bool = Field(False, env="CLEAR_STATIC_DATA")
|
||||
|
||||
http: HttpSettings = HttpSettings()
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
import uvicorn
|
||||
from contextlib import asynccontextmanager
|
||||
from fastapi import FastAPI
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi_cache import FastAPICache
|
||||
@@ -43,6 +43,24 @@ app.add_middleware(
|
||||
|
||||
app.mount("/widget", StaticFiles(directory="../frontend/", html=True), name="widget")
|
||||
|
||||
# The cache-control header entry is not managed properly by fastapi-cache:
|
||||
# For now, a request with a cache-control set to no-cache
|
||||
# is interpreted as disabling the use of the server cache.
|
||||
# Cf. Improve Cache-Control header parsing and handling
|
||||
# https://github.com/long2ice/fastapi-cache/issues/144 workaround
|
||||
@app.middleware("http")
|
||||
async def fastapi_cache_issue_144_workaround(request: Request, call_next):
|
||||
entries = request.headers.__dict__["_list"]
|
||||
new_entries = [
|
||||
entry for entry in entries if entry[0].decode().lower() != "cache-control"
|
||||
]
|
||||
|
||||
request.headers.__dict__["_list"] = new_entries
|
||||
|
||||
return await call_next(request)
|
||||
|
||||
|
||||
|
||||
app.include_router(line.router)
|
||||
app.include_router(stop.router)
|
||||
|
||||
|
@@ -4,7 +4,6 @@ version = "0.1.0"
|
||||
description = ""
|
||||
authors = ["Adrien SUEUR <me@adrien.run>"]
|
||||
readme = "README.md"
|
||||
packages = [{include = "backend"}]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.11"
|
||||
|
@@ -77,6 +77,9 @@ services:
|
||||
|
||||
carrramba-encore-rate-api:
|
||||
build: ./backend/
|
||||
environment:
|
||||
- CONFIG_PATH=./config.local.yaml
|
||||
- IDFM_API_KEY=set_your_idfm_key_here
|
||||
ports:
|
||||
- "127.0.0.1:8080:8080"
|
||||
|
||||
|
Reference in New Issue
Block a user