feat: add Docker support and update Python version to 3.11

This commit is contained in:
2025-09-02 03:37:48 +03:00
parent 43932a93e0
commit 03dd3f9db4
11 changed files with 2405 additions and 54 deletions

1
.dockerignore Normal file
View File

@@ -0,0 +1 @@
.venv

1
.python-version Normal file
View File

@@ -0,0 +1 @@
3.11

30
Dockerfile Normal file
View File

@@ -0,0 +1,30 @@
FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim AS builder
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
# Disable Python downloads, because we want to use the system interpreter
# across both images. If using a managed Python version, it needs to be
# copied from the build image into the final image; see `standalone.Dockerfile`
# for an example.
ENV UV_PYTHON_DOWNLOADS=0
# Install git
WORKDIR /app
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --locked --no-install-project --no-dev
COPY . /app
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --no-dev
# Then, use a final image without uv
FROM python:3.11-slim-bookworm
# It is important to use the image that matches the builder, as the path to the
# Python executable must be the same, e.g., using `python:3.11-slim-bookworm`
# will fail.
# Copy the application from the builder
COPY --from=builder --chown=app:app /app /app
ENV PATH="/app/.venv/bin:$PATH"
WORKDIR /app

0
README.md Normal file
View File

2
build-docker.sh Executable file
View File

@@ -0,0 +1,2 @@
docker build -t git.denco.store/fakz9/fulfillment-backend:latest .
docker push git.denco.store/fakz9/fulfillment-backend:latest

View File

@@ -2,7 +2,6 @@ import time
from enum import StrEnum
from typing import AsyncIterator
from async_timeout import timeout
from external.marketplace.base.core import BaseMarketplaceApi
from models import Marketplace

View File

@@ -1,10 +1,10 @@
import time
from collections import defaultdict
from io import BytesIO
from pathlib import Path
import openpyxl
import openpyxl.styles
from six import BytesIO
from sqlalchemy import select
from sqlalchemy.orm import joinedload

11
main.py
View File

@@ -36,16 +36,7 @@ async def lifespan(app: FastAPI):
consumer_task.cancel()
app = FastAPI(lifespan=lifespan, separate_input_output_schemas=False)
if platform.system() == 'Linux':
import uvicorn.workers
class Worker(uvicorn.workers.UvicornWorker):
CONFIG_KWARGS = {
'root_path': API_ROOT
}
app = FastAPI(lifespan=lifespan, separate_input_output_schemas=False, root_path='/api')
app.add_middleware(
CORSMiddleware,

43
pyproject.toml Normal file
View File

@@ -0,0 +1,43 @@
[project]
name = "fulfillment-backend"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
"aiohttp[speedups]>=3.11.16",
"aiokafka>=0.12.0",
"aioshutil>=1.5",
"alembic>=1.16.5",
"asyncpg>=0.30.0",
"celery[redis]>=5.5.3",
"fastapi>=0.116.1",
"fpdf>=1.7.2",
"gunicorn>=23.0.0",
"jinja2>=3.1.6",
"lexorank-py>=0.1.1",
"number-to-string>=1.0.3",
"openpyxl==3.0.10",
"pdfrw>=0.4",
"pydantic>=2.11.7",
"pyjwt>=2.10.1",
"pymupdf>=1.26.4",
"python-dotenv>=1.1.1",
"python-jose[cryptography]>=3.5.0",
"python-multipart>=0.0.20",
"reportlab>=4.4.3",
"reportlab-qrcode>=0.1.6",
"requests>=2.32.5",
"sqlalchemy[asyncio]>=2.0.43",
"svglib>=1.5.1",
"uvicorn[standard]>=0.35.0",
"weasyprint>=66.0",
"starlette>=0.47.3",
"redis[hiredis]>=5.2.1",
"typing-extensions>=4.15.0",
]
[dependency-groups]
dev = [
"deptry>=0.23.1",
]

View File

@@ -1,42 +0,0 @@
# FastApi
fastapi
pydantic
uvicorn
uvicorn[standard]
gunicorn
python-multipart
jinja2
# Security
python-jose[cryptography]
passlib[bcrypt]
pyjwt
# Database
sqlalchemy
sqlalchemy[asyncio]
asyncpg
alembic
# Kafka
aiokafka
# Other
python-dotenv
aiohttp>=3.11.16
aiohttp[speedups]
requests
openpyxl==3.0.10
lexorank-py
celery[redis]
celery
aioshutil
reportlab-qrcode
# PDF
reportlab
weasyprint
number_to_string
pdfrw
fpdf
PyMuPDF
svglib

2326
uv.lock generated Normal file

File diff suppressed because it is too large Load Diff