Daniel McKnight NeonClary commited on
Commit
b4ae83b
·
unverified ·
1 Parent(s): 9e6d175

Docker optimization by Cursor (#2)

Browse files

* fix: correct docker-compose.yml quoting and localhost typo

Remove unnecessary inner quotes from YAML env var defaults. Fix localhohst typo in REACT_APP_API_URL.

Made-with: Cursor

* chore: add .dockerignore, .gitignore updates, and optimize Dockerfile

Add .dockerignore to exclude dev/build artifacts from Docker context. Exclude venv from git. Optimize Dockerfile with separate dependency and source layers for faster rebuilds.

Made-with: Cursor

---------

Co-authored-by: NeonClary <askclary@gmail.com>

Files changed (4) hide show
  1. .dockerignore +20 -0
  2. .gitignore +3 -0
  3. Dockerfile +17 -6
  4. docker-compose.yml +3 -3
.dockerignore ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ **/node_modules
2
+ **/venv
3
+ **/.venv
4
+ **/__pycache__
5
+ **/chromadb_storage
6
+ **/chroma_data
7
+ **/chroma_db
8
+ .git
9
+ .gitignore
10
+ .env
11
+ **/.env
12
+ .vscode
13
+ .cursor
14
+ **/.idea
15
+ **/.DS_Store
16
+ **/Thumbs.db
17
+ docker-compose.yml
18
+ Dockerfile
19
+ .dockerignore
20
+ *.md
.gitignore CHANGED
@@ -21,3 +21,6 @@ phd-advisor-frontend/firebase.json
21
  # Ignore all __pycache__ folders
22
  **/__pycache__/
23
 
 
 
 
 
21
  # Ignore all __pycache__ folders
22
  **/__pycache__/
23
 
24
+
25
+ # Python virtual environments
26
+ **/venv/
Dockerfile CHANGED
@@ -1,3 +1,4 @@
 
1
  FROM node:24-bookworm AS base
2
 
3
  LABEL vendor=neon.ai \
@@ -12,18 +13,28 @@ RUN apt-get update && \
12
  python3 \
13
  python3-pip
14
 
15
- COPY . /ccai
16
  WORKDIR /ccai/multi_llm_chatbot_backend
 
 
 
17
 
18
- RUN pip install --no-cache-dir --break-system-packages -r requirements.txt
 
 
 
 
19
 
20
- FROM base AS backend
 
 
21
 
 
 
 
22
  CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
23
 
 
24
  FROM base AS frontend
25
  WORKDIR /ccai/phd-advisor-frontend
26
-
27
- RUN npm install
28
-
29
  CMD [ "npm", "start" ]
 
1
+ # syntax=docker/dockerfile:1
2
  FROM node:24-bookworm AS base
3
 
4
  LABEL vendor=neon.ai \
 
13
  python3 \
14
  python3-pip
15
 
16
+ # ---- Python dependencies (cached unless requirements.txt changes) ----------
17
  WORKDIR /ccai/multi_llm_chatbot_backend
18
+ COPY multi_llm_chatbot_backend/requirements.txt ./
19
+ RUN --mount=type=cache,target=/root/.cache/pip \
20
+ pip install --break-system-packages -r requirements.txt
21
 
22
+ # ---- Node dependencies (cached unless package.json changes) ----------------
23
+ WORKDIR /ccai/phd-advisor-frontend
24
+ COPY phd-advisor-frontend/package.json phd-advisor-frontend/package-lock.json* ./
25
+ RUN --mount=type=cache,target=/root/.npm \
26
+ npm install
27
 
28
+ # ---- Copy the rest of the source code (this layer changes often) -----------
29
+ WORKDIR /ccai
30
+ COPY . .
31
 
32
+ # ---- Backend target --------------------------------------------------------
33
+ FROM base AS backend
34
+ WORKDIR /ccai/multi_llm_chatbot_backend
35
  CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
36
 
37
+ # ---- Frontend target -------------------------------------------------------
38
  FROM base AS frontend
39
  WORKDIR /ccai/phd-advisor-frontend
 
 
 
40
  CMD [ "npm", "start" ]
docker-compose.yml CHANGED
@@ -13,9 +13,9 @@ services:
13
  environment:
14
  MONGODB_CONNECTION_STRING: "mongodb://database:27017"
15
  MONGODB_DATABASE: phd_advisor
16
- JWT_SECRET_KEY: ${JWT_SECRET_KEY:-"CHANGEME-by-overriding-in-dot-env-file"}
17
  GEMINI_API_KEY: ${GEMINI_API_KEY:-?}
18
- CORS_ORIGINS: ${CORS_ORIGINS:-"http://localhost:3000"}
19
  GEMINI_MODEL: gemini-2.5-flash
20
  frontend:
21
  build:
@@ -29,7 +29,7 @@ services:
29
  depends_on:
30
  - backend
31
  environment:
32
- REACT_APP_API_URL: ${REACT_APP_API_URL:-"http://localhohst:8000"}
33
  database:
34
  image: mongo:8.0
35
  volumes:
 
13
  environment:
14
  MONGODB_CONNECTION_STRING: "mongodb://database:27017"
15
  MONGODB_DATABASE: phd_advisor
16
+ JWT_SECRET_KEY: ${JWT_SECRET_KEY:-CHANGEME-by-overriding-in-dot-env-file}
17
  GEMINI_API_KEY: ${GEMINI_API_KEY:-?}
18
+ CORS_ORIGINS: ${CORS_ORIGINS:-http://localhost:3000}
19
  GEMINI_MODEL: gemini-2.5-flash
20
  frontend:
21
  build:
 
29
  depends_on:
30
  - backend
31
  environment:
32
+ REACT_APP_API_URL: ${REACT_APP_API_URL:-http://localhost:8000}
33
  database:
34
  image: mongo:8.0
35
  volumes: