devike / Dockerfile
mfoud444's picture
Update Dockerfile
1d20354 verified
# Stage 1: Frontend build
FROM node:18 AS frontend-builder
# Clone the repository
WORKDIR /app
RUN git clone https://github.com/stitionai/devika.git .
WORKDIR /app/ui
# Install dependencies and build
RUN npm install
RUN npm run build
# Stage 2: Backend setup
FROM python:3.10-slim AS backend-builder
WORKDIR /app
# Copy from frontend builder
COPY --from=frontend-builder /app /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
gcc \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
RUN pip install uv && \
uv venv && \
. /app/.venv/bin/activate && \
uv pip install -r /app/requirements.txt && \
playwright install --with-deps
# Stage 3: Runtime
FROM python:3.10-slim
WORKDIR /app
# Copy built artifacts
COPY --from=backend-builder /app /app
COPY --from=backend-builder /root/.cache/ms-playwright /root/.cache/ms-playwright
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
bun \
&& rm -rf /var/lib/apt/lists/*
# Install serve for frontend
RUN npm install -g serve
# Expose ports
# Backend default is 1337 (from docker-compose.yaml)
# Frontend will be served on 7860 as requested
EXPOSE 1337 7860
# Create a startup script
RUN echo '#!/bin/bash\n\
# Activate Python virtual environment\n\
. /app/.venv/bin/activate\n\
\n\
# Start backend\n\
python /app/devika.py &\n\
\n\
# Start frontend on port 7860\n\
cd /app/ui && serve -s build -l 7860\n\
\n\
# Keep container running\n\
wait' > /app/start.sh && chmod +x /app/start.sh
# Initialize config if not exists
RUN if [ ! -f /app/config.toml ]; then \
touch /app/config.toml && \
echo "[settings]" >> /app/config.toml && \
echo "SQLITE_DB = \"/app/db/devika.db\"" >> /app/config.toml && \
echo "SCREENSHOTS_DIR = \"/app/screenshots\"" >> /app/config.toml && \
echo "PDFS_DIR = \"/app/pdfs\"" >> /app/config.toml && \
echo "PROJECTS_DIR = \"/app/projects\"" >> /app/config.toml && \
echo "LOGS_DIR = \"/app/logs\"" >> /app/config.toml && \
echo "REPOS_DIR = \"/app/repos\"" >> /app/config.toml; \
fi
# Create necessary directories
RUN mkdir -p /app/db /app/screenshots /app/pdfs /app/projects /app/logs /app/repos
CMD ["/app/start.sh"]