Skip to content

Bump requests from 2.23.0 to 2.32.2 in /old/race-number-photo-finder #4

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

Open
wants to merge 2 commits into
base: main
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
2 changes: 2 additions & 0 deletions fastapi-docker-cloudrun/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.venv
__pycache__
34 changes: 34 additions & 0 deletions fastapi-docker-cloudrun/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# this function is from https://github.com/direnv/direnv/issues/1338
# maybe one day there will be a more official version

layout_uv() {
if [[ -d "$UV_PROJECT_ENVIRONMENT" ]]; then
log_status "Existing project virtual environment \'$UV_PROJECT_ENVIRONMENT\'"
else
log_status "No project virtual environment exists."

if [[ ! -f "pyproject.toml" ]]; then # No project in-place
log_status "Initializing a new Python project via \`uv init\`."
uv init --no-readme
else
log_status "Python project already initialized. Skipping \`uv init\`."
fi
[[ -f "hello.py" ]] && rm hello.py # a file created by `uv init`

if [[ ! -z "$UV_PROJECT_ENVIRONMENT" ]]; then
log_status "Project virtual environment path set to : $UV_PROJECT_ENVIRONMENT"
uv venv "$UV_PROJECT_ENVIRONMENT"
else
uv venv
UV_PROJECT_ENVIRONMENT="$(pwd)/.venv"
fi
fi

PATH_add "$UV_PROJECT_ENVIRONMENT/bin"
export UV_ACTIVE=1 # or VENV_ACTIVE=1
export UV_PROJECT_ENVIRONMENT
}

export UV_PROJECT_ENVIRONMENT=.venv
dotenv
layout uv
3 changes: 3 additions & 0 deletions fastapi-docker-cloudrun/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.venv
__pycache__
.env
1 change: 1 addition & 0 deletions fastapi-docker-cloudrun/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
13 changes: 13 additions & 0 deletions fastapi-docker-cloudrun/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.13.2-slim-bookworm
COPY --from=ghcr.io/astral-sh/uv:0.6.8 /uv /uvx /bin/

# StreamHandler in CPython already flushes after each emit/line, not entirely sure if this is really necessary
ENV PYTHONUNBUFFERED=1
ENV PORT=1234

WORKDIR /app
ADD . /app
RUN uv sync --frozen

# As an example here we're running the web service with one worker on uvicorn.
CMD ["uv", "run", "uvicorn", "server:app", "--host", "0.0.0.0", "--port", "${PORT}", "--workers", "1", "--app-dir", "src"]
54 changes: 54 additions & 0 deletions fastapi-docker-cloudrun/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
FastAPI + Docker + uv + direnv + Cloud Run
==========================================

Local without docker:
=====================

install uv

install direnv:

https://github.com/direnv/direnv/blob/master/docs/installation.md

add direnv hook:

https://github.com/direnv/direnv/blob/master/docs/hook.md

uvicorn server:app --host 0.0.0.0 --port 1234 --workers 1 --app-dir src

Local with docker
===================

Create .env, and add:

PROJECT_ID=<YOUR_UNIQUE_LOWER_CASE_PROJECT_ID>
APP=<app name>
PORT=1234
TAG="gcr.io/$PROJECT_ID/$APP"
REGION="europe-west1"

Then:

```
export TAG="gcr.io/$PROJECT_ID/$APP"
```

docker build -t $TAG .
docker run --rm -dp $PORT:$PORT -e PORT=$PORT $TAG

Cloud run:
==========

Set up project, billing project etc (some hints at https://github.com/sekR4/FastAPI-on-Google-Cloud-Run)

To build

```
gcloud builds submit --tag $TAG
```

To deploy:

``
gcloud run deploy $APP --image $TAG --platform managed --region $REGION
```
10 changes: 10 additions & 0 deletions fastapi-docker-cloudrun/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[project]
name = "fastapi-docker-cloudrun"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
"fastapi>=0.115.11",
"uvicorn>=0.34.0",
]
8 changes: 8 additions & 0 deletions fastapi-docker-cloudrun/src/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from fastapi import FastAPI

app = FastAPI()


@app.get("/")
async def root():
return {"message": "Hello World"}
203 changes: 203 additions & 0 deletions fastapi-docker-cloudrun/uv.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion old/race-number-photo-finder/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
keras-ocr==0.6.3
requests==2.23.0
requests==2.32.2
beautifulsoup4==4.8.2