-
Notifications
You must be signed in to change notification settings - Fork 988
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 1 commit
7b5f351
f4b706b
f73bb08
ba950e7
5f0a148
08e5e0e
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 | ||
|
||
# Cài 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 | ||
|
||
# Health-check endpoint nên implement ở FastAPI | ||
EXPOSE 8001 | ||
CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8001"] | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,34 @@ | ||
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
9
to
10
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 | ||
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.
There are a few improvements that can be made to this Dockerfile:
CMD
instruction seems to reference the wrong application object.api/main.py
importsapp
fromapi.api
, so the command should likely beuvicorn api.api:app ...
.CMD
. It's better to use thePORT
environment variable defined on line 14 for flexibility.Here's a suggested update that addresses these points: