shaliz-kong commited on
Commit ·
12d2187
1
Parent(s): 3493c8b
refactored dockerfile
Browse files- Dockerfile +33 -14
Dockerfile
CHANGED
|
@@ -1,24 +1,43 @@
|
|
| 1 |
-
# ---- 1. base image ---------------------------------------------------------
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
RUN apt-get update && apt-get install -y --
|
| 6 |
-
redis-server \
|
| 7 |
-
supervisor \
|
| 8 |
-
unzip \
|
| 9 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
-
#
|
| 12 |
COPY requirements.txt /tmp/
|
| 13 |
RUN pip install --no-cache-dir -r /tmp/requirements.txt
|
| 14 |
|
| 15 |
-
#
|
| 16 |
COPY . /app
|
| 17 |
WORKDIR /app
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
RUN
|
| 21 |
-
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
| 3 |
+
# Install Redis and Supervisor
|
| 4 |
+
RUN apt-get update && apt-get install -y redis-server supervisor && rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
# Install Python dependencies
|
| 7 |
COPY requirements.txt /tmp/
|
| 8 |
RUN pip install --no-cache-dir -r /tmp/requirements.txt
|
| 9 |
|
| 10 |
+
# Copy application
|
| 11 |
COPY . /app
|
| 12 |
WORKDIR /app
|
| 13 |
|
| 14 |
+
# Create supervisord config using heredoc (works on HF builder)
|
| 15 |
+
RUN cat > /etc/supervisord.conf << 'EOF'
|
| 16 |
+
[supervisord]
|
| 17 |
+
nodaemon=true
|
| 18 |
|
| 19 |
+
[program:redis]
|
| 20 |
+
command=redis-server --bind 127.0.0.1 --port 6379 --maxmemory 128mb
|
| 21 |
+
autostart=true
|
| 22 |
+
autorestart=true
|
| 23 |
+
|
| 24 |
+
[program:app]
|
| 25 |
+
command=python -m uvicorn app.main:app --host 0.0.0.0 --port 7860
|
| 26 |
+
directory=/app
|
| 27 |
+
environment=REDIS_URL=redis://localhost:6379
|
| 28 |
+
autostart=true
|
| 29 |
+
autorestart=true
|
| 30 |
+
|
| 31 |
+
[program:scheduler]
|
| 32 |
+
command=python /app/scheduler_loop.py
|
| 33 |
+
directory=/app
|
| 34 |
+
environment=REDIS_URL=redis://localhost:6379
|
| 35 |
+
autostart=true
|
| 36 |
+
autorestart=true
|
| 37 |
+
EOF
|
| 38 |
+
|
| 39 |
+
# Expose port
|
| 40 |
+
EXPOSE 7860
|
| 41 |
+
|
| 42 |
+
# Start supervisord
|
| 43 |
+
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
|