Added docker support

This commit is contained in:
Jamitz 2026-01-06 12:51:40 +00:00
parent d1d436b020
commit 40b74704e7
3 changed files with 67 additions and 1 deletions

View file

@ -1,10 +1,21 @@
# backend/Dockerfile
FROM python:3.11-slim FROM python:3.11-slim
# 1⃣ Set a deterministic working directory
WORKDIR /app WORKDIR /app
# 2⃣ Copy only the dependency list first this lets Docker cache the layer
COPY requirements.txt . COPY requirements.txt .
# 3⃣ Install Python deps (no cache to keep the image small)
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements.txt
# 4⃣ Now copy the actual source code
COPY ./app ./app 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 hotreload for local development.
# In production youd drop the `--reload` flag.
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]

40
compose.yaml Normal file
View file

@ -0,0 +1,40 @@
version: "3.9"
services:
api:
build:
context: ./backend
ports:
- "8000:8000"
volumes:
- ./backend:/app # livecode 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
View 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;"]