Fix potential Docker container issues - add proper icon, install curl, fix permissions
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Your Name 2025-03-12 19:41:36 -04:00
parent 4a0797fcff
commit 1fea51ff2b
4 changed files with 28 additions and 39 deletions

View File

@ -1,14 +1,20 @@
version: '3.8'
services: services:
fancy-qr: midtownplaydio:
build: build:
context: ./docker/fancy-qr context: ./docker/midtownplaydio
dockerfile: Dockerfile dockerfile: Dockerfile
ports: ports:
- "3000:3000" - "3000:3000"
volumes: volumes:
- ./docker/fancy-qr/src:/app/web - ./docker/midtownplaydio/src:/app
- ./uploads:/app/web/uploads
- ./output:/app/web/outputs
environment: environment:
- NODE_ENV=development - DEBUG=1
restart: unless-stopped restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 30s
timeout: 5s
retries: 3
start_period: 5s

View File

@ -2,6 +2,12 @@ FROM python:3.11-slim
WORKDIR /app 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 requirements first for better caching
COPY src/requirements.txt . COPY src/requirements.txt .
RUN pip install --no-cache-dir -r 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/ . COPY src/ .
# Create directory for static files # 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 # Create non-root user for security
RUN adduser --disabled-password --gecos '' appuser RUN adduser --disabled-password --gecos '' appuser

View File

@ -1,28 +1 @@
FROM python:3.11-slim FROM git.nixc.us/colin/midtownplaydio:staging
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

View File

@ -3,6 +3,7 @@ from fastapi.responses import HTMLResponse, JSONResponse, FileResponse
from fastapi.staticfiles import StaticFiles from fastapi.staticfiles import StaticFiles
import os import os
import json import json
import base64
app = FastAPI(title="MidTownPlaydio") app = FastAPI(title="MidTownPlaydio")
@ -135,9 +136,12 @@ def generate_service_worker():
# Create a simple placeholder icon # Create a simple placeholder icon
def create_placeholder_icon(): def create_placeholder_icon():
# This is just a placeholder - in a real app, you would use a proper icon file # A minimal 1x1 transparent PNG
with open(os.path.join(STATIC_DIR, 'icon.png'), 'w') as f: minimal_png_base64 = "iVBORw0KGgoAAAANSUhEUgAAAMAAAADAAQMAAABoEv5EAAAABlBMVEUAAAD///+l2Z/dAAAANklEQVRIx+3IMQEAAAgDoPnX3hiu20CDBnbmFVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFReQMHaigbWzGsIQAAAABJRU5ErkJggg=="
f.write("Placeholder for icon") 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 # Generate all static files on startup
@app.on_event("startup") @app.on_event("startup")