feat: add docker files

This commit is contained in:
Miki
2025-01-31 18:02:56 +01:00
parent 035bd0f084
commit d7ec2883ee
5 changed files with 53 additions and 3 deletions

21
docker-compose.yml Normal file
View File

@@ -0,0 +1,21 @@
version: '3.8'
services:
api:
build: ./src/ign-api
container_name: api
environment:
- REDISTOGO_URL=redis://redis:6379/0
ports:
- "8000:8000"
depends_on:
- redis
redis:
image: redis:latest
container_name: redis
ports:
- "6379:6379"
networks:
default:
driver: bridge

22
src/ign-api/Dockerfile Normal file
View File

@@ -0,0 +1,22 @@
FROM python:3.9-slim
RUN apt-get update && apt-get install -y cron
WORKDIR /app
COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install gunicorn
COPY . .
RUN chmod +x /app/run-worker.sh
COPY crontab /etc/cron.d/my-cron-job
RUN chmod 0644 /etc/cron.d/my-cron-job
RUN crontab /etc/cron.d/my-cron-job
RUN touch /var/log/cron.log
EXPOSE 8000
CMD cron && /app/run-worker.sh && tail -f /var/log/cron.log & /usr/local/bin/gunicorn --env REDISTOGO_URL=redis://redis:6379/ --workers 3 -m 007 -b 0.0.0.0:8000 wsgi:app

1
src/ign-api/crontab Normal file
View File

@@ -0,0 +1 @@
5 */6 * * * ubuntu . /usr/bin/bash /app/run-worker.sh

View File

@@ -1,15 +1,16 @@
Pillow==10.3.0
flask==1.1.2
Flask==3.1.0
flask_cors==3.0.8
image-go-nord==1.2.0
gunicorn==20.0.4
rq==1.8.0
pytest==6.0.2
itsdangerous==2.0.1
Werkzeug==2.0.3
itsdangerous==2.2.0
Werkzeug==3.1.3
ffmpeg-python==0.2.0
numpy==1.24.4
torch==2.2.2
torch-vision==0.1.6.dev0
torchvision==0.17.2
scikit-image==0.19.2
Jinja2==3.1.2

5
src/ign-api/run-worker.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
for i in {1..3}
do
python ./worker.py 2>&1 &
done