feat(infraestrutura): adiciona plugin infraestrutura (agents, skills, knowledge e metadados do projeto)
This commit is contained in:
@@ -0,0 +1,248 @@
|
||||
---
|
||||
name: easypanel-init
|
||||
description: Inicialização de projectos EasyPanel com configuração adequada via API oficial — scaffold automático para Node.js, PHP ou sites estáticos.
|
||||
disable-model-invocation: true
|
||||
layer: wiki
|
||||
---
|
||||
|
||||
# EasyPanel Init
|
||||
|
||||
Scaffold automático de projectos optimizados para deploy no EasyPanel.
|
||||
|
||||
## Quando Usar
|
||||
|
||||
- Iniciar novo projecto do zero
|
||||
- Converter projecto existente para EasyPanel
|
||||
- Setup rápido com best practices
|
||||
- Criar estrutura standardizada
|
||||
- Prototype rapidamente
|
||||
|
||||
## Sintaxe
|
||||
|
||||
```bash
|
||||
/easypanel-init <project-name> <domain> [--type nodejs|python|go] [--db postgres|mysql|none]
|
||||
```
|
||||
|
||||
## Exemplos
|
||||
|
||||
```bash
|
||||
# Node.js API sem database
|
||||
/easypanel-init dashboard-api dashboard.descomplicar.pt --type nodejs
|
||||
|
||||
# Node.js API com PostgreSQL
|
||||
/easypanel-init crm-api crm.descomplicar.pt --type nodejs --db postgres
|
||||
|
||||
# Python API (futuro)
|
||||
/easypanel-init ml-api ml.descomplicar.pt --type python
|
||||
|
||||
# Go API (futuro)
|
||||
/easypanel-init fast-api api.descomplicar.pt --type go
|
||||
```
|
||||
|
||||
## Workflow Completo
|
||||
|
||||
### 1. Criar Estrutura de Pastas
|
||||
|
||||
```
|
||||
project-root/
|
||||
├── src/
|
||||
│ ├── index.ts (ou main.py, main.go)
|
||||
│ └── routes/
|
||||
│ └── health.ts
|
||||
├── Dockerfile (template multi-stage)
|
||||
├── docker-compose.yml (Traefik labels)
|
||||
├── .dockerignore
|
||||
├── .gitignore
|
||||
├── .env.example
|
||||
├── package.json (scripts padronizados)
|
||||
├── tsconfig.json (se TypeScript)
|
||||
├── .gitea/
|
||||
│ └── workflows/
|
||||
│ └── deploy.yml (CI/CD)
|
||||
└── README.md (deploy guide)
|
||||
```
|
||||
|
||||
### 2. Generate Templates
|
||||
|
||||
#### Dockerfile (Multi-stage Node.js)
|
||||
|
||||
```dockerfile
|
||||
# Stage 1: Dependencies
|
||||
FROM node:22-alpine AS deps
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Stage 2: Builder
|
||||
FROM node:22-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# Stage 3: Runner
|
||||
FROM node:22-alpine AS runner
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV=production
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY --from=builder /app/dist ./dist
|
||||
COPY package*.json ./
|
||||
|
||||
RUN addgroup -g 1001 -S nodejs && \
|
||||
adduser -S nodejs -u 1001
|
||||
|
||||
USER nodejs
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD node -e "require('http').get('http://localhost:3000/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
|
||||
|
||||
CMD ["npm", "start"]
|
||||
```
|
||||
|
||||
#### docker-compose.yml (Traefik)
|
||||
|
||||
```yaml
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
app:
|
||||
build: .
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- PORT=3000
|
||||
networks:
|
||||
- traefik
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.PROJECTNAME.rule=Host(`DOMAIN`)"
|
||||
- "traefik.http.routers.PROJECTNAME.entrypoints=websecure"
|
||||
- "traefik.http.routers.PROJECTNAME.tls.certresolver=letsencrypt"
|
||||
- "traefik.http.services.PROJECTNAME.loadbalancer.server.port=3000"
|
||||
- "traefik.http.services.PROJECTNAME.loadbalancer.healthcheck.path=/health"
|
||||
- "traefik.http.services.PROJECTNAME.loadbalancer.healthcheck.interval=10s"
|
||||
|
||||
networks:
|
||||
traefik:
|
||||
external: true
|
||||
```
|
||||
|
||||
#### Health Endpoint (Express)
|
||||
|
||||
```typescript
|
||||
import { Router } from 'express'
|
||||
import type { Request, Response } from 'express'
|
||||
|
||||
const router = Router()
|
||||
|
||||
router.get('/health', (req: Request, res: Response) => {
|
||||
res.status(200).json({
|
||||
status: 'ok',
|
||||
timestamp: new Date().toISOString(),
|
||||
uptime: process.uptime(),
|
||||
environment: process.env.NODE_ENV || 'development'
|
||||
})
|
||||
})
|
||||
|
||||
export default router
|
||||
```
|
||||
|
||||
#### Gitea Workflow (.gitea/workflows/deploy.yml)
|
||||
|
||||
```yaml
|
||||
name: Deploy to EasyPanel
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '22'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Run tests
|
||||
run: npm test
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
- name: Trigger EasyPanel Deploy
|
||||
run: |
|
||||
curl -X POST ${{ secrets.EASYPANEL_WEBHOOK_URL }}
|
||||
```
|
||||
|
||||
#### package.json (scripts)
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "PROJECT_NAME",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "tsx watch src/index.ts",
|
||||
"build": "tsc",
|
||||
"start": "node dist/index.js",
|
||||
"lint": "eslint .",
|
||||
"test": "vitest"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### README.md
|
||||
|
||||
```markdown
|
||||
# PROJECT_NAME
|
||||
|
||||
## Setup Local
|
||||
|
||||
1. npm install
|
||||
2. cp .env.example .env.local
|
||||
3. npm run dev
|
||||
|
||||
## Deploy EasyPanel
|
||||
|
||||
1. Push to main: `git push origin main`
|
||||
2. CI/CD auto-deploy via Gitea Actions
|
||||
3. Health check: https://DOMAIN/health
|
||||
|
||||
## Environment Variables
|
||||
|
||||
See `.env.example` for required variables.
|
||||
|
||||
## Architecture
|
||||
|
||||
- Multi-stage Docker build (80% smaller image)
|
||||
- Traefik routing with SSL
|
||||
- Health checks every 10s
|
||||
- Non-root user for security
|
||||
```
|
||||
|
||||
### 3. Initialize Git
|
||||
|
||||
```bash
|
||||
git init
|
||||
git add .
|
||||
git commit -m "chore: initial project setup via /easypanel-init"
|
||||
```
|
||||
|
||||
### 4. Criar Projecto no EasyPanel via API
|
||||
|
||||
```bash
|
||||
# Obte
|
||||
Reference in New Issue
Block a user