shaliz-kong commited on
Commit ·
3493c8b
1
Parent(s): 5bf514b
refactored dockerfile to self host redis
Browse files- Dockerfile +11 -33
Dockerfile
CHANGED
|
@@ -1,46 +1,24 @@
|
|
| 1 |
# ---- 1. base image ---------------------------------------------------------
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
-
# ---- 2. system dependencies
|
| 5 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
g++ \
|
| 9 |
-
cmake \
|
| 10 |
-
libgomp1 \
|
| 11 |
-
libstdc++6 \
|
| 12 |
-
ca-certificates \
|
| 13 |
-
wget \
|
| 14 |
unzip \
|
| 15 |
-
redis-server \ # ✅ ADD THIS
|
| 16 |
-
supervisor \ # ✅ ADD THIS
|
| 17 |
&& rm -rf /var/lib/apt/lists/*
|
| 18 |
|
| 19 |
-
# ---- 3.
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
-
# ---- 4.
|
| 23 |
-
COPY requirements.txt /tmp/requirements.txt
|
| 24 |
-
RUN pip install --no-cache-dir --prefer-binary -r /tmp/requirements.txt && \
|
| 25 |
-
pip install --no-cache-dir "duckdb>=1.0.0"
|
| 26 |
-
|
| 27 |
-
# ---- 5. Pre-download VSS extension (matches DuckDB v1.1.3) ---------------
|
| 28 |
-
# ✅ CHANGED: v1.1.3 instead of v1.0.0
|
| 29 |
-
RUN mkdir -p /root/.duckdb/extensions/v1.1.3/linux_amd64 && \
|
| 30 |
-
wget -q https://extensions.duckdb.org/v1.1.3/linux_amd64/vss.duckdb_extension.gz \
|
| 31 |
-
-O /root/.duckdb/extensions/v1.1.3/linux_amd64/vss.duckdb_extension.gz && \
|
| 32 |
-
gunzip /root/.duckdb/extensions/v1.1.3/linux_amd64/vss.duckdb_extension.gz
|
| 33 |
-
# ---- 6. copy source --------------------------------------------------------
|
| 34 |
COPY . /app
|
| 35 |
WORKDIR /app
|
| 36 |
|
| 37 |
-
# ----
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
# ---- 8. copy supervisord config -------------------------------------------
|
| 41 |
-
# Create supervisord config inside Docker build
|
| 42 |
-
RUN mkdir -p /etc/supervisor/conf.d && \
|
| 43 |
-
echo '[supervisord]\nnodaemon=true\n\n[program:redis]\ncommand=redis-server --bind 127.0.0.1 --port 6379 --maxmemory 128mb\nautostart=true\nautorestart=true\n\n[program:app]\ncommand=python -m uvicorn app.main:app --host 0.0.0.0 --port 7860\ndirectory=/app\nenvironment=REDIS_URL=redis://localhost:6379\nautostart=true\nautorestart=true\n\n[program:scheduler]\ncommand=python /app/scheduler_loop.py\ndirectory=/app\nenvironment=REDIS_URL=redis://localhost:6379\nautostart=true\nautorestart=true' > /etc/supervisor/conf.d/supervisord.conf
|
| 44 |
|
| 45 |
-
# ----
|
| 46 |
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|
|
|
|
| 1 |
# ---- 1. base image ---------------------------------------------------------
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
+
# ---- 2. system dependencies -----------------------------------------------
|
| 5 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 6 |
+
redis-server \
|
| 7 |
+
supervisor \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
unzip \
|
|
|
|
|
|
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
+
# ---- 3. Python deps -------------------------------------------------------
|
| 12 |
+
COPY requirements.txt /tmp/
|
| 13 |
+
RUN pip install --no-cache-dir -r /tmp/requirements.txt
|
| 14 |
|
| 15 |
+
# ---- 4. Copy app -----------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
COPY . /app
|
| 17 |
WORKDIR /app
|
| 18 |
|
| 19 |
+
# ---- 5. Create supervisord config with proper newlines --------------------
|
| 20 |
+
RUN mkdir -p /etc/supervisor/conf.d /var/log/supervisor && \
|
| 21 |
+
printf '[supervisord]\nnodaemon=true\n\n[program:redis]\ncommand=redis-server --bind 127.0.0.1 --port 6379 --maxmemory 128mb\nautostart=true\nautorestart=true\n\n[program:app]\ncommand=python -m uvicorn app.main:app --host 0.0.0.0 --port 7860\ndirectory=/app\nenvironment=REDIS_URL=redis://localhost:6379\nautostart=true\nautorestart=true\n\n[program:scheduler]\ncommand=python /app/scheduler_loop.py\ndirectory=/app\nenvironment=REDIS_URL=redis://localhost:6379\nautostart=true\nautorestart=true\n' > /etc/supervisor/conf.d/supervisord.conf
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
# ---- 6. Start ----------------------------------------------------------------
|
| 24 |
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|