Skip to content

Commit 3772813

Browse files
committed
adicionar configuração docker-compose e deploy na nuvem
arquivos criados: - docker-compose.yml (desenvolvimento local) - Dockerfile (backend com blender + openfoam) - Dockerfile.frontend (frontend react) - env.example (variáveis de ambiente) - docker-setup.bat/sh (scripts de setup) - DOCKER_COMPOSE_GUIA.md (guia completo) - DEPLOY_NUVEM_GUIA.md (deploy na nuvem) funcionalidades: - containers para postgres, redis, minio - backend fastapi com celery workers - frontend react com vite - integração blender + openfoam - deploy automático na nuvem (railway) - scripts de setup automático onde colocar: - docker-compose.yml na raiz do projeto - Dockerfile na raiz do projeto - todos os arquivos na raiz como usar: - windows: executar docker-setup.bat - linux/mac: executar ./docker-setup.sh - produção: railway up deploy na nuvem: - aplicação web disponível 24/7 - blender + openfoam rodando na nuvem - banco de dados gerenciado - acesso global via navegador - deploy automático via git push benefícios: - sem necessidade de instalação local - acesso de qualquer lugar - recursos escaláveis - backup automático - monitoramento completo - profissionalismo para tcc
1 parent a4b8aad commit 3772813

27 files changed

Lines changed: 1425 additions & 153 deletions

DEPLOY_NUVEM_GUIA.md

Lines changed: 540 additions & 0 deletions
Large diffs are not rendered by default.

DOCKER_COMPOSE_GUIA.md

Lines changed: 587 additions & 0 deletions
Large diffs are not rendered by default.

Dockerfile

Lines changed: 40 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,44 @@
1-
#dockerfile para containerização do projeto TCC
2-
#geração de Leitos de extração com Blender
3-
FROM ubuntu:22.04
4-
# evitar prompts interativos durante a instalação
5-
ENV DEBIAN_FRONTEND=noninteractive
6-
# definir diretório de trabalho
1+
FROM python:3.11-slim
2+
73
WORKDIR /app
8-
#instalar dependências do sistema
4+
5+
# instalar dependências do sistema
96
RUN apt-get update && apt-get install -y \
10-
python3 \
11-
python3-pip \
12-
python3-venv \
13-
wget \
7+
gcc \
8+
g++ \
9+
libpq-dev \
1410
curl \
15-
unzip \
16-
xz-utils \
17-
libgl1-mesa-glx \
18-
libglu1-mesa \
19-
libxrender1 \
20-
libxext6 \
21-
libxrandr2 \
22-
libxinerama1 \
23-
libxi6 \
24-
libxfixes3 \
25-
libxcursor1 \
26-
libxcomposite1 \
27-
libxdamage1 \
28-
libxss1 \
29-
libxtst6 \
30-
libgconf-2-4 \
31-
libasound2 \
32-
libpulse0 \
33-
libdrm2 \
34-
libxkbcommon0 \
35-
libxcb1 \
36-
libxcb-icccm4 \
37-
libxcb-image0 \
38-
libxcb-shm0 \
39-
libxcb-keysyms1 \
40-
libxcb-randr0 \
41-
libxcb-render-util0 \
42-
libxcb-xinerama0 \
43-
libxcb-xkb1 \
44-
libxkbcommon-x11-0 \
11+
wget \
12+
git \
13+
build-essential \
4514
&& rm -rf /var/lib/apt/lists/*
46-
#criar usuario nao-root
47-
RUN useradd -m -s /bin/bash blender_user
48-
USER blender_user
49-
# definir variaveis de ambiente
50-
ENV HOME=/home/blender_user
51-
ENV PATH="/home/blender_user/.local/bin:$PATH"
52-
# Instalar Blender
53-
RUN mkdir -p /home/blender_user/blender && \
54-
cd /home/blender_user/blender && \
55-
wget https://download.blender.org/release/Blender4.0/blender-4.0.2-linux-x64.tar.xz && \
56-
tar -xf blender-4.0.2-linux-x64.tar.xz && \
57-
rm blender-4.0.2-linux-x64.tar.xz && \
58-
ln -s /home/blender_user/blender/blender-4.0.2-linux-x64/blender /home/blender_user/.local/bin/blender
59-
# copiar arquivos do projeto
60-
COPY --chown=blender_user:blender_user . /app/
61-
#instalar dependências Python
62-
RUN pip3 install --user argparse pathlib
63-
# Configurar PATH
64-
ENV PATH="/home/blender_user/.local/bin:$PATH"
65-
# Verificar instalação do Blender
66-
RUN blender --version
67-
# Executar setup automático
68-
RUN python3 scripts/setup_project.py --no-auto-install --no-sample
69-
# Expor porta (se necessário para interface web)
70-
EXPOSE 8000
71-
# Comando padrão
72-
CMD ["python3", "scripts/leito_standalone.py", "--help"]
15+
16+
# instalar openfoam
17+
RUN curl -s https://dl.openfoam.org/gpg.key | apt-key add - \
18+
&& echo "deb http://dl.openfoam.org/ubuntu focal main" >> /etc/apt/sources.list.d/openfoam.list \
19+
&& apt-get update \
20+
&& apt-get install -y openfoam11-dev
21+
22+
# instalar blender
23+
RUN wget https://download.blender.org/release/Blender4.0/blender-4.0.0-linux-x64.tar.xz \
24+
&& tar -xf blender-4.0.0-linux-x64.tar.xz \
25+
&& mv blender-4.0.0-linux-x64 /opt/blender \
26+
&& rm blender-4.0.0-linux-x64.tar.xz
27+
28+
# adicionar ao path
29+
ENV PATH="/opt/blender:${PATH}"
30+
ENV PATH="/opt/openfoam11/platforms/linux64GccDPInt32Opt/bin:${PATH}"
31+
32+
# copiar requirements
33+
COPY backend/requirements.txt .
34+
RUN pip install --no-cache-dir -r requirements.txt
35+
36+
# copiar código
37+
COPY backend/ .
38+
COPY scripts/ ./scripts/
39+
40+
# criar diretórios
41+
RUN mkdir -p output logs
42+
43+
# comando padrão
44+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

Dockerfile.frontend

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM node:18-alpine
2+
3+
WORKDIR /app
4+
5+
# copiar package files
6+
COPY frontend/package*.json ./
7+
8+
# instalar dependências
9+
RUN npm ci
10+
11+
# copiar código
12+
COPY frontend/ .
13+
14+
# comando padrão
15+
CMD ["npm", "run", "dev"]

docker-compose.yml

Lines changed: 93 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,150 @@
11
version: '3.8'
22

33
services:
4-
# banco de dados PostgreSQL
4+
# banco de dados postgresql
55
postgres:
6-
image: postgres:16-alpine
7-
container_name: tcc-postgres
6+
image: postgres:15
7+
container_name: cfd_postgres
88
environment:
9-
POSTGRES_DB: cfd_dashboard
10-
POSTGRES_USER: cfd_user
11-
POSTGRES_PASSWORD: cfd_password
9+
POSTGRES_DB: cfd_pipeline
10+
POSTGRES_USER: postgres
11+
POSTGRES_PASSWORD: postgres123
12+
ports:
13+
- "5432:5432"
1214
volumes:
1315
- postgres_data:/var/lib/postgresql/data
16+
healthcheck:
17+
test: ["CMD-SHELL", "pg_isready -U postgres"]
18+
interval: 10s
19+
timeout: 5s
20+
retries: 5
21+
22+
# redis para cache e celery
23+
redis:
24+
image: redis:7-alpine
25+
container_name: cfd_redis
1426
ports:
15-
- "5432:5432"
27+
- "6379:6379"
28+
command: redis-server --appendonly yes
29+
volumes:
30+
- redis_data:/data
1631
healthcheck:
17-
test: ["CMD-SHELL", "pg_isready -U cfd_user -d cfd_dashboard"]
32+
test: ["CMD", "redis-cli", "ping"]
1833
interval: 10s
1934
timeout: 5s
2035
retries: 5
2136

22-
# MinIO para armazenamento de arquivos
37+
# minio para armazenamento de arquivos
2338
minio:
24-
image: minio/minio:latest
25-
container_name: tcc-minio
39+
image: minio/minio
40+
container_name: cfd_minio
2641
environment:
2742
MINIO_ROOT_USER: minioadmin
2843
MINIO_ROOT_PASSWORD: minioadmin123
29-
volumes:
30-
- minio_data:/data
3144
ports:
3245
- "9000:9000"
3346
- "9001:9001"
47+
volumes:
48+
- minio_data:/data
3449
command: server /data --console-address ":9001"
3550
healthcheck:
3651
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
3752
interval: 30s
3853
timeout: 20s
3954
retries: 3
4055

41-
# redis para filas de tarefas
42-
redis:
43-
image: redis:7-alpine
44-
container_name: tcc-redis
45-
ports:
46-
- "6379:6379"
47-
volumes:
48-
- redis_data:/data
49-
healthcheck:
50-
test: ["CMD", "redis-cli", "ping"]
51-
interval: 10s
52-
timeout: 5s
53-
retries: 5
54-
55-
# API backend (FastAPI)
56+
# backend fastapi
5657
backend:
57-
build:
58+
build:
5859
context: .
59-
dockerfile: Dockerfile.backend
60-
container_name: tcc-backend
61-
environment:
62-
- DATABASE_URL=postgresql://cfd_user:cfd_password@postgres:5432/cfd_dashboard
63-
- REDIS_URL=redis://redis:6379
64-
- MINIO_ENDPOINT=minio:9000
65-
- MINIO_ACCESS_KEY=minioadmin
66-
- MINIO_SECRET_KEY=minioadmin123
60+
dockerfile: Dockerfile
61+
container_name: cfd_backend
6762
ports:
6863
- "8000:8000"
64+
environment:
65+
DATABASE_URL: postgresql://postgres:postgres123@postgres:5432/cfd_pipeline
66+
REDIS_URL: redis://redis:6379
67+
MINIO_ENDPOINT: minio:9000
68+
MINIO_ACCESS_KEY: minioadmin
69+
MINIO_SECRET_KEY: minioadmin123
70+
CELERY_BROKER_URL: redis://redis:6379
71+
CELERY_RESULT_BACKEND: redis://redis:6379
72+
volumes:
73+
- ./backend:/app
74+
- ./scripts:/app/scripts
75+
- ./output:/app/output
6976
depends_on:
7077
postgres:
7178
condition: service_healthy
7279
redis:
7380
condition: service_healthy
7481
minio:
7582
condition: service_healthy
76-
volumes:
77-
- ./models:/app/models
78-
- ./exports:/app/exports
79-
- ./temp:/app/temp
80-
- ./scripts:/app/scripts
83+
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
8184

82-
# frontend React
85+
# frontend react
8386
frontend:
84-
build:
85-
context: ./frontend
86-
dockerfile: Dockerfile
87-
container_name: tcc-frontend
88-
environment:
89-
- REACT_APP_API_URL=http://localhost:8000
90-
- REACT_APP_ENVIRONMENT=production
87+
build:
88+
context: .
89+
dockerfile: Dockerfile.frontend
90+
container_name: cfd_frontend
9191
ports:
92-
- "3000:80"
92+
- "5173:5173"
93+
environment:
94+
VITE_API_URL: http://localhost:8000
95+
volumes:
96+
- ./frontend:/app
97+
- /app/node_modules
9398
depends_on:
9499
- backend
100+
command: npm run dev
95101

96-
# worker para processamento de simulacoes
97-
worker:
98-
build:
102+
# celery worker para tarefas assíncronas
103+
celery-worker:
104+
build:
99105
context: .
100-
dockerfile: Dockerfile.worker
101-
container_name: tcc-worker
106+
dockerfile: Dockerfile
107+
container_name: cfd_celery_worker
102108
environment:
103-
- DATABASE_URL=postgresql://cfd_user:cfd_password@postgres:5432/cfd_dashboard
104-
- REDIS_URL=redis://redis:6379
105-
- MINIO_ENDPOINT=minio:9000
106-
- MINIO_ACCESS_KEY=minioadmin
107-
- MINIO_SECRET_KEY=minioadmin123
109+
DATABASE_URL: postgresql://postgres:postgres123@postgres:5432/cfd_pipeline
110+
REDIS_URL: redis://redis:6379
111+
MINIO_ENDPOINT: minio:9000
112+
MINIO_ACCESS_KEY: minioadmin
113+
MINIO_SECRET_KEY: minioadmin123
114+
CELERY_BROKER_URL: redis://redis:6379
115+
CELERY_RESULT_BACKEND: redis://redis:6379
116+
volumes:
117+
- ./backend:/app
118+
- ./scripts:/app/scripts
119+
- ./output:/app/output
108120
depends_on:
109121
postgres:
110122
condition: service_healthy
111123
redis:
112124
condition: service_healthy
113-
minio:
114-
condition: service_healthy
115-
volumes:
116-
- ./models:/app/models
117-
- ./exports:/app/exports
118-
- ./temp:/app/temp
119-
- ./scripts:/app/scripts
125+
command: celery -A app.core.celery worker --loglevel=info --concurrency=2
120126

121-
# blender para geracao de geometrias
122-
blender:
123-
build: .
124-
container_name: tcc-blender
125-
volumes:
126-
- ./models:/app/models
127-
- ./exports:/app/exports
128-
- ./temp:/app/temp
129-
- ./scripts:/app/scripts
127+
# celery beat para tarefas agendadas
128+
celery-beat:
129+
build:
130+
context: .
131+
dockerfile: Dockerfile
132+
container_name: cfd_celery_beat
130133
environment:
131-
- DISPLAY=${DISPLAY}
132-
- PYTHONPATH=/app/scripts
133-
working_dir: /app
134-
command: ["python3", "scripts/leito_standalone.py", "--help"]
134+
DATABASE_URL: postgresql://postgres:postgres123@postgres:5432/cfd_pipeline
135+
REDIS_URL: redis://redis:6379
136+
CELERY_BROKER_URL: redis://redis:6379
137+
CELERY_RESULT_BACKEND: redis://redis:6379
138+
volumes:
139+
- ./backend:/app
140+
depends_on:
141+
postgres:
142+
condition: service_healthy
143+
redis:
144+
condition: service_healthy
145+
command: celery -A app.core.celery beat --loglevel=info
135146

136147
volumes:
137148
postgres_data:
138-
minio_data:
139149
redis_data:
140-
models:
141-
exports:
142-
temp:
150+
minio_data:

0 commit comments

Comments
 (0)