Added docker and improved everything.

This commit is contained in:
2025-06-09 15:29:58 +02:00
parent 47d4ed1cc0
commit 82bb0340c4
9 changed files with 316 additions and 56 deletions

19
devbox-back/Dockerfile Normal file
View File

@@ -0,0 +1,19 @@
FROM python:3.13.4-alpine
RUN apk update \
&& apk upgrade \
&& mkdir -p /usr/src/app
EXPOSE 8000
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
COPY app/* .
CMD [ "gunicorn", "--config", "gunicorn-cfg.py", "main:app" ]

View File

@@ -0,0 +1,10 @@
# -*- encoding: utf-8 -*-
bind = '0.0.0.0:8080'
workers = 2
worker_class = 'uvicorn.workers.UvicornWorker'
accesslog = '-'
loglevel = 'debug'
capture_output = True
enable_stdio_inheritance = True

View File

@@ -14,7 +14,7 @@ logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Database configuration
DATABASE_FILE = "devbox_emails.db"
DATABASE_FILE = "db/devbox.sqlite3"
def get_db_connection():
"""Create and return a database connection"""

View File

@@ -38,7 +38,7 @@ class DevBoxEmailManager:
Database manager for DevBox email subscriptions
"""
def __init__(self, db_file: str = "devbox_emails.db"):
def __init__(self, db_file: str = "db/devbox.sqlite3"):
self.db_file = db_file
self.ensure_database_exists()

View File

@@ -1,46 +0,0 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "devbox-email-api"
version = "1.0.0"
description = "Email collection API for DevBox landing page"
readme = "README.md"
license = {text = "MIT"}
authors = [
{name = "DevBox Team"},
]
requires-python = ">=3.8"
dependencies = [
"fastapi>=0.104.0",
"uvicorn[standard]>=0.24.0",
"pydantic[email]>=2.5.0",
"python-multipart>=0.0.6",
]
[project.optional-dependencies]
dev = [
"pytest>=7.0.0",
"black>=23.0.0",
"isort>=5.12.0",
"flake8>=6.0.0",
]
[project.urls]
Homepage = "https://github.com/yourusername/devbox-email-api"
Repository = "https://github.com/yourusername/devbox-email-api"
[tool.hatch.build.targets.wheel]
packages = ["src"]
[tool.black]
line-length = 88
target-version = ['py38']
[tool.isort]
profile = "black"
line_length = 88
[project.scripts]
devbox-api = "main:main"

View File

@@ -0,0 +1,24 @@
annotated-types==0.7.0
anyio==4.9.0
click==8.2.1
dnspython==2.7.0
email_validator==2.2.0
fastapi==0.115.12
gunicorn==23.0.0
h11==0.16.0
httptools==0.6.4
idna==3.10
packaging==25.0
pydantic==2.11.5
pydantic_core==2.33.2
python-dotenv==1.1.0
python-multipart==0.0.20
PyYAML==6.0.2
sniffio==1.3.1
starlette==0.46.2
typing-inspection==0.4.1
typing_extensions==4.14.0
uvicorn==0.34.3
uvloop==0.21.0
watchfiles==1.0.5
websockets==15.0.1

View File

@@ -13,6 +13,13 @@ fi
echo "✅ Found Python: $(python3 --version)"
# Check if we're in the right directory
if [ ! -f "requirements.txt" ]; then
echo "❌ Error: requirements.txt not found!"
echo "Please run this script from the project root directory."
exit 1
fi
# Create virtual environment if it doesn't exist
if [ ! -d "venv" ]; then
echo "📦 Creating virtual environment..."
@@ -23,10 +30,10 @@ fi
echo "🔧 Activating virtual environment..."
source venv/bin/activate
# Install dependencies directly (simpler approach)
echo "📚 Installing dependencies..."
# Install dependencies from requirements.txt
echo "📚 Installing dependencies from requirements.txt..."
pip install --upgrade pip
pip install fastapi uvicorn[standard] pydantic[email] python-multipart
pip install -r requirements.txt
echo ""
echo "🎉 Setup complete!"
@@ -38,4 +45,4 @@ echo "💡 Press Ctrl+C to stop"
echo ""
# Start the application
python main.py --dev
python main.py --dev