muhammadghiffari commited on
Commit
703e27a
·
1 Parent(s): 55ce956

fix(deploy): run redis and celery in docker container

Browse files
Files changed (2) hide show
  1. Dockerfile +5 -3
  2. start.sh +12 -0
Dockerfile CHANGED
@@ -11,14 +11,16 @@ RUN pip install uv && \
11
  libglib2.0-0 \
12
  libmagic1 \
13
  curl \
 
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
  # Install dependencies using uv (lockfile ensures deterministic resolution)
17
  COPY pyproject.toml uv.lock ./
18
  RUN uv pip install --system -r pyproject.toml
19
 
20
- # Copy source code
21
  COPY . .
 
22
 
23
- # Run FastAPI via Uvicorn
24
- CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "7860", "--proxy-headers", "--forwarded-allow-ips", "*"]
 
11
  libglib2.0-0 \
12
  libmagic1 \
13
  curl \
14
+ redis-server \
15
  && rm -rf /var/lib/apt/lists/*
16
 
17
  # Install dependencies using uv (lockfile ensures deterministic resolution)
18
  COPY pyproject.toml uv.lock ./
19
  RUN uv pip install --system -r pyproject.toml
20
 
21
+ # Copy source code and start script
22
  COPY . .
23
+ RUN chmod +x start.sh
24
 
25
+ # Run via start.sh (starts Redis, Celery, and Uvicorn)
26
+ CMD ["./start.sh"]
start.sh ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Start Redis in the background
3
+ redis-server --daemonize yes
4
+
5
+ # Wait for Redis to start
6
+ sleep 2
7
+
8
+ # Start Celery worker in the background
9
+ celery -A src.tasks.ocr_tasks worker --loglevel=info &
10
+
11
+ # Start FastAPI
12
+ exec uvicorn src.main:app --host 0.0.0.0 --port 7860 --proxy-headers --forwarded-allow-ips "*"