fix: eslint and build
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
name: Build & Deploy Mintel.me
|
name: Build & Deploy
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -7,23 +7,17 @@ on:
|
|||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
|
||||||
skip_long_checks:
|
|
||||||
description: 'Skip tests? (true/false)'
|
|
||||||
required: false
|
|
||||||
default: 'false'
|
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ (github.ref_type == 'tag' && !contains(github.ref_name, '-')) && 'prod' || (github.ref_type == 'tag' && 'staging' || 'testing') }}
|
group: ${{ github.workflow }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: false
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# ──────────────────────────────────────────────────────────────────────────────
|
|
||||||
# JOB 1: Prepare & Determine Environment
|
|
||||||
# ──────────────────────────────────────────────────────────────────────────────
|
|
||||||
prepare:
|
prepare:
|
||||||
name: 🔍 Prepare Environment
|
name: 🔍 Prepare Environment
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
outputs:
|
outputs:
|
||||||
target: ${{ steps.determine.outputs.target }}
|
target: ${{ steps.determine.outputs.target }}
|
||||||
image_tag: ${{ steps.determine.outputs.image_tag }}
|
image_tag: ${{ steps.determine.outputs.image_tag }}
|
||||||
@@ -32,106 +26,184 @@ jobs:
|
|||||||
next_public_base_url: ${{ steps.determine.outputs.next_public_base_url }}
|
next_public_base_url: ${{ steps.determine.outputs.next_public_base_url }}
|
||||||
directus_url: ${{ steps.determine.outputs.directus_url }}
|
directus_url: ${{ steps.determine.outputs.directus_url }}
|
||||||
directus_host: ${{ steps.determine.outputs.directus_host }}
|
directus_host: ${{ steps.determine.outputs.directus_host }}
|
||||||
|
gatekeeper_host: ${{ steps.determine.outputs.gatekeeper_host }}
|
||||||
|
traefik_rule: ${{ steps.determine.outputs.traefik_rule }}
|
||||||
|
gatekeeper_rule: ${{ steps.determine.outputs.gatekeeper_rule }}
|
||||||
project_name: ${{ steps.determine.outputs.project_name }}
|
project_name: ${{ steps.determine.outputs.project_name }}
|
||||||
is_prod: ${{ steps.determine.outputs.is_prod }}
|
|
||||||
gotify_title: ${{ steps.determine.outputs.gotify_title }}
|
|
||||||
gotify_priority: ${{ steps.determine.outputs.gotify_priority }}
|
|
||||||
short_sha: ${{ steps.determine.outputs.short_sha }}
|
|
||||||
commit_msg: ${{ steps.determine.outputs.commit_msg }}
|
|
||||||
container:
|
|
||||||
image: catthehacker/ubuntu:act-latest
|
|
||||||
steps:
|
steps:
|
||||||
- name: 🧹 Maintenance (High Density Cleanup)
|
- name: 🔍 Debug Info
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "Purging old build layers and dangling images..."
|
echo "ref_name: ${{ github.ref_name }}"
|
||||||
docker image prune -f
|
echo "ref_type: ${{ github.ref_type }}"
|
||||||
docker builder prune -f --filter "until=6h"
|
echo "tag: ${{ github.ref_name }}"
|
||||||
|
|
||||||
|
- name: 🧹 Maintenance (Runner Cleanup)
|
||||||
|
continue-on-error: true
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
docker image prune -f || true
|
||||||
|
docker builder prune -f --filter "until=24h" || true
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 2
|
||||||
|
|
||||||
- name: 🔍 Environment & Version ermitteln
|
- name: 🔍 Determine Environment
|
||||||
id: determine
|
id: determine
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
TAG="${{ github.ref_name }}"
|
REF="${{ github.ref }}"
|
||||||
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-9)
|
REF_NAME="${{ github.ref_name }}"
|
||||||
IMAGE_TAG="sha-${SHORT_SHA}"
|
REF_TYPE="${{ github.ref_type }}"
|
||||||
COMMIT_MSG=$(git log -1 --pretty=%s || echo "No commit message available")
|
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
|
||||||
|
DOMAIN_BASE="mintel.me"
|
||||||
|
PRJ_ID="mintel-me"
|
||||||
|
|
||||||
if [[ "${{ github.ref_type }}" == "branch" && "$TAG" == "main" ]]; then
|
echo "Detecting environment for ref: $REF ($REF_NAME, type: $REF_TYPE)"
|
||||||
|
|
||||||
|
# Fallback for REF_TYPE if missing
|
||||||
|
if [[ -z "$REF_TYPE" ]]; then
|
||||||
|
if [[ "$REF" == refs/tags/* ]]; then
|
||||||
|
REF_TYPE="tag"
|
||||||
|
elif [[ "$REF" == refs/heads/* ]]; then
|
||||||
|
REF_TYPE="branch"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$REF_TYPE" == "branch" && "$REF_NAME" == "main" ]]; then
|
||||||
TARGET="testing"
|
TARGET="testing"
|
||||||
IMAGE_TAG="main-${SHORT_SHA}"
|
IMAGE_TAG="testing-${SHORT_SHA}"
|
||||||
ENV_FILE=".env.testing"
|
ENV_FILE=".env.testing"
|
||||||
TRAEFIK_HOST='`testing.mintel.me`'
|
TRAEFIK_HOST="testing.${DOMAIN_BASE}"
|
||||||
NEXT_PUBLIC_BASE_URL="https://testing.mintel.me"
|
GATEKEEPER_HOST="gatekeeper.testing.${DOMAIN_BASE}"
|
||||||
DIRECTUS_URL="https://cms.testing.mintel.me"
|
NEXT_PUBLIC_BASE_URL="https://testing.${DOMAIN_BASE}"
|
||||||
DIRECTUS_HOST='`cms.testing.mintel.me`'
|
DIRECTUS_URL="https://cms.testing.${DOMAIN_BASE}"
|
||||||
PROJECT_NAME="mintel-me-testing"
|
DIRECTUS_HOST="cms.testing.${DOMAIN_BASE}"
|
||||||
IS_PROD="false"
|
elif [[ "$REF_TYPE" == "tag" ]]; then
|
||||||
GOTIFY_TITLE="🧪 Testing-Deploy"
|
if [[ "$REF_NAME" =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]; then
|
||||||
GOTIFY_PRIORITY=4
|
|
||||||
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
|
|
||||||
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
||||||
TARGET="production"
|
TARGET="production"
|
||||||
IMAGE_TAG="$TAG"
|
IMAGE_TAG="$REF_NAME"
|
||||||
ENV_FILE=".env.prod"
|
ENV_FILE=".env.prod"
|
||||||
TRAEFIK_HOST='`mintel.me`, `www.mintel.me`'
|
TRAEFIK_HOST="${DOMAIN_BASE}" # Primary domain
|
||||||
NEXT_PUBLIC_BASE_URL="https://mintel.me"
|
GATEKEEPER_HOST="gatekeeper.${DOMAIN_BASE}"
|
||||||
DIRECTUS_URL="https://cms.mintel.me"
|
NEXT_PUBLIC_BASE_URL="https://${DOMAIN_BASE}"
|
||||||
DIRECTUS_HOST='`cms.mintel.me`'
|
DIRECTUS_URL="https://cms.${DOMAIN_BASE}"
|
||||||
PROJECT_NAME="mintel-me-prod"
|
DIRECTUS_HOST="cms.${DOMAIN_BASE}"
|
||||||
IS_PROD="true"
|
elif [[ "$REF_NAME" =~ -rc || "$REF_NAME" =~ -beta || "$REF_NAME" =~ -alpha ]]; then
|
||||||
GOTIFY_TITLE="🚀 Production-Release"
|
|
||||||
GOTIFY_PRIORITY=6
|
|
||||||
elif [[ "$TAG" =~ -rc || "$TAG" =~ -beta || "$TAG" =~ -alpha ]]; then
|
|
||||||
TARGET="staging"
|
TARGET="staging"
|
||||||
IMAGE_TAG="$TAG"
|
IMAGE_TAG="$REF_NAME"
|
||||||
ENV_FILE=".env.staging"
|
ENV_FILE=".env.staging"
|
||||||
TRAEFIK_HOST='`staging.mintel.me`'
|
TRAEFIK_HOST="staging.${DOMAIN_BASE}"
|
||||||
NEXT_PUBLIC_BASE_URL="https://staging.mintel.me"
|
GATEKEEPER_HOST="gatekeeper.staging.${DOMAIN_BASE}"
|
||||||
DIRECTUS_URL="https://cms.staging.mintel.me"
|
NEXT_PUBLIC_BASE_URL="https://staging.${DOMAIN_BASE}"
|
||||||
DIRECTUS_HOST='`cms.staging.mintel.me`'
|
DIRECTUS_URL="https://cms.staging.${DOMAIN_BASE}"
|
||||||
PROJECT_NAME="mintel-me-staging"
|
DIRECTUS_HOST="cms.staging.${DOMAIN_BASE}"
|
||||||
IS_PROD="false"
|
|
||||||
GOTIFY_TITLE="🧪 Staging-Deploy (Pre-Release)"
|
|
||||||
GOTIFY_PRIORITY=5
|
|
||||||
else
|
else
|
||||||
TARGET="skip"
|
TARGET="skip"
|
||||||
GOTIFY_TITLE="❓ Unbekannter Tag"
|
echo "Tag $REF_NAME did not match any environment pattern."
|
||||||
GOTIFY_PRIORITY=3
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
TARGET="skip"
|
TARGET="skip"
|
||||||
|
echo "Ref type $REF_TYPE is not handled for deployment."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
{
|
# Determine Rules based on target (if not skipped)
|
||||||
echo "target=$TARGET"
|
if [[ "$TARGET" != "skip" ]]; then
|
||||||
echo "image_tag=$IMAGE_TAG"
|
if [[ "$TARGET" == "production" ]]; then
|
||||||
echo "env_file=$ENV_FILE"
|
TRAEFIK_RULE="Host(\`${DOMAIN_BASE}\`) || Host(\`www.${DOMAIN_BASE}\`)"
|
||||||
echo "traefik_host=$TRAEFIK_HOST"
|
GATEKEEPER_RULE="(Host(\`${DOMAIN_BASE}\`) || Host(\`www.${DOMAIN_BASE}\`)) && PathPrefix(\`/gatekeeper\`) || Host(\`gatekeeper.${DOMAIN_BASE}\`)"
|
||||||
echo "next_public_base_url=$NEXT_PUBLIC_BASE_URL"
|
else
|
||||||
echo "directus_url=$DIRECTUS_URL"
|
TRAEFIK_RULE="Host(\`${TRAEFIK_HOST}\`)"
|
||||||
echo "directus_host=$DIRECTUS_HOST"
|
GATEKEEPER_RULE="(Host(\`${TRAEFIK_HOST}\`) && PathPrefix(\`/gatekeeper\`)) || Host(\`gatekeeper.${TRAEFIK_HOST}\`)"
|
||||||
echo "project_name=$PROJECT_NAME"
|
fi
|
||||||
echo "is_prod=$IS_PROD"
|
fi
|
||||||
echo "gotify_title=$GOTIFY_TITLE"
|
|
||||||
echo "gotify_priority=$GOTIFY_PRIORITY"
|
echo "Target determined: $TARGET"
|
||||||
echo "short_sha=$SHORT_SHA"
|
echo "Image tag: $IMAGE_TAG"
|
||||||
echo "commit_msg=$COMMIT_MSG"
|
|
||||||
} >> "$GITHUB_OUTPUT"
|
echo "target=$TARGET" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "image_tag=$IMAGE_TAG" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "env_file=$ENV_FILE" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "traefik_host=$TRAEFIK_HOST" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "traefik_rule=$TRAEFIK_RULE" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "gatekeeper_rule=$GATEKEEPER_RULE" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "gatekeeper_host=$GATEKEEPER_HOST" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "next_public_base_url=$NEXT_PUBLIC_BASE_URL" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "directus_url=$DIRECTUS_URL" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "directus_host=$DIRECTUS_HOST" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "project_name=$PRJ_ID-$TARGET" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
# ──────────────────────────────────────────────────────────────────────────────
|
|
||||||
# JOB 2: Quality Assurance (pnpm Lint & Test)
|
|
||||||
# ──────────────────────────────────────────────────────────────────────────────
|
|
||||||
qa:
|
qa:
|
||||||
name: 🧪 Quality Assurance
|
name: 🧪 QA
|
||||||
needs: prepare
|
needs: prepare
|
||||||
if: needs.prepare.outputs.target != 'skip'
|
if: needs.prepare.outputs.target != 'skip'
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20
|
||||||
|
- name: Install dependencies
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
corepack enable
|
||||||
|
pnpm install --frozen-lockfile
|
||||||
|
env:
|
||||||
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
- name: 🧪 Lint
|
||||||
|
shell: bash
|
||||||
|
run: pnpm lint
|
||||||
|
env:
|
||||||
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
- name: 🏗️ Build Test
|
||||||
|
shell: bash
|
||||||
|
run: pnpm build
|
||||||
|
env:
|
||||||
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
NEXT_PUBLIC_BASE_URL: https://dummy.test
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: 🏗️ Build
|
||||||
|
needs: prepare
|
||||||
|
if: needs.prepare.outputs.target != 'skip'
|
||||||
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: 🐳 Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: 🔐 Registry Login
|
||||||
|
run: echo "${{ secrets.REGISTRY_PASS }}" | docker login registry.infra.mintel.me -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
||||||
|
|
||||||
|
- name: 🏗️ Build and Push
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
docker buildx build \
|
||||||
|
--pull \
|
||||||
|
--platform linux/arm64 \
|
||||||
|
--build-arg NPM_TOKEN=${{ secrets.NPM_TOKEN }} \
|
||||||
|
--build-arg NEXT_PUBLIC_BASE_URL=${{ needs.prepare.outputs.next_public_base_url }} \
|
||||||
|
--build-arg NEXT_PUBLIC_TARGET=${{ needs.prepare.outputs.target }} \
|
||||||
|
--build-arg DIRECTUS_URL=${{ needs.prepare.outputs.directus_url }} \
|
||||||
|
--build-arg UMAMI_API_ENDPOINT=${{ secrets.UMAMI_API_ENDPOINT || secrets.NEXT_PUBLIC_UMAMI_SCRIPT_URL || vars.UMAMI_API_ENDPOINT || 'https://analytics.infra.mintel.me' }} \
|
||||||
|
-t registry.infra.mintel.me/mintel/mintel.me:${{ needs.prepare.outputs.image_tag }} \
|
||||||
|
--push .
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
name: 🚀 Deploy
|
||||||
|
needs: [prepare, build, qa]
|
||||||
|
if: needs.prepare.outputs.target != 'skip'
|
||||||
|
runs-on: docker
|
||||||
container:
|
container:
|
||||||
image: catthehacker/ubuntu:act-latest
|
image: catthehacker/ubuntu:act-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -140,235 +212,127 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
- name: Setup pnpm
|
|
||||||
uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: 10
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: pnpm install --frozen-lockfile
|
|
||||||
env:
|
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
||||||
|
|
||||||
- name: 🧪 Run Checks in Parallel
|
|
||||||
if: github.event.inputs.skip_long_checks != 'true'
|
|
||||||
run: |
|
|
||||||
pnpm lint &
|
|
||||||
LINT_PID=$!
|
|
||||||
pnpm --filter @mintel/web typecheck &
|
|
||||||
TYPE_PID=$!
|
|
||||||
# pnpm test &
|
|
||||||
# TEST_PID=$!
|
|
||||||
|
|
||||||
wait $LINT_PID || exit 1
|
|
||||||
wait $TYPE_PID || exit 1
|
|
||||||
# wait $TEST_PID || exit 1
|
|
||||||
|
|
||||||
# ──────────────────────────────────────────────────────────────────────────────
|
|
||||||
# JOB 3: Build & Push Docker Image
|
|
||||||
# ──────────────────────────────────────────────────────────────────────────────
|
|
||||||
build:
|
|
||||||
name: 🏗️ Build App
|
|
||||||
needs: prepare
|
|
||||||
if: ${{ needs.prepare.outputs.target != 'skip' }}
|
|
||||||
runs-on: docker
|
|
||||||
container:
|
|
||||||
image: catthehacker/ubuntu:act-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 1
|
|
||||||
|
|
||||||
- name: 🐳 Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: 🔐 Registry Login
|
|
||||||
run: |
|
|
||||||
echo "${{ secrets.REGISTRY_PASS }}" | docker login registry.infra.mintel.me -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
|
||||||
|
|
||||||
- name: 🏗️ App bauen & pushen
|
|
||||||
env:
|
|
||||||
IMAGE_TAG: ${{ needs.prepare.outputs.image_tag }}
|
|
||||||
TARGET: ${{ needs.prepare.outputs.target }}
|
|
||||||
NEXT_PUBLIC_BASE_URL: ${{ needs.prepare.outputs.next_public_base_url }}
|
|
||||||
DIRECTUS_URL: ${{ needs.prepare.outputs.directus_url }}
|
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
||||||
run: |
|
|
||||||
docker buildx build \
|
|
||||||
--pull \
|
|
||||||
--platform linux/arm64 \
|
|
||||||
--build-arg NEXT_PUBLIC_BASE_URL="$NEXT_PUBLIC_BASE_URL" \
|
|
||||||
--build-arg NEXT_PUBLIC_TARGET="$TARGET" \
|
|
||||||
--build-arg DIRECTUS_URL="$DIRECTUS_URL" \
|
|
||||||
--secret id=NPM_TOKEN,env=NPM_TOKEN \
|
|
||||||
-t registry.infra.mintel.me/mintel/mintel.me:$IMAGE_TAG \
|
|
||||||
--cache-from type=registry,ref=registry.infra.mintel.me/mintel/mintel.me:buildcache \
|
|
||||||
--cache-to type=registry,ref=registry.infra.mintel.me/mintel/mintel.me:buildcache,mode=max \
|
|
||||||
--push .
|
|
||||||
|
|
||||||
# ──────────────────────────────────────────────────────────────────────────────
|
|
||||||
# JOB 4: Deploy via SSH
|
|
||||||
# ──────────────────────────────────────────────────────────────────────────────
|
|
||||||
deploy:
|
|
||||||
name: 🚀 Deploy
|
|
||||||
needs: [prepare, build, qa]
|
|
||||||
if: ${{ needs.prepare.outputs.target != 'skip' }}
|
|
||||||
runs-on: docker
|
|
||||||
container:
|
|
||||||
image: catthehacker/ubuntu:act-latest
|
|
||||||
env:
|
|
||||||
TARGET: ${{ needs.prepare.outputs.target }}
|
|
||||||
IMAGE_TAG: ${{ needs.prepare.outputs.image_tag }}
|
|
||||||
ENV_FILE: ${{ needs.prepare.outputs.env_file }}
|
|
||||||
PROJECT_NAME: ${{ needs.prepare.outputs.project_name }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 1
|
|
||||||
|
|
||||||
- name: 🚀 Deploy via SSH
|
- name: 🚀 Deploy via SSH
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
echo "Deploying to alpha.mintel.me"
|
||||||
|
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.ALPHA_SSH_KEY }}" > ~/.ssh/id_ed25519
|
echo "${{ secrets.ALPHA_SSH_KEY }}" > ~/.ssh/id_ed25519
|
||||||
chmod 600 ~/.ssh/id_ed25519
|
chmod 600 ~/.ssh/id_ed25519
|
||||||
ssh-keyscan -H alpha.mintel.me >> ~/.ssh/known_hosts 2>/dev/null
|
ssh-keyscan -H alpha.mintel.me >> ~/.ssh/known_hosts 2>/dev/null
|
||||||
|
|
||||||
# Create .env on the fly
|
# Generate Environment File
|
||||||
cat > /tmp/mintel.me.env << EOF
|
cat > .env.deploy << 'EOF'
|
||||||
# Generated by CI - $TARGET - $(date -u)
|
ENV_FILE=${{ needs.prepare.outputs.env_file }}
|
||||||
|
IMAGE_TAG=${{ needs.prepare.outputs.image_tag }}
|
||||||
|
TRAEFIK_HOST=${{ needs.prepare.outputs.traefik_host }}
|
||||||
|
TRAEFIK_RULE=${{ needs.prepare.outputs.traefik_rule }}
|
||||||
|
GATEKEEPER_RULE=${{ needs.prepare.outputs.gatekeeper_rule }}
|
||||||
|
GATEKEEPER_HOST=${{ needs.prepare.outputs.gatekeeper_host }}
|
||||||
|
PROJECT_NAME=${{ needs.prepare.outputs.project_name }}
|
||||||
NEXT_PUBLIC_BASE_URL=${{ needs.prepare.outputs.next_public_base_url }}
|
NEXT_PUBLIC_BASE_URL=${{ needs.prepare.outputs.next_public_base_url }}
|
||||||
NEXT_PUBLIC_TARGET=$TARGET
|
|
||||||
|
# Directus
|
||||||
DIRECTUS_URL=${{ needs.prepare.outputs.directus_url }}
|
DIRECTUS_URL=${{ needs.prepare.outputs.directus_url }}
|
||||||
DIRECTUS_HOST=${{ needs.prepare.outputs.directus_host }}
|
DIRECTUS_HOST=${{ needs.prepare.outputs.directus_host }}
|
||||||
TRAEFIK_HOST=${{ needs.prepare.outputs.traefik_host }}
|
INTERNAL_DIRECTUS_URL=http://directus:8055
|
||||||
IMAGE_TAG=$IMAGE_TAG
|
DIRECTUS_API_TOKEN=${{ secrets.DIRECTUS_API_TOKEN || vars.DIRECTUS_API_TOKEN }}
|
||||||
PROJECT_NAME=$PROJECT_NAME
|
DIRECTUS_ADMIN_EMAIL=${{ secrets.DIRECTUS_ADMIN_EMAIL || vars.DIRECTUS_ADMIN_EMAIL || 'admin@mintel.me' }}
|
||||||
AUTH_MIDDLEWARE=$( [[ "$TARGET" == "production" ]] && echo "compress" || echo "${PROJECT_NAME}-auth,compress" )
|
DIRECTUS_ADMIN_PASSWORD=${{ secrets.DIRECTUS_ADMIN_PASSWORD || vars.DIRECTUS_ADMIN_PASSWORD }}
|
||||||
|
DIRECTUS_DB_NAME=${{ secrets.DIRECTUS_DB_NAME || vars.DIRECTUS_DB_NAME || 'directus' }}
|
||||||
|
DIRECTUS_DB_USER=${{ secrets.DIRECTUS_DB_USER || vars.DIRECTUS_DB_USER || 'directus' }}
|
||||||
|
DIRECTUS_DB_PASSWORD=${{ secrets.DIRECTUS_DB_PASSWORD || vars.DIRECTUS_DB_PASSWORD }}
|
||||||
|
DIRECTUS_KEY=${{ secrets.DIRECTUS_KEY || vars.DIRECTUS_KEY }}
|
||||||
|
DIRECTUS_SECRET=${{ secrets.DIRECTUS_SECRET || vars.DIRECTUS_SECRET }}
|
||||||
|
|
||||||
# Secrets
|
# SMTP Config
|
||||||
DIRECTUS_KEY=${{ secrets.DIRECTUS_KEY }}
|
SMTP_HOST=${{ secrets.SMTP_HOST || vars.SMTP_HOST }}
|
||||||
DIRECTUS_SECRET=${{ secrets.DIRECTUS_SECRET }}
|
SMTP_PORT=${{ secrets.SMTP_PORT || vars.SMTP_PORT || '587' }}
|
||||||
DIRECTUS_DB_NAME=${{ secrets.DIRECTUS_DB_NAME || 'directus' }}
|
SMTP_SECURE=${{ secrets.SMTP_SECURE || vars.SMTP_SECURE || 'false' }}
|
||||||
DIRECTUS_DB_USER=${{ secrets.DIRECTUS_DB_USER || 'directus' }}
|
SMTP_USER=${{ secrets.SMTP_USER || vars.SMTP_USER }}
|
||||||
DIRECTUS_DB_PASSWORD=${{ secrets.DIRECTUS_DB_PASSWORD }}
|
SMTP_PASS=${{ secrets.SMTP_PASS || vars.SMTP_PASS }}
|
||||||
|
SMTP_FROM=${{ secrets.SMTP_FROM || vars.SMTP_FROM }}
|
||||||
|
CONTACT_RECIPIENT=${{ secrets.CONTACT_RECIPIENT || vars.CONTACT_RECIPIENT }}
|
||||||
|
|
||||||
# General
|
# Authentication
|
||||||
NODE_ENV=production
|
GATEKEEPER_PASSWORD=${{ secrets.GATEKEEPER_PASSWORD || vars.GATEKEEPER_PASSWORD }}
|
||||||
|
AUTH_COOKIE_NAME=${{ secrets.AUTH_COOKIE_NAME || vars.AUTH_COOKIE_NAME || 'mintel_gatekeeper_session' }}
|
||||||
|
COOKIE_DOMAIN=${{ secrets.COOKIE_DOMAIN || vars.COOKIE_DOMAIN || '.mintel.me' }}
|
||||||
|
AUTH_MIDDLEWARE=$( [[ "${{ needs.prepare.outputs.target }}" == "production" ]] && echo "compress" || echo "${{ needs.prepare.outputs.project_name }}-auth,compress" )
|
||||||
|
|
||||||
|
# External Services
|
||||||
|
SENTRY_DSN=${{ secrets.SENTRY_DSN || vars.SENTRY_DSN }}
|
||||||
|
GOTIFY_URL=${{ secrets.GOTIFY_URL || vars.GOTIFY_URL }}
|
||||||
|
GOTIFY_TOKEN=${{ secrets.GOTIFY_TOKEN || vars.GOTIFY_TOKEN }}
|
||||||
|
UMAMI_WEBSITE_ID=${{ secrets.UMAMI_WEBSITE_ID || secrets.NEXT_PUBLIC_UMAMI_WEBSITE_ID || vars.UMAMI_WEBSITE_ID || vars.NEXT_PUBLIC_UMAMI_WEBSITE_ID }}
|
||||||
|
UMAMI_API_ENDPOINT=${{ secrets.UMAMI_API_ENDPOINT || secrets.NEXT_PUBLIC_UMAMI_SCRIPT_URL || vars.UMAMI_API_ENDPOINT || 'https://analytics.infra.mintel.me' }}
|
||||||
|
|
||||||
|
# Project
|
||||||
|
PROJECT_COLOR=${{ secrets.PROJECT_COLOR || vars.PROJECT_COLOR || '#ff00ff' }}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# 1. Cleanup and Create Directories on server BEFORE SCP
|
APP_DIR="/home/deploy/sites/mintel.me"
|
||||||
|
ssh -o StrictHostKeyChecking=accept-new root@alpha.mintel.me "mkdir -p $APP_DIR"
|
||||||
|
|
||||||
|
scp -o StrictHostKeyChecking=accept-new .env.deploy root@alpha.mintel.me:$APP_DIR/${{ needs.prepare.outputs.env_file }}
|
||||||
|
scp -o StrictHostKeyChecking=accept-new docker-compose.yaml root@alpha.mintel.me:$APP_DIR/docker-compose.yaml
|
||||||
|
|
||||||
ssh -o StrictHostKeyChecking=accept-new root@alpha.mintel.me bash << 'EOF'
|
ssh -o StrictHostKeyChecking=accept-new root@alpha.mintel.me bash << 'EOF'
|
||||||
set -e
|
set -e
|
||||||
mkdir -p /home/deploy/sites/mintel.me/varnish
|
APP_DIR="/home/deploy/sites/mintel.me"
|
||||||
mkdir -p /home/deploy/sites/mintel.me/directus/uploads /home/deploy/sites/mintel.me/directus/extensions
|
cd $APP_DIR
|
||||||
if [ -d "/home/deploy/sites/mintel.me/varnish/default.vcl" ]; then
|
|
||||||
echo "🧹 Removing directory 'varnish/default.vcl' created by Docker..."
|
|
||||||
rm -rf /home/deploy/sites/mintel.me/varnish/default.vcl
|
|
||||||
fi
|
|
||||||
chown -R deploy:deploy /home/deploy/sites/mintel.me/directus /home/deploy/sites/mintel.me/varnish
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# 2. Transfer files
|
|
||||||
scp /tmp/mintel.me.env root@alpha.mintel.me:/home/deploy/sites/mintel.me/$ENV_FILE
|
|
||||||
scp docker-compose.yml root@alpha.mintel.me:/home/deploy/sites/mintel.me/docker-compose.yml
|
|
||||||
scp -r varnish root@alpha.mintel.me:/home/deploy/sites/mintel.me/
|
|
||||||
|
|
||||||
ssh root@alpha.mintel.me IMAGE_TAG="$IMAGE_TAG" ENV_FILE="$ENV_FILE" PROJECT_NAME="$PROJECT_NAME" bash << 'EOF'
|
|
||||||
set -e
|
|
||||||
cd /home/deploy/sites/mintel.me
|
|
||||||
echo "${{ secrets.REGISTRY_PASS }}" | docker login registry.infra.mintel.me -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
echo "${{ secrets.REGISTRY_PASS }}" | docker login registry.infra.mintel.me -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
||||||
docker compose -p "$PROJECT_NAME" --env-file "$ENV_FILE" pull
|
docker compose -p "${{ needs.prepare.outputs.project_name }}" --env-file ${{ needs.prepare.outputs.env_file }} pull
|
||||||
docker compose -p "$PROJECT_NAME" --env-file "$ENV_FILE" up -d --remove-orphans
|
docker compose -p "${{ needs.prepare.outputs.project_name }}" --env-file ${{ needs.prepare.outputs.env_file }} up -d --remove-orphans
|
||||||
docker system prune -f --filter "until=24h"
|
docker system prune -f --filter "until=24h"
|
||||||
echo "→ Waiting 15s for warmup..."
|
|
||||||
sleep 15
|
|
||||||
docker compose -p "$PROJECT_NAME" --env-file "$ENV_FILE" ps
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# ──────────────────────────────────────────────────────────────────────────────
|
|
||||||
# JOB 5: PageSpeed Test
|
|
||||||
# ──────────────────────────────────────────────────────────────────────────────
|
|
||||||
pagespeed:
|
pagespeed:
|
||||||
name: ⚡ PageSpeed
|
name: ⚡ PageSpeed
|
||||||
needs: [prepare, deploy]
|
needs: [prepare, deploy]
|
||||||
if: |
|
if: |
|
||||||
always() &&
|
always() &&
|
||||||
needs.prepare.outputs.target != 'skip' &&
|
needs.prepare.outputs.target != 'skip' &&
|
||||||
needs.deploy.result == 'success' &&
|
needs.deploy.result == 'success'
|
||||||
github.event.inputs.skip_long_checks != 'true'
|
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
container:
|
container:
|
||||||
image: catthehacker/ubuntu:act-latest
|
image: catthehacker/ubuntu:act-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
fetch-depth: 1
|
|
||||||
|
|
||||||
- name: Setup pnpm
|
|
||||||
uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: 10
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 20
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --frozen-lockfile
|
run: |
|
||||||
|
corepack enable
|
||||||
|
pnpm install --frozen-lockfile
|
||||||
env:
|
env:
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
- name: 🧪 Run PageSpeed (Lighthouse CI)
|
||||||
- name: 🔍 Install Chromium (ARM64)
|
|
||||||
run: |
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y gnupg wget ca-certificates
|
|
||||||
CODENAME=$(. /etc/os-release && echo $VERSION_CODENAME)
|
|
||||||
|
|
||||||
mkdir -p /etc/apt/keyrings
|
|
||||||
KEY_ID="82BB6851C64F6880"
|
|
||||||
wget -qO- "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x$KEY_ID" | gpg --dearmor > /etc/apt/keyrings/xtradeb.gpg
|
|
||||||
echo "deb [signed-by=/etc/apt/keyrings/xtradeb.gpg] http://ppa.launchpad.net/xtradeb/apps/ubuntu $CODENAME main" > /etc/apt/sources.list.d/xtradeb-ppa.list
|
|
||||||
printf "Package: *\nPin: release o=LP-PPA-xtradeb-apps\nPin-Priority: 1001\n" > /etc/apt/preferences.d/xtradeb
|
|
||||||
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y --allow-downgrades chromium
|
|
||||||
[ -f /usr/bin/chromium ] && ln -sf /usr/bin/chromium /usr/bin/google-chrome
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: 🧪 Run PageSpeed (Lighthouse)
|
|
||||||
env:
|
env:
|
||||||
NEXT_PUBLIC_BASE_URL: ${{ needs.prepare.outputs.next_public_base_url }}
|
NEXT_PUBLIC_BASE_URL: ${{ needs.prepare.outputs.next_public_base_url }}
|
||||||
GATEKEEPER_PASSWORD: ${{ secrets.GATEKEEPER_PASSWORD || 'klz2026' }}
|
GATEKEEPER_PASSWORD: ${{ secrets.GATEKEEPER_PASSWORD }}
|
||||||
PAGESPEED_LIMIT: 8
|
run: pnpm --filter @mintel/web pagespeed:test
|
||||||
CHROME_PATH: /usr/bin/chromium
|
|
||||||
run: pnpm --filter @mintel/web run pagespeed:test
|
|
||||||
|
|
||||||
# ──────────────────────────────────────────────────────────────────────────────
|
|
||||||
# JOB 6: Notifications
|
|
||||||
# ──────────────────────────────────────────────────────────────────────────────
|
|
||||||
notifications:
|
notifications:
|
||||||
name: 🔔 Notifications
|
name: 🔔 Notifications
|
||||||
needs: [prepare, qa, build, deploy, pagespeed]
|
needs: [prepare, deploy]
|
||||||
if: always()
|
if: always()
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
container:
|
container:
|
||||||
image: catthehacker/ubuntu:act-latest
|
image: catthehacker/ubuntu:act-latest
|
||||||
steps:
|
steps:
|
||||||
- name: 🔔 Gotify
|
- name: Notify Gotify
|
||||||
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
STATUS="${{ needs.deploy.result == 'success' && '✅' || '❌' }}"
|
STATUS="${{ needs.deploy.result }}"
|
||||||
PRIORITY="${{ needs.deploy.result == 'success' && needs.prepare.outputs.gotify_priority || '8' }}"
|
[[ "$STATUS" == "success" ]] && PRIORITY=5 || PRIORITY=8
|
||||||
curl -s -k -X POST "${{ secrets.GOTIFY_URL }}/message?token=${{ secrets.GOTIFY_TOKEN }}" \
|
|
||||||
-F "title=$STATUS ${{ needs.prepare.outputs.gotify_title }}" \
|
curl -X POST "${{ secrets.GOTIFY_URL }}/message?token=${{ secrets.GOTIFY_TOKEN }}" \
|
||||||
-F "message=Deploy to **${{ needs.prepare.outputs.target }}** ${{ needs.deploy.result }}.\n\nVersion: **${{ needs.prepare.outputs.image_tag }}**\nCommit: ${{ needs.prepare.outputs.short_sha }} (${{ needs.prepare.outputs.commit_msg }})\nActor: ${{ github.actor }}" \
|
-F "title=mintel.me Deployment" \
|
||||||
-F "priority=$PRIORITY" || true
|
-F "message=Status: $STATUS for ${{ needs.prepare.outputs.target }} (${{ needs.prepare.outputs.image_tag }})" \
|
||||||
|
-F "priority=$PRIORITY"
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
npx lint-staged
|
pnpm exec lint-staged
|
||||||
|
|||||||
77
Dockerfile
77
Dockerfile
@@ -1,69 +1,48 @@
|
|||||||
FROM node:20-alpine AS base
|
# Start from the pre-built Nextjs Base image
|
||||||
RUN corepack enable pnpm
|
FROM registry.infra.mintel.me/mintel/nextjs:latest AS builder
|
||||||
|
|
||||||
# Install dependencies only when needed
|
|
||||||
FROM base AS deps
|
|
||||||
RUN apk add --no-cache libc6-compat curl
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Build-time environment variables for Next.js
|
||||||
|
ARG NEXT_PUBLIC_BASE_URL
|
||||||
|
ARG UMAMI_API_ENDPOINT
|
||||||
|
ARG NEXT_PUBLIC_TARGET
|
||||||
|
ARG DIRECTUS_URL
|
||||||
|
ARG NPM_TOKEN
|
||||||
|
|
||||||
|
ENV NEXT_PUBLIC_BASE_URL=$NEXT_PUBLIC_BASE_URL
|
||||||
|
ENV UMAMI_API_ENDPOINT=$UMAMI_API_ENDPOINT
|
||||||
|
ENV NEXT_PUBLIC_TARGET=$NEXT_PUBLIC_TARGET
|
||||||
|
ENV DIRECTUS_URL=$DIRECTUS_URL
|
||||||
|
ENV NPM_TOKEN=$NPM_TOKEN
|
||||||
|
ENV SENTRY_SUPPRESS_TURBOPACK_WARNING=1
|
||||||
|
|
||||||
|
# Enable pnpm
|
||||||
|
RUN corepack enable
|
||||||
|
|
||||||
|
# Copy workspace configuration
|
||||||
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json .npmrc ./
|
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json .npmrc ./
|
||||||
COPY apps/web/package.json ./apps/web/package.json
|
COPY apps/web/package.json ./apps/web/package.json
|
||||||
|
|
||||||
# If there are local packages, copy them here
|
# Install dependencies (use cache mount if possible, but keep it simple as per standard)
|
||||||
# COPY packages/ ./packages/
|
RUN pnpm install --no-frozen-lockfile
|
||||||
|
|
||||||
RUN --mount=type=cache,target=/root/.local/share/pnpm/store/v3 \
|
# Copy source
|
||||||
--mount=type=secret,id=NPM_TOKEN \
|
|
||||||
export NPM_TOKEN=$(cat /run/secrets/NPM_TOKEN) && \
|
|
||||||
pnpm install --frozen-lockfile
|
|
||||||
|
|
||||||
# Rebuild the source code only when needed
|
|
||||||
FROM base AS builder
|
|
||||||
WORKDIR /app
|
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
|
||||||
COPY --from=deps /app/apps/web/node_modules ./apps/web/node_modules
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build-time environment variables
|
# Build the app
|
||||||
ARG NEXT_PUBLIC_BASE_URL
|
|
||||||
ARG NEXT_PUBLIC_TARGET
|
|
||||||
ARG DIRECTUS_URL
|
|
||||||
|
|
||||||
ENV NEXT_PUBLIC_BASE_URL=$NEXT_PUBLIC_BASE_URL
|
|
||||||
ENV NEXT_PUBLIC_TARGET=$NEXT_PUBLIC_TARGET
|
|
||||||
ENV DIRECTUS_URL=$DIRECTUS_URL
|
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
|
||||||
|
|
||||||
RUN pnpm --filter @mintel/web build
|
RUN pnpm --filter @mintel/web build
|
||||||
|
|
||||||
# Production image, copy all the files and run next
|
# Production image
|
||||||
FROM base AS runner
|
FROM registry.infra.mintel.me/mintel/runtime:latest AS runner
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN apk add --no-cache curl
|
# Copy standalone output and static files (Monorepo paths)
|
||||||
|
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public
|
||||||
ENV NODE_ENV=production
|
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
|
||||||
|
|
||||||
RUN addgroup --system --gid 1001 nodejs
|
|
||||||
RUN adduser --system --uid 1001 nextjs
|
|
||||||
|
|
||||||
COPY --from=builder /app/apps/web/public ./apps/web/public
|
|
||||||
|
|
||||||
# Set the correct permission for prerender cache
|
|
||||||
RUN mkdir -p apps/web/.next
|
|
||||||
RUN chown nextjs:nodejs apps/web/.next
|
|
||||||
|
|
||||||
# Automatically leverage output traces to reduce image size
|
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
|
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
|
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
|
||||||
|
|
||||||
USER nextjs
|
USER nextjs
|
||||||
|
|
||||||
EXPOSE 3000
|
|
||||||
|
|
||||||
ENV PORT=3000
|
|
||||||
ENV HOSTNAME="0.0.0.0"
|
|
||||||
|
|
||||||
WORKDIR /app/apps/web
|
WORKDIR /app/apps/web
|
||||||
CMD ["node", "server.js"]
|
CMD ["node", "server.js"]
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ import React from 'react';
|
|||||||
import { technologies } from './data';
|
import { technologies } from './data';
|
||||||
import TechnologyContent from './content';
|
import TechnologyContent from './content';
|
||||||
|
|
||||||
export default function TechnologyPage({ params }: { params: { slug: string } }) {
|
export default async function TechnologyPage({ params }: { params: Promise<{ slug: string }> }) {
|
||||||
return <TechnologyContent slug={params.slug} />;
|
const { slug } = await params;
|
||||||
|
return <TechnologyContent slug={slug} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate static params for these dynamic routes
|
// Generate static params for these dynamic routes
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import mintelConfig from "@mintel/eslint-config/next";
|
import { nextConfig } from "@mintel/eslint-config/next";
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
...mintelConfig,
|
...nextConfig,
|
||||||
{
|
{
|
||||||
rules: {
|
rules: {
|
||||||
"no-console": "warn",
|
"no-console": "warn",
|
||||||
|
|||||||
@@ -1,7 +1,30 @@
|
|||||||
|
import withMintelConfig from "@mintel/next-config";
|
||||||
|
|
||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
output: 'standalone',
|
output: 'standalone',
|
||||||
|
async rewrites() {
|
||||||
|
const umamiUrl =
|
||||||
|
process.env.UMAMI_API_ENDPOINT ||
|
||||||
|
process.env.UMAMI_SCRIPT_URL ||
|
||||||
|
process.env.NEXT_PUBLIC_UMAMI_SCRIPT_URL ||
|
||||||
|
"https://analytics.infra.mintel.me";
|
||||||
|
const glitchtipUrl = process.env.SENTRY_DSN
|
||||||
|
? new URL(process.env.SENTRY_DSN).origin
|
||||||
|
: "https://errors.infra.mintel.me";
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
source: "/stats/:path*",
|
||||||
|
destination: `${umamiUrl}/:path*`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
source: "/errors/:path*",
|
||||||
|
destination: `${glitchtipUrl}/:path*`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
export default withMintelConfig(nextConfig);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "next lint",
|
"lint": "eslint .",
|
||||||
"test": "npm run test:links",
|
"test": "npm run test:links",
|
||||||
"test:links": "tsx ./scripts/test-links.ts",
|
"test:links": "tsx ./scripts/test-links.ts",
|
||||||
"test:file-examples": "tsx ./scripts/test-file-examples-comprehensive.ts",
|
"test:file-examples": "tsx ./scripts/test-file-examples-comprehensive.ts",
|
||||||
@@ -20,11 +20,19 @@
|
|||||||
"video:render:contact": "remotion render video/index.ts ContactFormShowcase out/contact-showcase.mp4 --concurrency=1 --codec=h264 --crf=16 --pixel-format=yuv420p --overwrite",
|
"video:render:contact": "remotion render video/index.ts ContactFormShowcase out/contact-showcase.mp4 --concurrency=1 --codec=h264 --crf=16 --pixel-format=yuv420p --overwrite",
|
||||||
"video:render:button": "remotion render video/index.ts ButtonShowcase out/button-showcase.mp4 --concurrency=1 --codec=h264 --crf=16 --pixel-format=yuv420p --overwrite",
|
"video:render:button": "remotion render video/index.ts ButtonShowcase out/button-showcase.mp4 --concurrency=1 --codec=h264 --crf=16 --pixel-format=yuv420p --overwrite",
|
||||||
"video:render:all": "npm run video:render:contact && npm run video:render:button",
|
"video:render:all": "npm run video:render:contact && npm run video:render:button",
|
||||||
"pagespeed:test": "tsx ./scripts/pagespeed-sitemap.ts",
|
"pagespeed:test": "mintel pagespeed test",
|
||||||
|
"cms:bootstrap": "DIRECTUS_URL=http://localhost:8055 npx tsx --env-file=.env scripts/setup-directus.ts",
|
||||||
|
"cms:push:staging": "../../scripts/sync-directus.sh push staging",
|
||||||
|
"cms:pull:staging": "../../scripts/sync-directus.sh pull staging",
|
||||||
|
"cms:push:testing": "../../scripts/sync-directus.sh push testing",
|
||||||
|
"cms:pull:testing": "../../scripts/sync-directus.sh pull testing",
|
||||||
|
"cms:push:prod": "../../scripts/sync-directus.sh push production",
|
||||||
|
"cms:pull:prod": "../../scripts/sync-directus.sh pull production",
|
||||||
"typecheck": "tsc --noEmit"
|
"typecheck": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mintel/next-utils": "^1.0.1",
|
"@mintel/next-utils": "^1.1.13",
|
||||||
|
"@sentry/nextjs": "^10.38.0",
|
||||||
"@react-pdf/renderer": "^4.3.2",
|
"@react-pdf/renderer": "^4.3.2",
|
||||||
"@remotion/bundler": "^4.0.414",
|
"@remotion/bundler": "^4.0.414",
|
||||||
"@remotion/cli": "^4.0.414",
|
"@remotion/cli": "^4.0.414",
|
||||||
@@ -60,8 +68,9 @@
|
|||||||
"zod": "3.22.3"
|
"zod": "3.22.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@mintel/eslint-config": "^1.0.1",
|
"@mintel/cli": "^1.1.13",
|
||||||
"@mintel/tsconfig": "^1.0.1",
|
"@mintel/eslint-config": "^1.1.13",
|
||||||
|
"@mintel/tsconfig": "^1.1.13",
|
||||||
"@tailwindcss/typography": "^0.5.15",
|
"@tailwindcss/typography": "^0.5.15",
|
||||||
"@types/node": "^25.0.6",
|
"@types/node": "^25.0.6",
|
||||||
"@types/prismjs": "^1.26.5",
|
"@types/prismjs": "^1.26.5",
|
||||||
|
|||||||
73
apps/web/scripts/setup-directus.ts
Normal file
73
apps/web/scripts/setup-directus.ts
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
import {
|
||||||
|
createMintelDirectusClient,
|
||||||
|
ensureDirectusAuthenticated,
|
||||||
|
} from "@mintel/next-utils";
|
||||||
|
import { updateSettings } from "@directus/sdk";
|
||||||
|
|
||||||
|
const client = createMintelDirectusClient();
|
||||||
|
|
||||||
|
async function setupBranding() {
|
||||||
|
const prjName = process.env.PROJECT_NAME || "Mintel.me";
|
||||||
|
const prjColor = process.env.PROJECT_COLOR || "#ff00ff";
|
||||||
|
|
||||||
|
console.log(`🎨 Refining Directus Branding for ${prjName}...`);
|
||||||
|
await ensureDirectusAuthenticated(client);
|
||||||
|
|
||||||
|
const cssInjection = `
|
||||||
|
<style>
|
||||||
|
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap');
|
||||||
|
|
||||||
|
body, .v-app { font-family: 'Outfit', sans-serif !important; }
|
||||||
|
|
||||||
|
.public-view .v-card {
|
||||||
|
backdrop-filter: blur(20px);
|
||||||
|
background: rgba(255, 255, 255, 0.9) !important;
|
||||||
|
border-radius: 32px !important;
|
||||||
|
box-shadow: 0 50px 100px -20px rgba(0, 0, 0, 0.4) !important;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.3) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-navigation-drawer { background: #000c24 !important; }
|
||||||
|
|
||||||
|
.v-list-item--active {
|
||||||
|
color: ${prjColor} !important;
|
||||||
|
background: rgba(255, 0, 255, 0.1) !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div style="font-family: 'Outfit', sans-serif; text-align: center; margin-top: 24px;">
|
||||||
|
<p style="color: rgba(255,255,255,0.6); font-size: 11px; letter-spacing: 2px; margin-bottom: 4px; font-weight: 600; text-transform: uppercase;">Mintel Infrastructure Engine</p>
|
||||||
|
<h1 style="color: #ffffff; font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -0.5px;">${prjName.toUpperCase()} <span style="color: ${prjColor};">SYNC.</span></h1>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await client.request(
|
||||||
|
updateSettings({
|
||||||
|
project_name: prjName,
|
||||||
|
project_color: prjColor,
|
||||||
|
public_note: cssInjection,
|
||||||
|
module_bar_background: "#00081a",
|
||||||
|
theme_light_overrides: {
|
||||||
|
primary: prjColor,
|
||||||
|
borderRadius: "12px",
|
||||||
|
navigationBackground: "#000c24",
|
||||||
|
navigationForeground: "#ffffff",
|
||||||
|
moduleBarBackground: "#00081a",
|
||||||
|
},
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
} as any),
|
||||||
|
);
|
||||||
|
console.log("✨ Branding applied!");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("❌ Error during bootstrap:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setupBranding()
|
||||||
|
.then(() => {
|
||||||
|
process.exit(0);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error("🚨 Fatal bootstrap error:", err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
@@ -8,15 +8,11 @@ import { ConceptPrice, ConceptAutomation } from '../../Landing/ConceptIllustrati
|
|||||||
import { Info, Download, Share2, RefreshCw } from 'lucide-react';
|
import { Info, Download, Share2, RefreshCw } from 'lucide-react';
|
||||||
import { motion, AnimatePresence } from 'framer-motion';
|
import { motion, AnimatePresence } from 'framer-motion';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import { EstimationPDF } from '../../EstimationPDF';
|
// EstimationPDF will be imported dynamically where used or inside the and client-side block
|
||||||
import IconWhite from '../../../assets/logo/Icon White Transparent.png';
|
import IconWhite from '../../../assets/logo/Icon White Transparent.png';
|
||||||
import LogoBlack from '../../../assets/logo/Logo Black Transparent.png';
|
import LogoBlack from '../../../assets/logo/Logo Black Transparent.png';
|
||||||
|
|
||||||
// Dynamically import PDF components to avoid SSR issues
|
// PDF components removed from top-level dynamic import to fix ESM resolution issues in Next.js 16/Webpack
|
||||||
const PDFDownloadLink = dynamic(
|
|
||||||
() => import('@react-pdf/renderer').then((mod) => mod.PDFDownloadLink),
|
|
||||||
{ ssr: false }
|
|
||||||
);
|
|
||||||
|
|
||||||
interface PriceCalculationProps {
|
interface PriceCalculationProps {
|
||||||
state: FormState;
|
state: FormState;
|
||||||
@@ -44,8 +40,7 @@ export function PriceCalculation({
|
|||||||
setPdfLoading(true);
|
setPdfLoading(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { pdf } = await import('@react-pdf/renderer');
|
const { EstimationPDF } = await import('../../EstimationPDF');
|
||||||
|
|
||||||
const doc = <EstimationPDF
|
const doc = <EstimationPDF
|
||||||
state={state}
|
state={state}
|
||||||
totalPrice={totalPrice}
|
totalPrice={totalPrice}
|
||||||
@@ -56,6 +51,8 @@ export function PriceCalculation({
|
|||||||
footerLogo={typeof LogoBlack === 'string' ? LogoBlack : (LogoBlack as any).src}
|
footerLogo={typeof LogoBlack === 'string' ? LogoBlack : (LogoBlack as any).src}
|
||||||
/>;
|
/>;
|
||||||
|
|
||||||
|
const { pdf } = await import('@react-pdf/renderer');
|
||||||
|
|
||||||
// Minimum loading time of 2 seconds for better UX
|
// Minimum loading time of 2 seconds for better UX
|
||||||
const [blob] = await Promise.all([
|
const [blob] = await Promise.all([
|
||||||
pdf(doc).toBlob(),
|
pdf(doc).toBlob(),
|
||||||
|
|||||||
@@ -1,70 +1,51 @@
|
|||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
args:
|
|
||||||
NEXT_PUBLIC_BASE_URL: ${NEXT_PUBLIC_BASE_URL}
|
|
||||||
NEXT_PUBLIC_TARGET: ${TARGET:-development}
|
|
||||||
image: registry.infra.mintel.me/mintel/mintel.me:${IMAGE_TAG:-latest}
|
image: registry.infra.mintel.me/mintel/mintel.me:${IMAGE_TAG:-latest}
|
||||||
restart: always
|
restart: always
|
||||||
networks:
|
networks:
|
||||||
- infra
|
- infra
|
||||||
env_file:
|
env_file:
|
||||||
- ${ENV_FILE:-.env}
|
- ${ENV_FILE:-.env}
|
||||||
labels:
|
|
||||||
- "traefik.enable=false"
|
|
||||||
|
|
||||||
varnish:
|
|
||||||
image: varnish:7
|
|
||||||
restart: always
|
|
||||||
networks:
|
|
||||||
- infra
|
|
||||||
volumes:
|
|
||||||
- ./varnish/default.vcl:/etc/varnish/default.vcl:ro
|
|
||||||
tmpfs:
|
|
||||||
- /var/lib/varnish:exec
|
|
||||||
environment:
|
|
||||||
VARNISH_SIZE: ${VARNISH_CACHE_SIZE:-256M}
|
|
||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-mintel-me}-web.rule=Host(`${TRAEFIK_HOST}`) && !PathPrefix(`/.well-known/acme-challenge/`)"
|
- "traefik.http.routers.${PROJECT_NAME}.rule=Host(`${TRAEFIK_HOST}`)"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-mintel-me}-web.entrypoints=web"
|
- "traefik.http.routers.${PROJECT_NAME}.entrypoints=websecure"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-mintel-me}-web.middlewares=redirect-https"
|
- "traefik.http.routers.${PROJECT_NAME}.tls.certresolver=le"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-mintel-me}.rule=Host(`${TRAEFIK_HOST}`)"
|
- "traefik.http.routers.${PROJECT_NAME}.tls=true"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-mintel-me}.entrypoints=websecure"
|
- "traefik.http.services.${PROJECT_NAME}.loadbalancer.server.port=3000"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-mintel-me}.tls.certresolver=le"
|
- "traefik.http.routers.${PROJECT_NAME}.middlewares=${AUTH_MIDDLEWARE:-compress}"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-mintel-me}.tls=true"
|
- "traefik.docker.network=infra"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-mintel-me}.service=${PROJECT_NAME:-mintel-me}"
|
|
||||||
- "traefik.http.services.${PROJECT_NAME:-mintel-me}.loadbalancer.server.port=80"
|
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-mintel-me}.middlewares=${PROJECT_NAME:-mintel-me}-ratelimit,${AUTH_MIDDLEWARE:-compress}"
|
|
||||||
|
|
||||||
# Gatekeeper
|
# Gatekeeper Router
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-mintel-me}-gatekeeper.rule=Host(`${TRAEFIK_HOST}`) && PathPrefix(`/gatekeeper`)"
|
- "traefik.http.routers.${PROJECT_NAME}-gatekeeper.rule=Host(`${TRAEFIK_HOST}`) && PathPrefix(`/gatekeeper`)"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-mintel-me}-gatekeeper.entrypoints=websecure"
|
- "traefik.http.routers.${PROJECT_NAME}-gatekeeper.entrypoints=websecure"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-mintel-me}-gatekeeper.tls.certresolver=le"
|
- "traefik.http.routers.${PROJECT_NAME}-gatekeeper.tls.certresolver=le"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-mintel-me}-gatekeeper.tls=true"
|
- "traefik.http.routers.${PROJECT_NAME}-gatekeeper.tls=true"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-mintel-me}-gatekeeper.service=${PROJECT_NAME:-mintel-me}-gatekeeper"
|
- "traefik.http.routers.${PROJECT_NAME}-gatekeeper.service=${PROJECT_NAME}-gatekeeper"
|
||||||
|
|
||||||
# Middleware Definitions
|
- "traefik.http.middlewares.${PROJECT_NAME}-auth.forwardauth.address=http://${PROJECT_NAME}-gatekeeper:3000/api/verify"
|
||||||
- "traefik.http.middlewares.${PROJECT_NAME:-mintel-me}-ratelimit.ratelimit.average=100"
|
- "traefik.http.middlewares.${PROJECT_NAME}-auth.forwardauth.trustForwardHeader=true"
|
||||||
- "traefik.http.middlewares.${PROJECT_NAME:-mintel-me}-ratelimit.ratelimit.burst=50"
|
- "traefik.http.middlewares.${PROJECT_NAME}-auth.forwardauth.authResponseHeaders=X-Auth-User"
|
||||||
- "traefik.http.middlewares.${PROJECT_NAME:-mintel-me}-auth.forwardauth.address=http://${PROJECT_NAME}-gatekeeper:3000/verify"
|
- "traefik.docker.network=infra"
|
||||||
- "traefik.http.middlewares.${PROJECT_NAME:-mintel-me}-auth.forwardauth.trustForwardHeader=true"
|
|
||||||
- "traefik.http.middlewares.${PROJECT_NAME:-mintel-me}-auth.forwardauth.authResponseHeaders=X-Auth-User"
|
|
||||||
|
|
||||||
gatekeeper:
|
gatekeeper:
|
||||||
image: registry.infra.mintel.me/mintel/gatekeeper:latest
|
image: registry.infra.mintel.me/mintel/gatekeeper:latest
|
||||||
container_name: ${PROJECT_NAME:-mintel-me}-gatekeeper
|
container_name: ${PROJECT_NAME:-mintel-me}-gatekeeper
|
||||||
restart: always
|
restart: always
|
||||||
networks:
|
networks:
|
||||||
- infra
|
infra:
|
||||||
|
aliases:
|
||||||
|
- ${PROJECT_NAME:-mintel-me}-gatekeeper
|
||||||
env_file:
|
env_file:
|
||||||
- ${ENV_FILE:-.env}
|
- ${ENV_FILE:-.env}
|
||||||
environment:
|
environment:
|
||||||
PORT: 3000
|
PORT: 3000
|
||||||
|
PROJECT_NAME: ${PROJECT_NAME:-Mintel.me}
|
||||||
|
PROJECT_COLOR: ${PROJECT_COLOR:-#ff00ff}
|
||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
- "traefik.http.services.${PROJECT_NAME:-mintel-me}-gatekeeper.loadbalancer.server.port=3000"
|
- "traefik.http.services.${PROJECT_NAME}-gatekeeper.loadbalancer.server.port=3000"
|
||||||
|
- "traefik.docker.network=infra"
|
||||||
|
|
||||||
directus:
|
directus:
|
||||||
image: registry.infra.mintel.me/mintel/directus:latest
|
image: registry.infra.mintel.me/mintel/directus:latest
|
||||||
@@ -88,12 +69,13 @@ services:
|
|||||||
- ./directus/extensions:/directus/extensions
|
- ./directus/extensions:/directus/extensions
|
||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-mintel-me}-directus.rule=Host(`${DIRECTUS_HOST}`)"
|
- "traefik.http.routers.${PROJECT_NAME}-directus.rule=Host(`${DIRECTUS_HOST}`)"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-mintel-me}-directus.entrypoints=websecure"
|
- "traefik.http.routers.${PROJECT_NAME}-directus.entrypoints=websecure"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-mintel-me}-directus.tls.certresolver=le"
|
- "traefik.http.routers.${PROJECT_NAME}-directus.tls.certresolver=le"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-mintel-me}-directus.tls=true"
|
- "traefik.http.routers.${PROJECT_NAME}-directus.tls=true"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-mintel-me}-directus.middlewares=${AUTH_MIDDLEWARE:-compress}"
|
- "traefik.http.routers.${PROJECT_NAME}-directus.middlewares=${AUTH_MIDDLEWARE:-compress}"
|
||||||
- "traefik.http.services.${PROJECT_NAME:-mintel-me}-directus.loadbalancer.server.port=8055"
|
- "traefik.http.services.${PROJECT_NAME}-directus.loadbalancer.server.port=8055"
|
||||||
|
- "traefik.docker.network=infra"
|
||||||
|
|
||||||
directus-db:
|
directus-db:
|
||||||
image: postgres:15-alpine
|
image: postgres:15-alpine
|
||||||
|
|||||||
12
package.json
12
package.json
@@ -12,7 +12,17 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@mintel/eslint-config": "^1.2.3",
|
"@mintel/eslint-config": "^1.2.3",
|
||||||
"@mintel/husky-config": "^1.2.3",
|
"@mintel/husky-config": "^1.2.3",
|
||||||
|
"eslint": "^10.0.0",
|
||||||
|
"eslint-plugin-react": "^7.37.5",
|
||||||
|
"eslint-plugin-react-hooks": "^7.0.1",
|
||||||
"husky": "^9.1.7",
|
"husky": "^9.1.7",
|
||||||
"lint-staged": "^16.2.7"
|
"lint-staged": "^16.2.7",
|
||||||
|
"prettier": "^3.8.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@mintel/cli": "^1.2.5",
|
||||||
|
"@mintel/next-config": "^1.2.5",
|
||||||
|
"@mintel/next-utils": "^1.2.3",
|
||||||
|
"@mintel/tsconfig": "^1.2.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2954
pnpm-lock.yaml
generated
2954
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
116
scripts/sync-directus.sh
Executable file
116
scripts/sync-directus.sh
Executable file
@@ -0,0 +1,116 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
REMOTE_HOST="${SSH_HOST:-root@alpha.mintel.me}"
|
||||||
|
ACTION=$1
|
||||||
|
ENV=$2
|
||||||
|
|
||||||
|
# Help
|
||||||
|
if [ -z "$ACTION" ] || [ -z "$ENV" ]; then
|
||||||
|
echo "Usage: ./scripts/sync-directus.sh [push|pull] [testing|staging|production]"
|
||||||
|
echo ""
|
||||||
|
echo "Commands:"
|
||||||
|
echo " push Sync LOCAL data -> REMOTE"
|
||||||
|
echo " pull Sync REMOTE data -> LOCAL"
|
||||||
|
echo ""
|
||||||
|
echo "Environments:"
|
||||||
|
echo " testing, staging, production"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Project Configuration
|
||||||
|
PRJ_ID="mintel-me"
|
||||||
|
REMOTE_DIR="/home/deploy/sites/mintel.me"
|
||||||
|
|
||||||
|
case $ENV in
|
||||||
|
testing) PROJECT_NAME="${PRJ_ID}-testing"; ENV_FILE=".env.testing" ;;
|
||||||
|
staging) PROJECT_NAME="${PRJ_ID}-staging"; ENV_FILE=".env.staging" ;;
|
||||||
|
production) PROJECT_NAME="${PRJ_ID}-prod"; ENV_FILE=".env.prod" ;;
|
||||||
|
*) echo "❌ Invalid environment: $ENV"; exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# DB Details
|
||||||
|
DB_USER="directus"
|
||||||
|
DB_NAME="directus"
|
||||||
|
|
||||||
|
echo "🔍 Detecting local database..."
|
||||||
|
# Check root or apps/web for docker-compose context
|
||||||
|
if [ -f "docker-compose.yml" ]; then
|
||||||
|
COMPOSE_CMD="docker compose"
|
||||||
|
elif [ -f "../../docker-compose.yml" ]; then
|
||||||
|
COMPOSE_CMD="docker compose -f ../../docker-compose.yml"
|
||||||
|
else
|
||||||
|
echo "❌ docker-compose.yml not found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
LOCAL_DB_CONTAINER=$($COMPOSE_CMD ps -q directus-db)
|
||||||
|
if [ -z "$LOCAL_DB_CONTAINER" ]; then
|
||||||
|
echo "❌ Local directus-db container not found. Is it running?"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$ACTION" == "push" ]; then
|
||||||
|
echo "🚀 Pushing LOCAL -> $ENV ($PROJECT_NAME)..."
|
||||||
|
|
||||||
|
echo "📦 Dumping local database..."
|
||||||
|
docker exec "$LOCAL_DB_CONTAINER" pg_dump -U "$DB_USER" --clean --if-exists --no-owner --no-privileges "$DB_NAME" > dump.sql
|
||||||
|
|
||||||
|
echo "📤 Uploading dump to remote server..."
|
||||||
|
scp dump.sql "$REMOTE_HOST:$REMOTE_DIR/dump.sql"
|
||||||
|
|
||||||
|
echo "🔄 Restoring dump on $ENV..."
|
||||||
|
REMOTE_DB_CONTAINER=$(ssh "$REMOTE_HOST" "cd $REMOTE_DIR && docker compose -p $PROJECT_NAME ps -q directus-db")
|
||||||
|
|
||||||
|
if [ -z "$REMOTE_DB_CONTAINER" ]; then
|
||||||
|
echo "❌ Remote $ENV-db container not found!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "🧹 Wiping remote database schema..."
|
||||||
|
ssh "$REMOTE_HOST" "docker exec $REMOTE_DB_CONTAINER psql -U $DB_USER $DB_NAME -c 'DROP SCHEMA public CASCADE; CREATE SCHEMA public;'"
|
||||||
|
|
||||||
|
echo "⚡ Restoring database..."
|
||||||
|
ssh "$REMOTE_HOST" "docker exec -i $REMOTE_DB_CONTAINER psql -U $DB_USER $DB_NAME < $REMOTE_DIR/dump.sql"
|
||||||
|
|
||||||
|
echo "📁 Syncing uploads (Local -> $ENV)..."
|
||||||
|
rsync -avz --progress ./directus/uploads/ "$REMOTE_HOST:$REMOTE_DIR/directus/uploads/"
|
||||||
|
|
||||||
|
rm dump.sql
|
||||||
|
ssh "$REMOTE_HOST" "rm $REMOTE_DIR/dump.sql"
|
||||||
|
|
||||||
|
echo "🔄 Restarting remote Directus..."
|
||||||
|
ssh "$REMOTE_HOST" "cd $REMOTE_DIR && docker compose -p $PROJECT_NAME restart directus"
|
||||||
|
|
||||||
|
echo "✨ Push to $ENV complete!"
|
||||||
|
|
||||||
|
elif [ "$ACTION" == "pull" ]; then
|
||||||
|
echo "📥 Pulling $ENV Data -> LOCAL..."
|
||||||
|
|
||||||
|
echo "📦 Dumping remote database ($ENV)..."
|
||||||
|
REMOTE_DB_CONTAINER=$(ssh "$REMOTE_HOST" "cd $REMOTE_DIR && docker compose -p $PROJECT_NAME ps -q directus-db")
|
||||||
|
|
||||||
|
if [ -z "$REMOTE_DB_CONTAINER" ]; then
|
||||||
|
echo "❌ Remote $ENV-db container not found!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
ssh "$REMOTE_HOST" "docker exec $REMOTE_DB_CONTAINER pg_dump -U $DB_USER --clean --if-exists --no-owner --no-privileges $DB_NAME > $REMOTE_DIR/dump.sql"
|
||||||
|
|
||||||
|
echo "📥 Downloading dump..."
|
||||||
|
scp "$REMOTE_HOST:$REMOTE_DIR/dump.sql" dump.sql
|
||||||
|
|
||||||
|
echo "🧹 Wiping local database schema..."
|
||||||
|
docker exec "$LOCAL_DB_CONTAINER" psql -U "$DB_USER" "$DB_NAME" -c 'DROP SCHEMA public CASCADE; CREATE SCHEMA public;'
|
||||||
|
|
||||||
|
echo "⚡ Restoring database locally..."
|
||||||
|
docker exec -i "$LOCAL_DB_CONTAINER" psql -U "$DB_USER" "$DB_NAME" < dump.sql
|
||||||
|
|
||||||
|
echo "📁 Syncing uploads ($ENV -> Local)..."
|
||||||
|
rsync -avz --progress "$REMOTE_HOST:$REMOTE_DIR/directus/uploads/" ./directus/uploads/
|
||||||
|
|
||||||
|
rm dump.sql
|
||||||
|
ssh "$REMOTE_HOST" "rm $REMOTE_DIR/dump.sql"
|
||||||
|
|
||||||
|
echo "✨ Pull to Local complete!"
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user