ConfiguraciΓ³n completa: Next.js 14 + FastAPI Β· GitHub Actions CI/CD Β· Railway deploy
# Auto-detectado: Next.js 14 + Node 20 (.nvmrc) # Generado por CULTIVA IA Β· skill nixpacks-build [phases.setup] nixPkgs = ["nodejs_20", "openssl"] [phases.install] cmds = ["npm ci --include=dev"] [phases.build] cmds = [ "npx prisma generate", "npm run build" ] [start] cmd = "node server.js" [variables] NODE_ENV = "production" NEXT_TELEMETRY_DISABLED = "1" # DATABASE_URL β Railway secret (no en repo)
# Auto-detectado: Python 3.12 + FastAPI # psycopg2 nativo (ARM64) + Pillow + FFmpeg [phases.setup] nixPkgs = [ "python312", "postgresql_15", # psycopg2 compile "libffi", "ffmpeg", # procesamiento media "libvips" # Pillow optimizado ] [phases.install] cmds = [ "pip install --upgrade pip", "pip install -r requirements.txt" ] [phases.build] cmds = [ "python -m compileall app/" ] [start] cmd = "gunicorn app.main:app --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:$PORT --workers 4"
name: MegaLeads Β· Build & Deploy on: push: branches: [main] env: REGISTRY: ghcr.io IMAGE_FE: ghcr.io/megaleads/frontend IMAGE_BE: ghcr.io/megaleads/backend jobs: build-frontend: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install Nixpacks run: curl -sSL https://nixpacks.com/install.sh | bash - name: Build Frontend Image run: | nixpacks build ./frontend \ --name $IMAGE_FE:${{ github.sha }} \ --env NODE_ENV=production \ --env NEXT_TELEMETRY_DISABLED=1 - name: Login GHCR & Push run: | echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin docker push $IMAGE_FE:${{ github.sha }} docker tag $IMAGE_FE:${{ github.sha }} $IMAGE_FE:latest docker push $IMAGE_FE:latest build-backend: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install Nixpacks run: curl -sSL https://nixpacks.com/install.sh | bash - name: Build Backend Image run: | nixpacks build ./backend \ --name $IMAGE_BE:${{ github.sha }} - name: Login GHCR & Push run: | echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin docker push $IMAGE_BE:${{ github.sha }} docker tag $IMAGE_BE:${{ github.sha }} $IMAGE_BE:latest docker push $IMAGE_BE:latest deploy-railway: needs: [build-frontend, build-backend] runs-on: ubuntu-latest steps: - name: Deploy to Railway run: npx @railway/cli up --detach env: RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
$ nixpacks plan ./frontend ββββββββββββββββββββββββββββββββ Providers node Framework Next.js Node version 20.x (from .nvmrc) ββββββββββββββββββββββββββββββββ Phases: setup nixPkgs: nodejs_20, openssl install cmds: βΈ npm ci --include=dev build cmds: βΈ npx prisma generate βΈ npm run build start cmd: node server.js ββββββββββββββββββββββββββββββββ β Plan generated in 0.3s
$ nixpacks build ./backend --name megaleads/backend [1/5] βΆ Detecting providers... β python (requirements.txt) β version: 3.12 (.python-version) [2/5] βΆ Setup phase Nix packages: + python312 + postgresql_15 (libpq-dev) + ffmpeg + libvips + libffi [3/5] βΆ Install phase β pip install --upgrade pip 1.2s β pip install -r requirements.txt 38.4s psycopg2 2.9.9 (native ARM64 β) Pillow 10.3.0 (libvips β) fastapi 0.111.0 + 47 more packages [4/5] βΆ Build phase β python -m compileall app/ 0.8s [5/5] βΆ Finalizing image β Image size: 487 MB β megaleads/backend:latest ββββββββββββββββββββββββββββββ β Build completed in 3m 41s
| Criterio | Dockerfile manual | Nixpacks | Ganador |
|---|---|---|---|
| Tiempo de configuraciΓ³n inicial | 2β4h (investigar, probar, depurar) | ~10 min (detecta automΓ‘tico) | β Nixpacks |
| psycopg2 nativo ARM64 | Requiere 15+ lΓneas RUN apt-get | nixPkgs = ["postgresql_15"] β 1 lΓnea | β Nixpacks |
| Reproducibilidad | apt puede dar versiones distintas | Nix = hash fijo, siempre idΓ©ntico | β Nixpacks |
| CachΓ© de capas | Manual (COPY package.json primero) | AutomΓ‘tico por fase | β Nixpacks |
| Multi-stage builds | Control total, pero complejo | AutomΓ‘tico (builder / runner) | β Nixpacks |
| PersonalizaciΓ³n avanzada | Control total | nixpacks.toml cubre 95% casos | β Empate |
| Mantenimiento a largo plazo | Alto (actualizar base image) | Bajo (Railway actualiza builders) | β Nixpacks |