Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.git
.github
.env
.ruff_cache
.DS_Store
**/.venv
**/__pycache__
**/node_modules
data_local
data/processed
ml/data
frontend/dist
7 changes: 7 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.venv
__pycache__
**/__pycache__
.env
.ruff_cache
Dockerfile
.dockerignore
15 changes: 15 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.12-slim

ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1

WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

EXPOSE 8000

CMD ["sh", "-c", "alembic upgrade head && uvicorn main:app --host 0.0.0.0 --port 8000"]
68 changes: 68 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
x-app-env: &app-env
env_file: .env
environment:
DATABASE_URL: postgresql+psycopg://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
MODEL_PATH: /models/model.json

services:
db:
image: postgres:16
Expand All @@ -15,5 +21,67 @@ services:
timeout: 3s
retries: 10

backend:
build: ./backend
<<: *app-env
ports:
- "8000:8000"
depends_on:
db:
condition: service_healthy
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/docs')"]
interval: 5s
timeout: 3s
retries: 20
start_period: 10s
restart: unless-stopped

alert_sender:
build: ./backend
<<: *app-env
command: ["python", "-m", "app.workers.alert_sender"]
depends_on:
backend:
condition: service_healthy
restart: unless-stopped

simulator:
build:
context: .
dockerfile: ml/Dockerfile
<<: *app-env
command: ["python", "simulator.py", "/app/data/train_FD001.txt"]
depends_on:
backend:
condition: service_healthy
restart: on-failure

worker:
build:
context: .
dockerfile: ml/Dockerfile
<<: *app-env
command:
- sh
- -c
- "[ -f \"$$MODEL_PATH\" ] || python baseline_model.py /app/data/train_FD001.txt; exec python worker.py"
volumes:
- models:/models
depends_on:
backend:
condition: service_healthy
restart: unless-stopped

frontend:
build: ./frontend
ports:
- "5173:80"
depends_on:
backend:
condition: service_healthy
restart: unless-stopped

volumes:
pgdata:
models:
4 changes: 4 additions & 0 deletions frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
Dockerfile
.dockerignore
16 changes: 16 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:22-alpine AS build

WORKDIR /app

COPY package.json package-lock.json ./
RUN npm ci

COPY . .
RUN npm run build

FROM nginx:1.27-alpine

COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /usr/share/nginx/html

EXPOSE 80
16 changes: 16 additions & 0 deletions frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
server {
listen 80;

root /usr/share/nginx/html;
index index.html;

location /api/ {
proxy_pass http://backend:8000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}

location / {
try_files $uri /index.html;
}
}
16 changes: 16 additions & 0 deletions ml/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.12-slim

ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1

RUN apt-get update \
&& apt-get install -y --no-install-recommends libgomp1 \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app/ml

COPY ml/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY data/train_FD001.txt /app/data/train_FD001.txt
COPY ml/ .
Loading