Fix compatibility issues and improve deployment scripts
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
This commit is contained in:
parent
1fea51ff2b
commit
1f583ba7c5
|
@ -1 +1,34 @@
|
|||
FROM git.nixc.us/colin/midtownplaydio:staging
|
||||
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
|
|
@ -1,5 +1,6 @@
|
|||
fastapi==0.104.0
|
||||
uvicorn==0.23.2
|
||||
gunicorn==21.2.0
|
||||
uvloop==0.18.0
|
||||
httptools==0.6.0
|
||||
# Optional packages that might not compile on all systems
|
||||
# uvloop==0.18.0
|
||||
# httptools==0.6.0
|
|
@ -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()
|
Loading…
Reference in New Issue