mfoud444 commited on
Commit
1d20354
·
verified ·
1 Parent(s): 48020d0

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +71 -25
Dockerfile CHANGED
@@ -1,40 +1,86 @@
1
- # Base image
2
- FROM python:3.10-slim
3
 
4
- # Set working directory
5
  WORKDIR /app
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  # Install system dependencies
8
  RUN apt-get update && apt-get install -y \
9
- git curl gnupg unzip \
 
 
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
- # Install Node.js 18 and bun
13
- RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
14
- apt-get install -y nodejs && \
15
- npm install -g bun
 
 
 
 
 
16
 
17
- # Install uv (Python package manager)
18
- RUN curl -Ls https://astral.sh/uv/install.sh | bash
19
 
20
- # Clone Devika repo
21
- RUN git clone https://github.com/stitionai/devika.git ./
 
22
 
23
- # Set up virtual environment
24
- RUN uv venv
25
- ENV PATH="/app/.venv/bin:$PATH"
 
26
 
27
- # Install Python dependencies
28
- RUN uv pip install -r requirements.txt
 
 
 
 
 
29
 
30
- # Install Playwright dependencies and browsers
31
- RUN .venv/bin/playwright install --with-deps
 
 
 
 
 
 
 
 
 
 
 
32
 
33
- # Set environment variable for port if needed
34
- ENV PORT=7860
 
 
 
 
 
 
 
 
 
35
 
36
- # Expose backend port (you'll need to modify the code to bind to 7860 if it defaults to something else)
37
- EXPOSE 7860
38
 
39
- # Start backend (adjust path if needed)
40
- CMD ["python", "devika.py"]
 
1
+ # Stage 1: Frontend build
2
+ FROM node:18 AS frontend-builder
3
 
4
+ # Clone the repository
5
  WORKDIR /app
6
+ RUN git clone https://github.com/stitionai/devika.git .
7
+ WORKDIR /app/ui
8
+
9
+ # Install dependencies and build
10
+ RUN npm install
11
+ RUN npm run build
12
+
13
+ # Stage 2: Backend setup
14
+ FROM python:3.10-slim AS backend-builder
15
+
16
+ WORKDIR /app
17
+
18
+ # Copy from frontend builder
19
+ COPY --from=frontend-builder /app /app
20
 
21
  # Install system dependencies
22
  RUN apt-get update && apt-get install -y \
23
+ git \
24
+ gcc \
25
+ g++ \
26
  && rm -rf /var/lib/apt/lists/*
27
 
28
+ # Install Python dependencies
29
+ RUN pip install uv && \
30
+ uv venv && \
31
+ . /app/.venv/bin/activate && \
32
+ uv pip install -r /app/requirements.txt && \
33
+ playwright install --with-deps
34
+
35
+ # Stage 3: Runtime
36
+ FROM python:3.10-slim
37
 
38
+ WORKDIR /app
 
39
 
40
+ # Copy built artifacts
41
+ COPY --from=backend-builder /app /app
42
+ COPY --from=backend-builder /root/.cache/ms-playwright /root/.cache/ms-playwright
43
 
44
+ # Install runtime dependencies
45
+ RUN apt-get update && apt-get install -y \
46
+ bun \
47
+ && rm -rf /var/lib/apt/lists/*
48
 
49
+ # Install serve for frontend
50
+ RUN npm install -g serve
51
+
52
+ # Expose ports
53
+ # Backend default is 1337 (from docker-compose.yaml)
54
+ # Frontend will be served on 7860 as requested
55
+ EXPOSE 1337 7860
56
 
57
+ # Create a startup script
58
+ RUN echo '#!/bin/bash\n\
59
+ # Activate Python virtual environment\n\
60
+ . /app/.venv/bin/activate\n\
61
+ \n\
62
+ # Start backend\n\
63
+ python /app/devika.py &\n\
64
+ \n\
65
+ # Start frontend on port 7860\n\
66
+ cd /app/ui && serve -s build -l 7860\n\
67
+ \n\
68
+ # Keep container running\n\
69
+ wait' > /app/start.sh && chmod +x /app/start.sh
70
 
71
+ # Initialize config if not exists
72
+ RUN if [ ! -f /app/config.toml ]; then \
73
+ touch /app/config.toml && \
74
+ echo "[settings]" >> /app/config.toml && \
75
+ echo "SQLITE_DB = \"/app/db/devika.db\"" >> /app/config.toml && \
76
+ echo "SCREENSHOTS_DIR = \"/app/screenshots\"" >> /app/config.toml && \
77
+ echo "PDFS_DIR = \"/app/pdfs\"" >> /app/config.toml && \
78
+ echo "PROJECTS_DIR = \"/app/projects\"" >> /app/config.toml && \
79
+ echo "LOGS_DIR = \"/app/logs\"" >> /app/config.toml && \
80
+ echo "REPOS_DIR = \"/app/repos\"" >> /app/config.toml; \
81
+ fi
82
 
83
+ # Create necessary directories
84
+ RUN mkdir -p /app/db /app/screenshots /app/pdfs /app/projects /app/logs /app/repos
85
 
86
+ CMD ["/app/start.sh"]