diff --git a/.gitignore b/.gitignore index 0dc8222..51c14c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ Vocard.rar .env *.pyc -logs -settings.json \ No newline at end of file +settings.json +logs \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 37223ce..d500667 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ # Use an official Python runtime as a base image FROM python:3.12-slim -# Install build dependencies -RUN apt-get update -y && apt-get install -y gcc python3-dev +# Install build dependencies and supervisor +RUN apt-get update -y && apt-get install -y gcc python3-dev supervisor # Set the working directory to /app WORKDIR /app @@ -13,5 +13,8 @@ COPY . /app # Install any needed packages specified in requirements.txt RUN pip install --no-cache-dir -r requirements.txt -# Run main.py when the container launches -CMD ["python", "-u", "main.py"] +# Copy the supervisor configuration file +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +# Run supervisor to manage both processes main.py and webapp.py +CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] \ No newline at end of file diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 0000000..3a75ad4 --- /dev/null +++ b/supervisord.conf @@ -0,0 +1,17 @@ +[supervisord] +nodaemon=true +user=root + +[program:main] +command=python -u /app/main.py +autostart=true +autorestart=true +stderr_logfile=/var/log/main.err.log +stdout_logfile=/var/log/main.out.log + +[program:webapp] +command=python -u /app/web/webapp.py +autostart=true +autorestart=true +stderr_logfile=/var/log/webapp.err.log +stdout_logfile=/var/log/webapp.out.log \ No newline at end of file