perf: Add Docker build cache mounts for npm ci and npm run build commands.
Some checks failed
Build & Deploy KLZ Cables / 🔍 Prepare Environment (push) Successful in 21s
Build & Deploy KLZ Cables / 🧪 Quality Assurance (push) Successful in 1m24s
Build & Deploy KLZ Cables / 🏗️ Build & Push (push) Successful in 5m48s
Build & Deploy KLZ Cables / 🚀 Deploy (push) Failing after 12s
Build & Deploy KLZ Cables / 🔔 Notifications (push) Successful in 3s
Some checks failed
Build & Deploy KLZ Cables / 🔍 Prepare Environment (push) Successful in 21s
Build & Deploy KLZ Cables / 🧪 Quality Assurance (push) Successful in 1m24s
Build & Deploy KLZ Cables / 🏗️ Build & Push (push) Successful in 5m48s
Build & Deploy KLZ Cables / 🚀 Deploy (push) Failing after 12s
Build & Deploy KLZ Cables / 🔔 Notifications (push) Successful in 3s
This commit is contained in:
@@ -32,6 +32,7 @@ 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 }}
|
||||||
|
project_name: ${{ steps.determine.outputs.project_name }}
|
||||||
is_prod: ${{ steps.determine.outputs.is_prod }}
|
is_prod: ${{ steps.determine.outputs.is_prod }}
|
||||||
gotify_title: ${{ steps.determine.outputs.gotify_title }}
|
gotify_title: ${{ steps.determine.outputs.gotify_title }}
|
||||||
gotify_priority: ${{ steps.determine.outputs.gotify_priority }}
|
gotify_priority: ${{ steps.determine.outputs.gotify_priority }}
|
||||||
@@ -59,6 +60,7 @@ jobs:
|
|||||||
NEXT_PUBLIC_BASE_URL="https://testing.klz-cables.com"
|
NEXT_PUBLIC_BASE_URL="https://testing.klz-cables.com"
|
||||||
DIRECTUS_URL="https://cms-testing.klz-cables.com"
|
DIRECTUS_URL="https://cms-testing.klz-cables.com"
|
||||||
DIRECTUS_HOST='`cms-testing.klz-cables.com`'
|
DIRECTUS_HOST='`cms-testing.klz-cables.com`'
|
||||||
|
PROJECT_NAME="klz-cables-testing"
|
||||||
IS_PROD="false"
|
IS_PROD="false"
|
||||||
GOTIFY_TITLE="🧪 Testing-Deploy"
|
GOTIFY_TITLE="🧪 Testing-Deploy"
|
||||||
GOTIFY_PRIORITY=4
|
GOTIFY_PRIORITY=4
|
||||||
@@ -71,6 +73,7 @@ jobs:
|
|||||||
NEXT_PUBLIC_BASE_URL="https://klz-cables.com"
|
NEXT_PUBLIC_BASE_URL="https://klz-cables.com"
|
||||||
DIRECTUS_URL="https://cms.klz-cables.com"
|
DIRECTUS_URL="https://cms.klz-cables.com"
|
||||||
DIRECTUS_HOST='`cms.klz-cables.com`'
|
DIRECTUS_HOST='`cms.klz-cables.com`'
|
||||||
|
PROJECT_NAME="klz-cables-prod"
|
||||||
IS_PROD="true"
|
IS_PROD="true"
|
||||||
GOTIFY_TITLE="🚀 Production-Release"
|
GOTIFY_TITLE="🚀 Production-Release"
|
||||||
GOTIFY_PRIORITY=6
|
GOTIFY_PRIORITY=6
|
||||||
@@ -82,6 +85,7 @@ jobs:
|
|||||||
NEXT_PUBLIC_BASE_URL="https://staging.klz-cables.com"
|
NEXT_PUBLIC_BASE_URL="https://staging.klz-cables.com"
|
||||||
DIRECTUS_URL="https://cms-staging.klz-cables.com"
|
DIRECTUS_URL="https://cms-staging.klz-cables.com"
|
||||||
DIRECTUS_HOST='`cms-staging.klz-cables.com`'
|
DIRECTUS_HOST='`cms-staging.klz-cables.com`'
|
||||||
|
PROJECT_NAME="klz-cables-staging"
|
||||||
IS_PROD="false"
|
IS_PROD="false"
|
||||||
GOTIFY_TITLE="🧪 Staging-Deploy (Pre-Release)"
|
GOTIFY_TITLE="🧪 Staging-Deploy (Pre-Release)"
|
||||||
GOTIFY_PRIORITY=5
|
GOTIFY_PRIORITY=5
|
||||||
@@ -101,6 +105,7 @@ jobs:
|
|||||||
echo "next_public_base_url=$NEXT_PUBLIC_BASE_URL" >> $GITHUB_OUTPUT
|
echo "next_public_base_url=$NEXT_PUBLIC_BASE_URL" >> $GITHUB_OUTPUT
|
||||||
echo "directus_url=$DIRECTUS_URL" >> $GITHUB_OUTPUT
|
echo "directus_url=$DIRECTUS_URL" >> $GITHUB_OUTPUT
|
||||||
echo "directus_host=$DIRECTUS_HOST" >> $GITHUB_OUTPUT
|
echo "directus_host=$DIRECTUS_HOST" >> $GITHUB_OUTPUT
|
||||||
|
echo "project_name=$PROJECT_NAME" >> $GITHUB_OUTPUT
|
||||||
echo "is_prod=$IS_PROD" >> $GITHUB_OUTPUT
|
echo "is_prod=$IS_PROD" >> $GITHUB_OUTPUT
|
||||||
echo "gotify_title=$GOTIFY_TITLE" >> $GITHUB_OUTPUT
|
echo "gotify_title=$GOTIFY_TITLE" >> $GITHUB_OUTPUT
|
||||||
echo "gotify_priority=$GOTIFY_PRIORITY" >> $GITHUB_OUTPUT
|
echo "gotify_priority=$GOTIFY_PRIORITY" >> $GITHUB_OUTPUT
|
||||||
@@ -166,15 +171,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
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
|
||||||
|
|
||||||
- name: 📦 Restore Next.js cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: .next/cache
|
|
||||||
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
|
|
||||||
${{ runner.os }}-nextjs-
|
|
||||||
|
|
||||||
- name: 🏗️ Docker Image bauen & pushen
|
- name: 🏗️ Docker Image bauen & pushen
|
||||||
env:
|
env:
|
||||||
IMAGE_TAG: ${{ needs.prepare.outputs.image_tag }}
|
IMAGE_TAG: ${{ needs.prepare.outputs.image_tag }}
|
||||||
@@ -197,12 +193,6 @@ jobs:
|
|||||||
--cache-to type=registry,ref=registry.infra.mintel.me/mintel/klz-cables.com:buildcache,mode=max \
|
--cache-to type=registry,ref=registry.infra.mintel.me/mintel/klz-cables.com:buildcache,mode=max \
|
||||||
--push .
|
--push .
|
||||||
|
|
||||||
- name: 📦 Save Next.js cache
|
|
||||||
uses: actions/cache/save@v4
|
|
||||||
if: always()
|
|
||||||
with:
|
|
||||||
path: .next/cache
|
|
||||||
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
|
|
||||||
|
|
||||||
# ──────────────────────────────────────────────────────────────────────────────
|
# ──────────────────────────────────────────────────────────────────────────────
|
||||||
# JOB 4: Deploy via SSH
|
# JOB 4: Deploy via SSH
|
||||||
@@ -228,6 +218,7 @@ jobs:
|
|||||||
MAIL_RECIPIENTS: ${{ secrets.MAIL_RECIPIENTS }}
|
MAIL_RECIPIENTS: ${{ secrets.MAIL_RECIPIENTS }}
|
||||||
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 }}
|
||||||
|
PROJECT_NAME: ${{ needs.prepare.outputs.project_name }}
|
||||||
DIRECTUS_KEY: ${{ secrets.DIRECTUS_KEY }}
|
DIRECTUS_KEY: ${{ secrets.DIRECTUS_KEY }}
|
||||||
DIRECTUS_SECRET: ${{ secrets.DIRECTUS_SECRET }}
|
DIRECTUS_SECRET: ${{ secrets.DIRECTUS_SECRET }}
|
||||||
DIRECTUS_ADMIN_EMAIL: ${{ secrets.DIRECTUS_ADMIN_EMAIL }}
|
DIRECTUS_ADMIN_EMAIL: ${{ secrets.DIRECTUS_ADMIN_EMAIL }}
|
||||||
@@ -283,16 +274,16 @@ jobs:
|
|||||||
scp -o StrictHostKeyChecking=accept-new /tmp/klz-cables.env root@alpha.mintel.me:/home/deploy/sites/klz-cables.com/$ENV_FILE
|
scp -o StrictHostKeyChecking=accept-new /tmp/klz-cables.env root@alpha.mintel.me:/home/deploy/sites/klz-cables.com/$ENV_FILE
|
||||||
scp -o StrictHostKeyChecking=accept-new docker-compose.yml root@alpha.mintel.me:/home/deploy/sites/klz-cables.com/docker-compose.yml
|
scp -o StrictHostKeyChecking=accept-new docker-compose.yml root@alpha.mintel.me:/home/deploy/sites/klz-cables.com/docker-compose.yml
|
||||||
|
|
||||||
ssh -o StrictHostKeyChecking=accept-new root@alpha.mintel.me IMAGE_TAG="$IMAGE_TAG" ENV_FILE="$ENV_FILE" bash << 'EOF'
|
ssh -o StrictHostKeyChecking=accept-new root@alpha.mintel.me IMAGE_TAG="$IMAGE_TAG" ENV_FILE="$ENV_FILE" PROJECT_NAME="$PROJECT_NAME" bash << 'EOF'
|
||||||
set -e
|
set -e
|
||||||
cd /home/deploy/sites/klz-cables.com
|
cd /home/deploy/sites/klz-cables.com
|
||||||
chmod 600 "$ENV_FILE"
|
chmod 600 "$ENV_FILE"
|
||||||
chown deploy:deploy "$ENV_FILE"
|
chown deploy:deploy "$ENV_FILE"
|
||||||
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
|
||||||
echo "→ Pulling image: $IMAGE_TAG"
|
echo "→ Pulling image: $IMAGE_TAG"
|
||||||
docker compose --env-file "$ENV_FILE" pull
|
docker compose -p "$PROJECT_NAME" --env-file "$ENV_FILE" pull
|
||||||
echo "→ Starting containers..."
|
echo "→ Starting containers..."
|
||||||
docker compose --env-file "$ENV_FILE" up -d
|
docker compose -p "$PROJECT_NAME" --env-file "$ENV_FILE" up -d --remove-orphans
|
||||||
docker system prune -f --filter "until=168h"
|
docker system prune -f --filter "until=168h"
|
||||||
echo "→ Waiting 15s for warmup..."
|
echo "→ Waiting 15s for warmup..."
|
||||||
sleep 15
|
sleep 15
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ WORKDIR /app
|
|||||||
|
|
||||||
# Install dependencies based on the preferred package manager
|
# Install dependencies based on the preferred package manager
|
||||||
COPY package.json package-lock.json* ./
|
COPY package.json package-lock.json* ./
|
||||||
RUN npm ci
|
RUN --mount=type=cache,target=/root/.npm npm ci
|
||||||
|
|
||||||
|
|
||||||
# Rebuild the source code only when needed
|
# Rebuild the source code only when needed
|
||||||
@@ -37,7 +37,7 @@ ENV DIRECTUS_URL=$DIRECTUS_URL
|
|||||||
# Validate environment variables during build
|
# Validate environment variables during build
|
||||||
RUN npx tsx scripts/validate-env.ts
|
RUN npx tsx scripts/validate-env.ts
|
||||||
|
|
||||||
RUN npm run build
|
RUN --mount=type=cache,target=/app/.next/cache npm run build
|
||||||
|
|
||||||
# Production image, copy all the files and run next
|
# Production image, copy all the files and run next
|
||||||
FROM base AS runner
|
FROM base AS runner
|
||||||
|
|||||||
Reference in New Issue
Block a user