Skip to content

Commit

Permalink
Support 2 processes running in docker
Browse files Browse the repository at this point in the history
Support 2 processes running in docker
  • Loading branch information
xingfanxia committed Apr 8, 2023
1 parent d989ef4 commit 0c991fa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
FROM python:3.9
RUN apt-get update && apt-get install -y build-essential ffmpeg
RUN apt-get update && apt-get install -y build-essential supervisor ffmpeg
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# RUN chmod +x *.sh
COPY requirements.txt .
RUN pip install --user -r requirements.txt

ENV PATH=/root/.local/bin:$PATH
ENV OPENAI_API_KEY your_api_key
ENV TELEGRAM_BOT_TOKEN your_bot_token
ENV FLASK_APP=main.py
COPY . /app
WORKDIR /app
CMD ["flask", "run", "--host=0.0.0.0", "--port=5000"]

# CMD ["flask", "run", "--host=0.0.0.0", "--port=5000"]
# CMD ["python3", "telegram_bot.py"]

CMD ["/usr/bin/supervisord"] # ideally to use multiple containers for multiple python processes, but Railway does not support so with docker-compose
18 changes: 18 additions & 0 deletions supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[supervisord]
nodaemon=true

[program:app]
directory=/app/
command=flask run --host=0.0.0.0 --port=5000
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stdout
stderr_logfile_maxbytes=0

[program:worker]
directory=/app/
command=python3 telegram_bot.py
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stdout
stderr_logfile_maxbytes=0

0 comments on commit 0c991fa

Please sign in to comment.