chore: desativa GitHub Actions e adiciona docs de setup
Some checks failed
Some checks failed
- Move .github/workflows para .github/workflows.disabled - Adiciona docs/SETUP.md com guia de setup em novo computador - Adiciona scripts/setup-dev.sh para setup automatizado - Remove GitHub Actions runner da VPS (agora usa apenas Forgejo) CI/CD agora e feito exclusivamente via Forgejo Actions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
454c3d5c3b
commit
2c95834598
5 changed files with 384 additions and 0 deletions
196
docs/SETUP.md
Normal file
196
docs/SETUP.md
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
# Setup em Novo Computador
|
||||
|
||||
Guia rapido para configurar o ambiente de desenvolvimento em uma nova maquina.
|
||||
|
||||
## Pre-requisitos
|
||||
|
||||
- **Git** instalado
|
||||
- **Bun** 1.3+ ([bun.sh](https://bun.sh))
|
||||
- **Docker** (para PostgreSQL local)
|
||||
- **Node.js** 20+ (opcional, para algumas ferramentas)
|
||||
|
||||
### Instalar Bun (se ainda nao tiver)
|
||||
|
||||
```bash
|
||||
# Linux/macOS/WSL
|
||||
curl -fsSL https://bun.sh/install | bash
|
||||
|
||||
# Windows (PowerShell)
|
||||
powershell -c "irm bun.sh/install.ps1 | iex"
|
||||
```
|
||||
|
||||
## Setup Rapido
|
||||
|
||||
### 1. Clonar o repositorio
|
||||
|
||||
```bash
|
||||
git clone https://github.com/esdrasrenan/sistema-de-chamados.git
|
||||
cd sistema-de-chamados
|
||||
```
|
||||
|
||||
Ou se ja tiver o repositorio:
|
||||
|
||||
```bash
|
||||
cd sistema-de-chamados
|
||||
git pull origin main
|
||||
```
|
||||
|
||||
### 2. Configurar remotes (para CI/CD)
|
||||
|
||||
```bash
|
||||
# Adicionar remote do Forgejo (dispara CI/CD)
|
||||
git remote add forgejo https://git.esdrasrenan.com.br/esdras/sistema-de-chamados.git
|
||||
|
||||
# Verificar remotes
|
||||
git remote -v
|
||||
# Deve mostrar:
|
||||
# origin https://github.com/esdrasrenan/sistema-de-chamados.git (fetch)
|
||||
# origin https://github.com/esdrasrenan/sistema-de-chamados.git (push)
|
||||
# forgejo https://git.esdrasrenan.com.br/esdras/sistema-de-chamados.git (fetch)
|
||||
# forgejo https://git.esdrasrenan.com.br/esdras/sistema-de-chamados.git (push)
|
||||
```
|
||||
|
||||
### 3. Instalar dependencias
|
||||
|
||||
```bash
|
||||
bun install
|
||||
```
|
||||
|
||||
### 4. Configurar banco de dados
|
||||
|
||||
```bash
|
||||
# Subir PostgreSQL via Docker
|
||||
docker run -d \
|
||||
--name postgres-dev \
|
||||
-p 5432:5432 \
|
||||
-e POSTGRES_PASSWORD=dev \
|
||||
-e POSTGRES_DB=sistema_chamados \
|
||||
postgres:16
|
||||
|
||||
# Criar arquivo .env
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
Edite o `.env` e configure:
|
||||
|
||||
```env
|
||||
DATABASE_URL=postgresql://postgres:dev@localhost:5432/sistema_chamados
|
||||
BETTER_AUTH_SECRET=sua-chave-secreta-aqui
|
||||
NEXT_PUBLIC_APP_URL=http://localhost:3000
|
||||
BETTER_AUTH_URL=http://localhost:3000
|
||||
```
|
||||
|
||||
### 5. Inicializar o banco
|
||||
|
||||
```bash
|
||||
# Gerar cliente Prisma
|
||||
bun run prisma:generate
|
||||
|
||||
# Criar tabelas no banco
|
||||
bunx prisma db push
|
||||
|
||||
# Popular dados iniciais
|
||||
bun run auth:seed
|
||||
```
|
||||
|
||||
### 6. Rodar o projeto
|
||||
|
||||
```bash
|
||||
bun run dev:bun
|
||||
```
|
||||
|
||||
Acesse: http://localhost:3000
|
||||
|
||||
**Credenciais padrao:** `admin@sistema.dev` / `admin123`
|
||||
|
||||
## Comandos Uteis
|
||||
|
||||
| Comando | Descricao |
|
||||
|---------|-----------|
|
||||
| `bun run dev:bun` | Iniciar servidor de desenvolvimento |
|
||||
| `bun run build:bun` | Build de producao |
|
||||
| `bun run lint` | Verificar codigo (ESLint) |
|
||||
| `bun test` | Rodar testes |
|
||||
| `bun run prisma:generate` | Gerar cliente Prisma |
|
||||
| `bunx prisma studio` | Interface visual do banco |
|
||||
|
||||
## Fluxo de Trabalho com Git
|
||||
|
||||
### Push para ambos os remotes (recomendado)
|
||||
|
||||
```bash
|
||||
# Fazer alteracoes
|
||||
git add .
|
||||
git commit -m "sua mensagem"
|
||||
|
||||
# Push para GitHub (backup) e Forgejo (CI/CD)
|
||||
git push origin main && git push forgejo main
|
||||
```
|
||||
|
||||
### Configurar alias para push duplo (opcional)
|
||||
|
||||
```bash
|
||||
# Criar alias
|
||||
git config alias.push-all '!git push origin main && git push forgejo main'
|
||||
|
||||
# Usar
|
||||
git push-all
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Erro: "bun: command not found"
|
||||
|
||||
```bash
|
||||
# Adicionar Bun ao PATH
|
||||
export PATH="$HOME/.bun/bin:$PATH"
|
||||
|
||||
# Adicionar permanentemente ao ~/.bashrc ou ~/.zshrc
|
||||
echo 'export PATH="$HOME/.bun/bin:$PATH"' >> ~/.bashrc
|
||||
source ~/.bashrc
|
||||
```
|
||||
|
||||
### Erro: Prisma "P2021" / tabelas nao existem
|
||||
|
||||
```bash
|
||||
bunx prisma db push
|
||||
bun run auth:seed
|
||||
```
|
||||
|
||||
### Erro: Lockfile desatualizado
|
||||
|
||||
```bash
|
||||
bun install
|
||||
```
|
||||
|
||||
### PostgreSQL nao conecta
|
||||
|
||||
```bash
|
||||
# Verificar se o container esta rodando
|
||||
docker ps
|
||||
|
||||
# Se nao estiver, iniciar
|
||||
docker start postgres-dev
|
||||
|
||||
# Ou recriar
|
||||
docker rm -f postgres-dev
|
||||
docker run -d --name postgres-dev -p 5432:5432 -e POSTGRES_PASSWORD=dev -e POSTGRES_DB=sistema_chamados postgres:16
|
||||
```
|
||||
|
||||
## Convex (Backend de Tempo Real)
|
||||
|
||||
Para desenvolvimento com Convex local:
|
||||
|
||||
```bash
|
||||
# Terminal 1: Convex dev server
|
||||
bun run convex:dev:bun
|
||||
|
||||
# Terminal 2: Next.js
|
||||
bun run dev:bun
|
||||
```
|
||||
|
||||
## Mais Informacoes
|
||||
|
||||
- **Desenvolvimento detalhado:** `docs/DEV.md`
|
||||
- **Deploy e operacoes:** `docs/DEPLOY-RUNBOOK.md`
|
||||
- **CI/CD Forgejo:** `docs/FORGEJO-CI-CD.md`
|
||||
188
scripts/setup-dev.sh
Normal file
188
scripts/setup-dev.sh
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
#!/bin/bash
|
||||
# Script de setup para ambiente de desenvolvimento
|
||||
# Uso: ./scripts/setup-dev.sh
|
||||
|
||||
set -e
|
||||
|
||||
echo "=== Setup do Ambiente de Desenvolvimento ==="
|
||||
echo ""
|
||||
|
||||
# Cores para output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Funcao para printar status
|
||||
ok() { echo -e "${GREEN}[OK]${NC} $1"; }
|
||||
warn() { echo -e "${YELLOW}[AVISO]${NC} $1"; }
|
||||
err() { echo -e "${RED}[ERRO]${NC} $1"; }
|
||||
|
||||
# 1. Verificar pre-requisitos
|
||||
echo "1. Verificando pre-requisitos..."
|
||||
|
||||
# Verificar Bun
|
||||
if command -v bun &> /dev/null; then
|
||||
BUN_VERSION=$(bun --version)
|
||||
ok "Bun instalado: v$BUN_VERSION"
|
||||
else
|
||||
err "Bun nao encontrado!"
|
||||
echo " Instale com: curl -fsSL https://bun.sh/install | bash"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verificar Docker
|
||||
if command -v docker &> /dev/null; then
|
||||
ok "Docker instalado"
|
||||
else
|
||||
warn "Docker nao encontrado. Voce precisara configurar o PostgreSQL manualmente."
|
||||
fi
|
||||
|
||||
# Verificar Git
|
||||
if command -v git &> /dev/null; then
|
||||
ok "Git instalado"
|
||||
else
|
||||
err "Git nao encontrado!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# 2. Configurar remotes do Git
|
||||
echo "2. Configurando remotes do Git..."
|
||||
|
||||
# Verificar se estamos em um repositorio git
|
||||
if [ ! -d ".git" ]; then
|
||||
err "Este diretorio nao e um repositorio Git!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verificar/adicionar remote forgejo
|
||||
if git remote get-url forgejo &> /dev/null; then
|
||||
ok "Remote 'forgejo' ja configurado"
|
||||
else
|
||||
git remote add forgejo https://git.esdrasrenan.com.br/esdras/sistema-de-chamados.git
|
||||
ok "Remote 'forgejo' adicionado"
|
||||
fi
|
||||
|
||||
# Mostrar remotes
|
||||
echo " Remotes configurados:"
|
||||
git remote -v | sed 's/^/ /'
|
||||
|
||||
echo ""
|
||||
|
||||
# 3. Instalar dependencias
|
||||
echo "3. Instalando dependencias..."
|
||||
bun install
|
||||
ok "Dependencias instaladas"
|
||||
|
||||
echo ""
|
||||
|
||||
# 4. Configurar arquivo .env
|
||||
echo "4. Configurando arquivo .env..."
|
||||
|
||||
if [ -f ".env" ]; then
|
||||
warn "Arquivo .env ja existe. Pulando..."
|
||||
else
|
||||
if [ -f ".env.example" ]; then
|
||||
cp .env.example .env
|
||||
ok "Arquivo .env criado a partir do .env.example"
|
||||
warn "IMPORTANTE: Edite o arquivo .env com suas configuracoes!"
|
||||
else
|
||||
# Criar .env basico
|
||||
cat > .env << 'EOF'
|
||||
DATABASE_URL=postgresql://postgres:dev@localhost:5432/sistema_chamados
|
||||
BETTER_AUTH_SECRET=dev-secret-change-in-production
|
||||
NEXT_PUBLIC_APP_URL=http://localhost:3000
|
||||
BETTER_AUTH_URL=http://localhost:3000
|
||||
NEXT_PUBLIC_CONVEX_URL=http://localhost:3210
|
||||
EOF
|
||||
ok "Arquivo .env criado com valores padrao para desenvolvimento"
|
||||
warn "IMPORTANTE: Ajuste as configuracoes conforme necessario!"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# 5. Configurar PostgreSQL via Docker
|
||||
echo "5. Configurando PostgreSQL..."
|
||||
|
||||
if command -v docker &> /dev/null; then
|
||||
if docker ps -a --format '{{.Names}}' | grep -q '^postgres-dev$'; then
|
||||
# Container existe, verificar se esta rodando
|
||||
if docker ps --format '{{.Names}}' | grep -q '^postgres-dev$'; then
|
||||
ok "PostgreSQL ja esta rodando"
|
||||
else
|
||||
docker start postgres-dev
|
||||
ok "PostgreSQL iniciado"
|
||||
fi
|
||||
else
|
||||
# Criar container
|
||||
docker run -d \
|
||||
--name postgres-dev \
|
||||
-p 5432:5432 \
|
||||
-e POSTGRES_PASSWORD=dev \
|
||||
-e POSTGRES_DB=sistema_chamados \
|
||||
postgres:16
|
||||
ok "PostgreSQL criado e iniciado"
|
||||
echo " Aguardando PostgreSQL inicializar..."
|
||||
sleep 3
|
||||
fi
|
||||
else
|
||||
warn "Docker nao disponivel. Configure o PostgreSQL manualmente."
|
||||
echo " DATABASE_URL deve apontar para seu servidor PostgreSQL"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# 6. Gerar cliente Prisma
|
||||
echo "6. Gerando cliente Prisma..."
|
||||
bun run prisma:generate
|
||||
ok "Cliente Prisma gerado"
|
||||
|
||||
echo ""
|
||||
|
||||
# 7. Inicializar banco de dados
|
||||
echo "7. Inicializando banco de dados..."
|
||||
|
||||
# Verificar se o banco esta acessivel
|
||||
if bunx prisma db push --skip-generate 2>/dev/null; then
|
||||
ok "Schema do banco atualizado"
|
||||
|
||||
# Seed inicial
|
||||
echo " Populando dados iniciais..."
|
||||
if bun run auth:seed 2>/dev/null; then
|
||||
ok "Dados iniciais criados"
|
||||
else
|
||||
warn "Seed falhou ou ja foi executado anteriormente"
|
||||
fi
|
||||
else
|
||||
warn "Nao foi possivel conectar ao banco de dados"
|
||||
echo " Verifique se o PostgreSQL esta rodando e as credenciais no .env"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# 8. Configurar alias do Git (opcional)
|
||||
echo "8. Configurando alias do Git..."
|
||||
|
||||
if git config --get alias.push-all &> /dev/null; then
|
||||
ok "Alias 'push-all' ja configurado"
|
||||
else
|
||||
git config alias.push-all '!git push origin main && git push forgejo main'
|
||||
ok "Alias 'push-all' criado (use: git push-all)"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== Setup Concluido! ==="
|
||||
echo ""
|
||||
echo "Proximos passos:"
|
||||
echo " 1. Verifique/edite o arquivo .env"
|
||||
echo " 2. Execute: bun run dev:bun"
|
||||
echo " 3. Acesse: http://localhost:3000"
|
||||
echo " 4. Login: admin@sistema.dev / admin123"
|
||||
echo ""
|
||||
echo "Para fazer deploy:"
|
||||
echo " git push origin main && git push forgejo main"
|
||||
echo " ou: git push-all"
|
||||
echo ""
|
||||
Loading…
Add table
Add a link
Reference in a new issue