Skip to content

Instantly share code, notes, and snippets.

@k8adev
Created July 3, 2025 23:35
Show Gist options
  • Select an option

  • Save k8adev/7f122e4deb83e625698aca45a20a3207 to your computer and use it in GitHub Desktop.

Select an option

Save k8adev/7f122e4deb83e625698aca45a20a3207 to your computer and use it in GitHub Desktop.

Revisions

  1. k8adev created this gist Jul 3, 2025.
    21 changes: 21 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    FROM node:22.14-bullseye-slim

    WORKDIR /usr/src/app

    COPY package*.json ./

    RUN apt-get update && apt-get install -y \
    curl \
    python3 \
    make \
    g++ \
    && rm -rf /var/lib/apt/lists/*
    RUN npm install --no-audit

    COPY . .

    RUN npm run build

    EXPOSE 3000

    CMD [ "node", "dist/main.js" ]
    17 changes: 17 additions & 0 deletions deploy.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    name: Deploy

    on:
    push:
    branches:
    - main
    - preview

    jobs:
    deploy:
    name: Deploy
    uses: ./.github/workflows/mau.yml
    with:
    # It uses the branch name to determine the environment to deploy to.
    # https://docs.github.com/en/actions/how-tos/managing-workflow-runs-and-deployments/managing-deployments/managing-environments-for-deployment
    environment: ${{ github.ref_name == 'main' && 'Production' || 'Preview' }}
    secrets: inherit
    47 changes: 47 additions & 0 deletions mau.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    name: Mau

    on:
    workflow_call:
    inputs:
    environment:
    description: Environment to deploy
    required: true
    type: string

    jobs:
    deploy:
    name: ${{ inputs.environment }}
    environment: ${{ inputs.environment }}
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4

    - uses: actions/setup-node@v4
    with:
    node-version: 22.14
    cache: npm

    - name: Set up QEMU
    uses: docker/setup-qemu-action@v3
    with:
    platforms: arm64

    - name: Set up Docker Buildx
    uses: docker/setup-buildx-action@v3
    with:
    platforms: linux/arm64

    - name: Setup Environment
    shell: bash
    run: |
    if [ "${{ github.event_name }}" == "pull_request" ]; then
    echo "GIT_HASH=${{ github.event.pull_request.head.sha }}" >> ${GITHUB_ENV}
    else
    echo "GIT_HASH=${GITHUB_SHA}" >> ${GITHUB_ENV}
    fi
    - name: Deploy
    run: npx @nestjs/mau deploy --wait-for-service-stability --dockerfile Dockerfile
    env:
    MAU_KEY: ${{ secrets.MAU_KEY }}
    MAU_SECRET: ${{ secrets.MAU_SECRET }}