From 89e5c1ac7edef9d2d0552bb66706f79cf519a38e Mon Sep 17 00:00:00 2001 From: Ettore <=> Date: Wed, 6 May 2026 11:23:10 +0200 Subject: [PATCH] Add Dockerfile and docker-compose.yml for deployment --- .dockerignore | 31 +++++++++++++++++++++++++++++++ .env.example | 3 +++ Dockerfile | 27 +++++++++++++++++++++++++++ docker-compose.yml | 16 ++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..50e807d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,31 @@ +__pycache__ +*.pyc +*.pyo +*.pyd +.Python +env +venv +.venv +pip-log.txt +pip-delete-this-directory.txt +.tox +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.log +.git +.mypy_cache +.pytest_cache +.hypothesis +.DS_Store +.vscode +.idea +*.swp +*.swo +*~ +data/*.db +data/*.db-* +data/*.db-journal \ No newline at end of file diff --git a/.env.example b/.env.example index c3e1ce5..a0f1fb5 100644 --- a/.env.example +++ b/.env.example @@ -8,5 +8,8 @@ SECRET_KEY=replace-with-a-random-64-char-hex-string # Set to true to skip real AVConnect calls (for testing) # MOCK_AVCONNECT=true +# Port configuration +APP_PORT=8000 + # Database path (default: ./data/gates.db relative to project root) # DATABASE_URL=sqlite:///./data/gates.db diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2473897 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# Use Python 3.11 slim image +FROM python:3.11-slim + +# Set working directory +WORKDIR /app + +# Install system dependencies if needed +RUN apt-get update && apt-get install -y \ + gcc \ + && rm -rf /var/lib/apt/lists/* + +# Copy requirements and install Python dependencies +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the source code +COPY src/ ./src/ +COPY data/ ./data/ + +# Create data directory if it doesn't exist +RUN mkdir -p data + +# Expose port +EXPOSE $APP_PORT + +# Run the application +CMD ["python", "-m", "uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "$APP_PORT"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..fd0052e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +version: '3.8' + +services: + app: + build: . + ports: + - "8000:8000" + volumes: + - ./data:/app/data + environment: + - ADMIN_USERNAME=admin + - ADMIN_PASSWORD=changeme + - SECRET_KEY=supersecretkey + - MOCK_AVCONNECT=false + - APP_PORT=8000 + restart: unless-stopped \ No newline at end of file