Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump fastapi from 0.109.0 to 0.109.1 #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .env.sample

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var/
*.egg
.venv/
venv/
.env
.envs/

# Python debug
pdb/
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Edgecutters

Simple FastAPI template with Keycloak integration in mind.

_A work in progress_
2 changes: 1 addition & 1 deletion app/api/endpoints.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fastapi import APIRouter, Depends
from fastapi_keycloak import OIDCUser

from app.keycloak import idp
from app.config.keycloak import idp

router = APIRouter()

Expand Down
4 changes: 2 additions & 2 deletions app/api/routers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from fastapi import APIRouter

from app import api
from app.api.endpoints import router

api_router_v1 = APIRouter()
api_router_v1.include_router(api.router)
api_router_v1.include_router(router)
12 changes: 1 addition & 11 deletions app/config/base.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
from pydantic import BaseModel
from pydantic_settings import BaseSettings, SettingsConfigDict


class KeycloakSettings(BaseModel):
server_url: str
client_id: str
client_secret: str
realm_name: str
admin_client_secret: str
callback_uri: str


class Settings(BaseSettings):
model_config = SettingsConfigDict(env_file=".env", extra='ignore')
model_config = SettingsConfigDict(env_file=".envs/.local", extra="ignore")

keycloak_server_url: str
keycloak_client_id: str
Expand Down
2 changes: 1 addition & 1 deletion app/config/keycloak.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
client_secret=settings.keycloak_client_secret,
admin_client_secret=settings.keycloak_admin_client_secret,
realm=settings.keycloak_realm_name,
callback_uri=settings.keycloak_callback_uri
callback_uri=settings.keycloak_callback_uri,
)
32 changes: 32 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM python:3.12-slim

ENV PYTHONDONTWRITEBYTECODE 1
ENV DOCKER_BUILDKIT 1
ENV PYTHONUNBUFFERED 1

RUN addgroup --system app && adduser --system --group app

WORKDIR /app

RUN rm -rf /var/lib/apt/lists/* && \
apt-get purge --auto-remove && \
apt-get clean

COPY ./requirements.txt /requirements.txt

RUN --mount=type=cache,target=/root/.cache \
pip install -r /requirements.txt --no-cache-dir

COPY ./docker/run.sh /run.sh
RUN chmod +x /run.sh

COPY ./docker/prestart.sh /prestart.sh
RUN chmod +x /prestart.sh

COPY --chown=app . /app

ENV PYTHONPATH=/app

USER app

ENTRYPOINT ["/prestart.sh"]
10 changes: 10 additions & 0 deletions docker/prestart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -o errexit
set -o pipefail
set -o nounset

# Run migrations
#alembic upgrade head

exec "$@"
11 changes: 11 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -o errexit
set -o pipefail
set -o nounset

export APP_MODULE=${APP_MODULE-app.main:app}
export HOST=${HOST:-0.0.0.0}
export PORT=${PORT:-8000}

uvicorn --host $HOST --port $PORT "$APP_MODULE"
33 changes: 33 additions & 0 deletions keycloak.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
volumes:
postgres_data: {}

name: local-keycloak

services:
postgres:
image: postgres:12-bullseye
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: keycloak
POSTGRES_USER: keycloak
POSTGRES_PASSWORD: password

keycloak:
image: quay.io/keycloak/keycloak:latest
ports:
- "8080:8080"
environment:
DB_VENDOR: POSTGRES
DB_ADDR: postgres
DB_DATABASE: keycloak
DB_USER: keycloak
DB_SCHEMA: public
DB_PASSWORD: password
KEYCLOAK_ADMIN: admin
KEYCLOAK_ADMIN_PASSWORD: admin
# Uncomment the line below if you want to specify JDBC parameters. The parameter below is just an example, and it shouldn't be used in production without knowledge. It is highly recommended that you read the PostgreSQL JDBC driver documentation in order to use it.
#JDBC_PARAMS: "ssl=true"
depends_on:
- postgres
command: start-dev
28 changes: 28 additions & 0 deletions local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
volumes:
local_postgres_data: {}
local_redis_data: {}

services:
backend:
image: backend_api
build:
context: .
dockerfile: docker/Dockerfile
command: /run.sh
depends_on:
- postgres
ports:
- "8000:8000"
env_file:
- .envs/.local
extra_hosts:
- "host.docker.internal:host-gateway"

postgres:
image: postgres:14
volumes:
- local_postgres_data:/var/lib/postgresql/data
env_file:
- .envs/.local.postgres
ports:
- "5434:5432"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ click==8.1.7
deprecation==2.1.0
distlib==0.3.8
ecdsa==0.18.0
fastapi==0.109.0
fastapi==0.109.1
fastapi_keycloak==1.0.10
filelock==3.13.1
h11==0.14.0
Expand Down