diff --git a/docker/midtownplaydio/Dockerfile.production b/docker/midtownplaydio/Dockerfile.production index e905f09..fef10c3 100644 --- a/docker/midtownplaydio/Dockerfile.production +++ b/docker/midtownplaydio/Dockerfile.production @@ -1 +1,34 @@ -FROM git.nixc.us/colin/midtownplaydio:staging \ No newline at end of file +FROM python:3.11-slim + +WORKDIR /app + +# Install curl for healthcheck and other dependencies +RUN apt-get update && \ + apt-get install -y --no-install-recommends curl && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Copy requirements first for better caching +COPY src/requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the application +COPY src/ . + +# Create directory for static files +RUN mkdir -p /app/static && chmod 777 /app/static + +# Create non-root user for security +RUN adduser --disabled-password --gecos '' appuser +RUN chown -R appuser:appuser /app +USER appuser + +# Expose the port the app runs on +EXPOSE 3000 + +# Health check +HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \ + CMD curl -f http://localhost:3000/health || exit 1 + +# Run the application with Gunicorn +CMD gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:3000 app:app \ No newline at end of file diff --git a/docker/midtownplaydio/src/requirements.txt b/docker/midtownplaydio/src/requirements.txt index 989fb05..668df7f 100644 --- a/docker/midtownplaydio/src/requirements.txt +++ b/docker/midtownplaydio/src/requirements.txt @@ -1,5 +1,6 @@ fastapi==0.104.0 uvicorn==0.23.2 gunicorn==21.2.0 -uvloop==0.18.0 -httptools==0.6.0 \ No newline at end of file +# Optional packages that might not compile on all systems +# uvloop==0.18.0 +# httptools==0.6.0 \ No newline at end of file diff --git a/docker/midtownplaydio/src/run_local.py b/docker/midtownplaydio/src/run_local.py new file mode 100644 index 0000000..3e70755 --- /dev/null +++ b/docker/midtownplaydio/src/run_local.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +""" +Simple script to run the application locally with uvicorn, +without needing Docker. +""" +import subprocess +import sys +import os + +def main(): + # Install dependencies if needed + try: + import fastapi + import uvicorn + except ImportError: + print("Installing required dependencies...") + subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"]) + + # Run the application + print("Starting MidTownPlaydio...") + import uvicorn + uvicorn.run("app:app", host="0.0.0.0", port=3000, reload=True) + +if __name__ == "__main__": + main() \ No newline at end of file