-
Notifications
You must be signed in to change notification settings - Fork 972
refactor: Refactor project structure for maintainability & modularity #309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# backend/Dockerfile | ||
FROM python:3.11-slim | ||
WORKDIR /app | ||
|
||
# Install Python dependencies | ||
COPY backend/api/requirements.txt ./api/ | ||
RUN python -m venv /opt/venv && \ | ||
/opt/venv/bin/pip install --no-cache -r api/requirements.txt | ||
|
||
# Copy source | ||
COPY backend/api/ ./api/ | ||
|
||
ENV PATH="/opt/venv/bin:$PATH" | ||
ENV PORT=8001 | ||
|
||
# A health-check endpoint should be implemented in FastAPI | ||
EXPOSE 8001 | ||
CMD ["sh", "-c", "uvicorn api.api:app --host 0.0.0.0 --port ${PORT}"] | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,37 @@ | ||
version: '3.8' | ||
|
||
services: | ||
deepwiki: | ||
backend: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
dockerfile: backend/Dockerfile | ||
container_name: deepwiki-backend | ||
ports: | ||
- "${PORT:-8001}:${PORT:-8001}" # API port | ||
- "3000:3000" # Next.js port | ||
- "8001:8001" | ||
env_file: | ||
- .env | ||
Comment on lines
11
to
12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new
I recommend re-adding these configurations to the
|
||
environment: | ||
- PORT=${PORT:-8001} | ||
- NODE_ENV=production | ||
- SERVER_BASE_URL=http://localhost:${PORT:-8001} | ||
- LOG_LEVEL=${LOG_LEVEL:-INFO} | ||
- LOG_FILE_PATH=${LOG_FILE_PATH:-api/logs/application.log} | ||
volumes: | ||
- ~/.adalflow:/root/.adalflow # Persist repository and embedding data | ||
- ./api/logs:/app/api/logs # Persist log files across container restarts | ||
# Resource limits for docker-compose up (not Swarm mode) | ||
mem_limit: 6g | ||
mem_reservation: 2g | ||
# Health check configuration | ||
- ./backend/api/logs:/app/api/logs # Persist log files across container restarts | ||
Comment on lines
11
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
|
||
healthcheck: | ||
test: ["CMD", "curl", "-f", "http://localhost:${PORT:-8001}/health"] | ||
interval: 60s | ||
timeout: 10s | ||
test: ["CMD-SHELL", "curl -f http://localhost:8001/health || exit 1"] | ||
interval: 30s | ||
timeout: 5s | ||
retries: 3 | ||
start_period: 30s | ||
|
||
frontend: | ||
build: | ||
context: . | ||
dockerfile: frontend/Dockerfile | ||
container_name: deepwiki-frontend | ||
ports: | ||
- "3000:3000" | ||
environment: | ||
- NODE_ENV=production | ||
Comment on lines
+29
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Without it, the frontend will default to
Comment on lines
+29
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The frontend service needs to communicate with the backend service. The
|
||
depends_on: | ||
backend: | ||
condition: service_healthy | ||
|
||
networks: | ||
default: | ||
driver: bridge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of
sh -c
inCMD
can lead to issues with signal handling, as the shell might not forward signals to theuvicorn
process, preventing a graceful shutdown. To ensure graceful shutdowns, you can useexec
to replace the shell process with theuvicorn
process. Also, the file should end with a newline character for POSIX compatibility.