Commit 5c935bed authored by Kantz's avatar Kantz
Browse files

docker test

parent 7fdbce6a
......@@ -77,6 +77,31 @@ VITE_BACKEND_URL=""
`VITE_BACKEND_URL=""` keeps requests relative so they use the proxy. If you set `VITE_BACKEND_URL` to a full URL, requests bypass the proxy and CORS must be configured accordingly.
## Docker Compose (Production-style)
Template files:
- `math-tutor/docker/docker-compose.yml`
- `math-tutor/docker/nginx.conf`
- `math-tutor/backend/Dockerfile`
- `math-tutor/frontend/Dockerfile`
Run:
```powershell
cd math-tutor/docker
docker compose up --build -d
```
Open in browser:
- `http://<HOST>:80`
Notes:
- Nginx serves the built frontend and proxies `/api` to backend (`http://backend:8000`).
- Keep frontend API calls relative (`/api/...`) for this setup.
## Database (pgvector) setup
Ensure `POSTGRES_URL` and embedding env vars are in `backend/.env`:
......
.venv
__pycache__
*.pyc
logs
test
FROM python:3.12-slim
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY app ./app
COPY scripts ./scripts
COPY sources ./sources
EXPOSE 8000
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
services:
backend:
build:
context: ../backend
dockerfile: Dockerfile
env_file:
- ../backend/.env
expose:
- "8000"
restart: unless-stopped
frontend:
build:
context: ../frontend
dockerfile: Dockerfile
depends_on:
- backend
ports:
- "80:80"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
restart: unless-stopped
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri /index.html;
}
location /api/ {
proxy_pass http://backend:8000/api/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
FROM node:22-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM nginx:1.27-alpine
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
......@@ -4,6 +4,12 @@ import react from '@vitejs/plugin-react'
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
build: {
outDir: "dist",
emptyOutDir: true,
sourcemap: false,
target: "es2020",
},
server: {
host: "0.0.0.0",
port: 5173,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment