Added docker support
This commit is contained in:
parent
d1d436b020
commit
40b74704e7
3 changed files with 67 additions and 1 deletions
|
|
@ -1,10 +1,21 @@
|
|||
# backend/Dockerfile
|
||||
FROM python:3.11-slim
|
||||
|
||||
# 1️⃣ Set a deterministic working directory
|
||||
WORKDIR /app
|
||||
|
||||
# 2️⃣ Copy only the dependency list first – this lets Docker cache the layer
|
||||
COPY requirements.txt .
|
||||
|
||||
# 3️⃣ Install Python deps (no cache to keep the image small)
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# 4️⃣ Now copy the actual source code
|
||||
COPY ./app ./app
|
||||
|
||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
# 5️⃣ Expose the port FastAPI will listen on (optional but nice for docs)
|
||||
EXPOSE 8000
|
||||
|
||||
# 6️⃣ Run uvicorn with hot‑reload for local development.
|
||||
# In production you’d drop the `--reload` flag.
|
||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
|
||||
|
|
|
|||
40
compose.yaml
Normal file
40
compose.yaml
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
version: "3.9"
|
||||
|
||||
services:
|
||||
api:
|
||||
build:
|
||||
context: ./backend
|
||||
ports:
|
||||
- "8000:8000"
|
||||
volumes:
|
||||
- ./backend:/app # live‑code sync for reload
|
||||
# env_file: .env # optional, keep secrets out of repo
|
||||
# depends_on:
|
||||
# - db # if you have a DB service
|
||||
|
||||
ui:
|
||||
build:
|
||||
context: ./frontend
|
||||
target: builder # use the builder stage for dev
|
||||
command: npm run dev -- --host 0.0.0.0 --port 5173
|
||||
ports:
|
||||
- "5173:5173"
|
||||
volumes:
|
||||
- ./frontend:/app
|
||||
environment:
|
||||
- VITE_API_URL=http://localhost:8000
|
||||
depends_on:
|
||||
- api
|
||||
|
||||
# Example DB (Postgres) – optional
|
||||
# db:
|
||||
# image: postgres:16-alpine
|
||||
# environment:
|
||||
# POSTGRES_USER: demo
|
||||
# POSTGRES_PASSWORD: demo
|
||||
# POSTGRES_DB: demo
|
||||
# volumes:
|
||||
# - pgdata:/var/lib/postgresql/data
|
||||
|
||||
# volumes:
|
||||
# pgdata:
|
||||
15
frontend/Dockerfile
Normal file
15
frontend/Dockerfile
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# frontend/Dockerfile
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci # clean install, respects lockfile
|
||||
|
||||
COPY . .
|
||||
RUN npm run build # produces ./dist
|
||||
|
||||
# ---- Runtime image (optional) ----
|
||||
FROM nginx:stable-alpine
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
Loading…
Reference in a new issue