From 4dd12c519edf5e1d5846ec22ffa283208bdcfaa7 Mon Sep 17 00:00:00 2001 From: edschuy95 Date: Sun, 13 Jul 2025 23:50:32 -0400 Subject: [PATCH] Updated stuff --- Dockerfile | 27 +++++++++++++++++++++++++++ app.py | 13 ------------- docker-compose.yml | 7 +++++++ webhook-proxy.pyproj | 2 ++ 4 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..200369f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# Use a slim Python image +FROM python:3.11-slim + +# Environment: no .pyc files, real-time logs +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 + +# Create working directory +WORKDIR /app + +# Install system dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + && rm -rf /var/lib/apt/lists/* + +# Install Python dependencies +COPY requirements.txt . +RUN pip install --upgrade pip && pip install -r requirements.txt + +# Copy app code +COPY . . + +# Expose Flask port +EXPOSE 5000 + +# Launch Gunicorn with 4 workers (adjust for your CPU cores) +CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app", "--workers", "4"] \ No newline at end of file diff --git a/app.py b/app.py index ce7da38..374d551 100644 --- a/app.py +++ b/app.py @@ -1,21 +1,8 @@ from flask import Flask from routes import yeastar, voipms import logging -import os -import shutil import sys -# Check for config.py at runtime -if not os.path.exists("config.py"): - print("config.py not found — creating from config.template.py") - try: - shutil.copyfile("config.template.py", "config.py") - print("Created config.py — please edit it with your real secrets.") - sys.exit(1) # Exit so user must edit it manually - except Exception as e: - print(f"Failed to create config.py: {e}") - sys.exit(1) - # Disable Flask/Werkzeug noisy request log log = logging.getLogger('werkzeug') log.setLevel(logging.ERROR) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..728d461 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +services: + webhook-proxy: + build: . + container_name: webhook-proxy + restart: unless-stopped + ports: + - "5000:5000" \ No newline at end of file diff --git a/webhook-proxy.pyproj b/webhook-proxy.pyproj index 4f18272..01a5bd5 100644 --- a/webhook-proxy.pyproj +++ b/webhook-proxy.pyproj @@ -19,6 +19,8 @@ 10.0 + +