Astro Application Deployment + CI/CD
Workflow for compiling Astro in Docker clusters
0views
In this document, we document the pipeline necessary to take the static website (SSG) or with SSR (Server Side Rendering) from the local development environment to production.
The Pipeline in GitHub Actions
Sección titulada «El Pipeline en GitHub Actions»It is required to create a .github/workflows/deploy.yml file that compiles the files, validates Type checking, and uploads the compiled artifact /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/Dockerizing Static Astro (Nginx)
Sección titulada «Dockerizando Astro Estático (Nginx)»For projects hosted internally on your NAS or private infrastructure (HomeLab or Local VPS), we will package Astro in an optimized image based on 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;"]
