Applicatie-implementatie in Astro + CI/CD
Workflow voor het compileren van Astro in Docker-clusters
0lecturas
In dit document documenteren we de pipeline die nodig is om de statische website (SSG) of met SSR (Server Side Rendering) van de lokale ontwikkelomgeving naar productie te brengen.
De pipeline in GitHub Actions
Sección titulada «El Pipeline en GitHub Actions»Er is een .github/workflows/deploy.yml bestand nodig dat de bestanden compileert, typechecking valideert en het gecompileerde artefact uploadt /dist.
name: Deploy Astro a Producción
on: push: branches: - main
jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v2 with: version: 8 - name: Install Dependencies run: pnpm install --no-frozen-lockfile - name: Build run: pnpm run build - name: RSYNC to Server run: | # Ejemplo de despliegue directo a máquina Linux mediante SSH rsync -avz --delete ./dist/ ${USER}@${SERVER_IP}:/var/www/html/astro/Statische Astro dockeriseren (Nginx)
Sección titulada «Dockerizando Astro Estático (Nginx)»Voor projecten die intern worden gehost op je NAS of privé-infrastructuur (HomeLab of lokale VPS), verpakken we Astro in een geoptimaliseerde image gebaseerd op Alpine Linux:
# Etapa 1: ConstrucciónFROM node:20-alpine AS builderWORKDIR /appCOPY package*.json ./RUN npm ciCOPY . .RUN npm run build
# Etapa 2: ServidorFROM nginx:alpineCOPY --from=builder /app/dist /usr/share/nginx/htmlEXPOSE 80CMD ["nginx", "-g", "daemon off;"]
