From 1fea51ff2bb3c1ac3d3e2fc3a380ba0c393cf270 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 12 Mar 2025 19:41:36 -0400 Subject: [PATCH] Fix potential Docker container issues - add proper icon, install curl, fix permissions --- docker-compose.yml | 20 +++++++++----- docker/midtownplaydio/Dockerfile | 8 +++++- docker/midtownplaydio/Dockerfile.production | 29 +-------------------- docker/midtownplaydio/src/app.py | 10 ++++--- 4 files changed, 28 insertions(+), 39 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index fe2ad6c..4e95320 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,14 +1,20 @@ +version: '3.8' + services: - fancy-qr: + midtownplaydio: build: - context: ./docker/fancy-qr + context: ./docker/midtownplaydio dockerfile: Dockerfile ports: - "3000:3000" volumes: - - ./docker/fancy-qr/src:/app/web - - ./uploads:/app/web/uploads - - ./output:/app/web/outputs + - ./docker/midtownplaydio/src:/app environment: - - NODE_ENV=development - restart: unless-stopped \ No newline at end of file + - DEBUG=1 + restart: unless-stopped + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:3000/health"] + interval: 30s + timeout: 5s + retries: 3 + start_period: 5s \ No newline at end of file diff --git a/docker/midtownplaydio/Dockerfile b/docker/midtownplaydio/Dockerfile index f156119..60b07f3 100644 --- a/docker/midtownplaydio/Dockerfile +++ b/docker/midtownplaydio/Dockerfile @@ -2,6 +2,12 @@ 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 @@ -13,7 +19,7 @@ RUN pip install --no-cache-dir pytest pytest-cov black isort COPY src/ . # Create directory for static files -RUN mkdir -p /app/static +RUN mkdir -p /app/static && chmod 777 /app/static # Create non-root user for security RUN adduser --disabled-password --gecos '' appuser diff --git a/docker/midtownplaydio/Dockerfile.production b/docker/midtownplaydio/Dockerfile.production index f482914..e905f09 100644 --- a/docker/midtownplaydio/Dockerfile.production +++ b/docker/midtownplaydio/Dockerfile.production @@ -1,28 +1 @@ -FROM python:3.11-slim - -WORKDIR /app - -# 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 - -# 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 +FROM git.nixc.us/colin/midtownplaydio:staging \ No newline at end of file diff --git a/docker/midtownplaydio/src/app.py b/docker/midtownplaydio/src/app.py index 5630064..c2075d3 100644 --- a/docker/midtownplaydio/src/app.py +++ b/docker/midtownplaydio/src/app.py @@ -3,6 +3,7 @@ from fastapi.responses import HTMLResponse, JSONResponse, FileResponse from fastapi.staticfiles import StaticFiles import os import json +import base64 app = FastAPI(title="MidTownPlaydio") @@ -135,9 +136,12 @@ def generate_service_worker(): # Create a simple placeholder icon def create_placeholder_icon(): - # This is just a placeholder - in a real app, you would use a proper icon file - with open(os.path.join(STATIC_DIR, 'icon.png'), 'w') as f: - f.write("Placeholder for icon") + # A minimal 1x1 transparent PNG + minimal_png_base64 = "iVBORw0KGgoAAAANSUhEUgAAAMAAAADAAQMAAABoEv5EAAAABlBMVEUAAAD///+l2Z/dAAAANklEQVRIx+3IMQEAAAgDoPnX3hiu20CDBnbmFVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFReQMHaigbWzGsIQAAAABJRU5ErkJggg==" + png_data = base64.b64decode(minimal_png_base64) + + with open(os.path.join(STATIC_DIR, 'icon.png'), 'wb') as f: + f.write(png_data) # Generate all static files on startup @app.on_event("startup")