chore: overhaul infrastructure and integrate @mintel packages
Some checks failed
🧪 CI (QA) / 🧪 Quality Assurance (push) Failing after 1m3s
Some checks failed
🧪 CI (QA) / 🧪 Quality Assurance (push) Failing after 1m3s
- Restructure to pnpm monorepo (site moved to apps/web) - Integrate @mintel/tsconfig, @mintel/eslint-config, @mintel/husky-config - Implement Docker service architecture (Varnish, Directus, Gatekeeper) - Setup environment-aware Gitea Actions deployment
This commit is contained in:
39
.gitea/workflows/ci.yml
Normal file
39
.gitea/workflows/ci.yml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
name: 🧪 CI (QA)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
qa:
|
||||||
|
name: 🧪 Quality Assurance
|
||||||
|
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: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 10
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm install --frozen-lockfile
|
||||||
|
env:
|
||||||
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
|
- name: 🧪 Run Checks
|
||||||
|
run: |
|
||||||
|
pnpm lint
|
||||||
|
pnpm build
|
||||||
@@ -1,146 +1,201 @@
|
|||||||
name: Build & Deploy Mintel Blog
|
name: Build & Deploy Mintel.me
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches:
|
||||||
|
- main
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ (github.ref_type == 'tag' && !contains(github.ref_name, '-')) && 'prod' || (github.ref_type == 'tag' && 'staging' || 'testing') }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-deploy:
|
prepare:
|
||||||
|
name: 🔍 Prepare Environment
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
|
outputs:
|
||||||
|
target: ${{ steps.determine.outputs.target }}
|
||||||
|
image_tag: ${{ steps.determine.outputs.image_tag }}
|
||||||
|
env_file: ${{ steps.determine.outputs.env_file }}
|
||||||
|
traefik_host: ${{ steps.determine.outputs.traefik_host }}
|
||||||
|
next_public_base_url: ${{ steps.determine.outputs.next_public_base_url }}
|
||||||
|
directus_url: ${{ steps.determine.outputs.directus_url }}
|
||||||
|
directus_host: ${{ steps.determine.outputs.directus_host }}
|
||||||
|
project_name: ${{ steps.determine.outputs.project_name }}
|
||||||
|
is_prod: ${{ steps.determine.outputs.is_prod }}
|
||||||
|
gotify_title: ${{ steps.determine.outputs.gotify_title }}
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
steps:
|
steps:
|
||||||
- name: 📋 Log Workflow Start
|
- name: Checkout repository
|
||||||
run: |
|
uses: actions/checkout@v4
|
||||||
echo "🚀 Starting deployment for ${{ github.repository }} (${{ github.ref }})"
|
with:
|
||||||
echo " • Commit: ${{ github.sha }}"
|
fetch-depth: 1
|
||||||
echo " • Timestamp: $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
|
|
||||||
|
|
||||||
|
- name: 🔍 Determine Environment
|
||||||
|
id: determine
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
TAG="${{ github.ref_name }}"
|
||||||
|
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-9)
|
||||||
|
|
||||||
|
if [[ "${{ github.ref_type }}" == "branch" && "$TAG" == "main" ]]; then
|
||||||
|
TARGET="testing"
|
||||||
|
IMAGE_TAG="main-${SHORT_SHA}"
|
||||||
|
ENV_FILE=".env.testing"
|
||||||
|
TRAEFIK_HOST="testing.mintel.me"
|
||||||
|
NEXT_PUBLIC_BASE_URL="https://testing.mintel.me"
|
||||||
|
DIRECTUS_URL="https://cms.testing.mintel.me"
|
||||||
|
DIRECTUS_HOST="cms.testing.mintel.me"
|
||||||
|
PROJECT_NAME="mintel-me-testing"
|
||||||
|
IS_PROD="false"
|
||||||
|
GOTIFY_TITLE="🧪 Testing-Deploy"
|
||||||
|
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
|
||||||
|
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
TARGET="production"
|
||||||
|
IMAGE_TAG="$TAG"
|
||||||
|
ENV_FILE=".env.prod"
|
||||||
|
TRAEFIK_HOST="mintel.me, www.mintel.me"
|
||||||
|
NEXT_PUBLIC_BASE_URL="https://mintel.me"
|
||||||
|
DIRECTUS_URL="https://cms.mintel.me"
|
||||||
|
DIRECTUS_HOST="cms.mintel.me"
|
||||||
|
PROJECT_NAME="mintel-me-prod"
|
||||||
|
IS_PROD="true"
|
||||||
|
GOTIFY_TITLE="🚀 Production-Release"
|
||||||
|
else
|
||||||
|
TARGET="staging"
|
||||||
|
IMAGE_TAG="$TAG"
|
||||||
|
ENV_FILE=".env.staging"
|
||||||
|
TRAEFIK_HOST="staging.mintel.me"
|
||||||
|
NEXT_PUBLIC_BASE_URL="https://staging.mintel.me"
|
||||||
|
DIRECTUS_URL="https://cms.staging.mintel.me"
|
||||||
|
DIRECTUS_HOST="cms.staging.mintel.me"
|
||||||
|
PROJECT_NAME="mintel-me-staging"
|
||||||
|
IS_PROD="false"
|
||||||
|
GOTIFY_TITLE="🧪 Staging-Deploy"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Skipping deploy for unknown ref type"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
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 "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=$PROJECT_NAME" >> $GITHUB_OUTPUT
|
||||||
|
echo "is_prod=$IS_PROD" >> $GITHUB_OUTPUT
|
||||||
|
echo "gotify_title=$GOTIFY_TITLE" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: 🏗️ Build & Push
|
||||||
|
needs: prepare
|
||||||
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: 🔐 Login to private registry
|
- name: 🐳 Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: 🔐 Registry Login
|
||||||
run: |
|
run: |
|
||||||
echo "🔐 Authenticating with registry.infra.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
|
||||||
|
|
||||||
- name: 🏗️ Build Docker image
|
- name: 🏗️ Build & Push
|
||||||
|
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 }}
|
||||||
run: |
|
run: |
|
||||||
echo "🏗️ Building Docker image (linux/arm64)..."
|
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--pull \
|
--pull \
|
||||||
--platform linux/arm64 \
|
--platform linux/arm64 \
|
||||||
--build-arg NEXT_PUBLIC_ANALYTICS_PROVIDER="${{ secrets.NEXT_PUBLIC_ANALYTICS_PROVIDER }}" \
|
--build-arg NEXT_PUBLIC_BASE_URL="$NEXT_PUBLIC_BASE_URL" \
|
||||||
--build-arg NEXT_PUBLIC_UMAMI_WEBSITE_ID="${{ secrets.NEXT_PUBLIC_UMAMI_WEBSITE_ID }}" \
|
--build-arg NEXT_PUBLIC_TARGET="$TARGET" \
|
||||||
--build-arg NEXT_PUBLIC_UMAMI_HOST_URL="${{ secrets.NEXT_PUBLIC_UMAMI_HOST_URL }}" \
|
--build-arg DIRECTUS_URL="$DIRECTUS_URL" \
|
||||||
--build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN="${{ secrets.NEXT_PUBLIC_PLAUSIBLE_DOMAIN }}" \
|
--secret id=NPM_TOKEN,env=NPM_TOKEN \
|
||||||
--build-arg NEXT_PUBLIC_PLAUSIBLE_SCRIPT_URL="${{ secrets.NEXT_PUBLIC_PLAUSIBLE_SCRIPT_URL }}" \
|
-t registry.infra.mintel.me/mintel/mintel.me:$IMAGE_TAG \
|
||||||
--build-arg NEXT_PUBLIC_GLITCHTIP_DSN="${{ secrets.NEXT_PUBLIC_GLITCHTIP_DSN }}" \
|
--push .
|
||||||
-t registry.infra.mintel.me/mintel/mintel.me:latest \
|
env:
|
||||||
--push -f docker/Dockerfile .
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
- name: 🚀 Deploy to production server
|
deploy:
|
||||||
|
name: 🚀 Deploy
|
||||||
|
needs: [prepare, build]
|
||||||
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: 🚀 Deploy via SSH
|
||||||
|
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 }}
|
||||||
|
AUTH_MIDDLEWARE: ${{ needs.prepare.outputs.is_prod == 'true' && 'compress' || format('{0}-auth,compress', needs.prepare.outputs.project_name) }}
|
||||||
run: |
|
run: |
|
||||||
echo "🚀 Deploying to alpha.mintel.me..."
|
|
||||||
|
|
||||||
# Setup SSH
|
|
||||||
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
|
||||||
|
cat > .env.tmp << EOF
|
||||||
|
# Generated by CI
|
||||||
|
NEXT_PUBLIC_BASE_URL=${{ needs.prepare.outputs.next_public_base_url }}
|
||||||
|
NEXT_PUBLIC_TARGET=$TARGET
|
||||||
|
DIRECTUS_URL=${{ needs.prepare.outputs.directus_url }}
|
||||||
|
DIRECTUS_HOST=${{ needs.prepare.outputs.directus_host }}
|
||||||
|
TRAEFIK_HOST=${{ needs.prepare.outputs.traefik_host }}
|
||||||
|
IMAGE_TAG=$IMAGE_TAG
|
||||||
|
PROJECT_NAME=$PROJECT_NAME
|
||||||
|
AUTH_MIDDLEWARE=$AUTH_MIDDLEWARE
|
||||||
|
|
||||||
# Create .env file content
|
# Secrets
|
||||||
cat > /tmp/mintel.me.env << EOF
|
DIRECTUS_KEY=${{ secrets.DIRECTUS_KEY }}
|
||||||
# ============================================================================
|
DIRECTUS_SECRET=${{ secrets.DIRECTUS_SECRET }}
|
||||||
# Mintel Blog - Production Environment Configuration
|
DIRECTUS_DB_NAME=${{ secrets.DIRECTUS_DB_NAME || 'directus' }}
|
||||||
# ============================================================================
|
DIRECTUS_DB_USER=${{ secrets.DIRECTUS_DB_USER || 'directus' }}
|
||||||
# Auto-generated by CI/CD workflow
|
DIRECTUS_DB_PASSWORD=${{ secrets.DIRECTUS_DB_PASSWORD }}
|
||||||
# ============================================================================
|
|
||||||
|
|
||||||
# Application
|
|
||||||
NODE_ENV=production
|
|
||||||
DOMAIN=mintel.me
|
|
||||||
ADMIN_EMAIL=${{ secrets.ADMIN_EMAIL }}
|
|
||||||
|
|
||||||
# Analytics
|
|
||||||
NEXT_PUBLIC_ANALYTICS_PROVIDER=${{ secrets.NEXT_PUBLIC_ANALYTICS_PROVIDER }}
|
|
||||||
NEXT_PUBLIC_UMAMI_WEBSITE_ID=${{ secrets.NEXT_PUBLIC_UMAMI_WEBSITE_ID }}
|
|
||||||
NEXT_PUBLIC_UMAMI_HOST_URL=${{ secrets.NEXT_PUBLIC_UMAMI_HOST_URL }}
|
|
||||||
NEXT_PUBLIC_PLAUSIBLE_DOMAIN=${{ secrets.NEXT_PUBLIC_PLAUSIBLE_DOMAIN }}
|
|
||||||
NEXT_PUBLIC_PLAUSIBLE_SCRIPT_URL=${{ secrets.NEXT_PUBLIC_PLAUSIBLE_SCRIPT_URL }}
|
|
||||||
|
|
||||||
# Error Tracking (GlitchTip/Sentry)
|
|
||||||
NEXT_PUBLIC_GLITCHTIP_DSN=${{ secrets.NEXT_PUBLIC_GLITCHTIP_DSN }}
|
|
||||||
|
|
||||||
# Redis
|
|
||||||
REDIS_URL=redis://redis:6379
|
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Upload .env and deploy
|
|
||||||
scp -o StrictHostKeyChecking=accept-new /tmp/mintel.me.env root@alpha.mintel.me:/home/deploy/sites/mintel.me/.env
|
|
||||||
|
|
||||||
ssh -o StrictHostKeyChecking=accept-new root@alpha.mintel.me bash << EOF
|
|
||||||
set -e
|
|
||||||
cd /home/deploy/sites/mintel.me
|
|
||||||
|
|
||||||
chmod 600 .env
|
|
||||||
chown deploy:deploy .env
|
|
||||||
|
|
||||||
echo "${{ secrets.REGISTRY_PASS }}" | docker login registry.infra.mintel.me -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
|
||||||
docker pull registry.infra.mintel.me/mintel/mintel.me:latest
|
|
||||||
|
|
||||||
docker-compose down
|
|
||||||
|
|
||||||
echo "🚀 Starting containers..."
|
|
||||||
docker-compose up -d
|
|
||||||
|
|
||||||
echo "⏳ Giving the app a few seconds to warm up..."
|
|
||||||
sleep 10
|
|
||||||
|
|
||||||
echo "🔍 Checking container status..."
|
|
||||||
docker-compose ps
|
|
||||||
|
|
||||||
if ! docker-compose ps | grep -q "Up"; then
|
|
||||||
echo "❌ Container failed to start"
|
|
||||||
docker-compose logs --tail=100
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "✅ Deployment complete!"
|
scp .env.tmp 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'
|
||||||
|
cd /home/deploy/sites/mintel.me
|
||||||
|
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 "$PROJECT_NAME" --env-file "$ENV_FILE" up -d --remove-orphans
|
||||||
|
docker system prune -f --filter "until=24h"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
rm -f /tmp/mintel.me.env
|
|
||||||
|
|
||||||
- name: 📊 Workflow Summary
|
notifications:
|
||||||
if: always()
|
name: 🔔 Notifications
|
||||||
|
needs: [prepare, deploy]
|
||||||
|
if: always()
|
||||||
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
steps:
|
||||||
|
- name: 🔔 Gotify
|
||||||
run: |
|
run: |
|
||||||
echo "📊 Status: ${{ job.status }}"
|
STATUS="${{ needs.deploy.result == 'success' && '✅' || '❌' }}"
|
||||||
echo "🎯 Target: alpha.mintel.me"
|
curl -s -k -X POST "${{ secrets.GOTIFY_URL }}/message?token=${{ secrets.GOTIFY_TOKEN }}" \
|
||||||
|
-F "title=$STATUS ${{ needs.prepare.outputs.gotify_title }}" \
|
||||||
- name: 🔔 Gotify Notification (Success)
|
-F "message=Deploy to **${{ needs.prepare.outputs.target }}** ${{ needs.deploy.result }}.\nVersion: ${{ needs.prepare.outputs.image_tag }}" \
|
||||||
if: success()
|
-F "priority=5" || true
|
||||||
run: |
|
|
||||||
echo "Sending success notification to Gotify..."
|
|
||||||
curl -k -s -X POST "${{ secrets.GOTIFY_URL }}/message?token=${{ secrets.GOTIFY_TOKEN }}" \
|
|
||||||
-F "title=✅ Deployment Success: ${{ github.repository }}" \
|
|
||||||
-F "message=The deployment of ${{ github.repository }} (branch: ${{ github.ref }}) was successful.
|
|
||||||
|
|
||||||
Commit: ${{ github.sha }}
|
|
||||||
Actor: ${{ github.actor }}
|
|
||||||
Run ID: ${{ github.run_id }}" \
|
|
||||||
-F "priority=5"
|
|
||||||
|
|
||||||
- name: 🔔 Gotify Notification (Failure)
|
|
||||||
if: failure()
|
|
||||||
run: |
|
|
||||||
echo "Sending failure notification to Gotify..."
|
|
||||||
curl -k -s -X POST "${{ secrets.GOTIFY_URL }}/message?token=${{ secrets.GOTIFY_TOKEN }}" \
|
|
||||||
-F "title=❌ Deployment Failed: ${{ github.repository }}" \
|
|
||||||
-F "message=The deployment of ${{ github.repository }} (branch: ${{ github.ref }}) failed!
|
|
||||||
|
|
||||||
Commit: ${{ github.sha }}
|
|
||||||
Actor: ${{ github.actor }}
|
|
||||||
Run ID: ${{ github.run_id }}
|
|
||||||
|
|
||||||
Please check the logs for details." \
|
|
||||||
-F "priority=8"
|
|
||||||
|
|||||||
1
.husky/pre-commit
Executable file
1
.husky/pre-commit
Executable file
@@ -0,0 +1 @@
|
|||||||
|
npx lint-staged
|
||||||
1
.lintstagedrc.js
Normal file
1
.lintstagedrc.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { default } from "@mintel/husky-config/lint-staged";
|
||||||
6
.npmrc
Normal file
6
.npmrc
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
@mintel:registry=https://npm.infra.mintel.me/
|
||||||
|
registry=https://npm.infra.mintel.me/
|
||||||
|
//npm.infra.mintel.me/:_authToken=${NPM_TOKEN}
|
||||||
|
always-auth=true
|
||||||
|
node-linker=hoisted
|
||||||
|
symlink=false
|
||||||
69
Dockerfile
Normal file
69
Dockerfile
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
FROM node:20-alpine AS base
|
||||||
|
RUN corepack enable pnpm
|
||||||
|
|
||||||
|
# Install dependencies only when needed
|
||||||
|
FROM base AS deps
|
||||||
|
RUN apk add --no-cache libc6-compat curl
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json .npmrc ./
|
||||||
|
COPY apps/web/package.json ./apps/web/package.json
|
||||||
|
|
||||||
|
# If there are local packages, copy them here
|
||||||
|
# COPY packages/ ./packages/
|
||||||
|
|
||||||
|
RUN --mount=type=cache,target=/root/.local/share/pnpm/store/v3 \
|
||||||
|
--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 . .
|
||||||
|
|
||||||
|
# Build-time environment variables
|
||||||
|
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
|
||||||
|
|
||||||
|
# Production image, copy all the files and run next
|
||||||
|
FROM base AS runner
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN apk add --no-cache curl
|
||||||
|
|
||||||
|
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/static ./apps/web/.next/static
|
||||||
|
|
||||||
|
USER nextjs
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
ENV PORT=3000
|
||||||
|
ENV HOSTNAME="0.0.0.0"
|
||||||
|
|
||||||
|
WORKDIR /app/apps/web
|
||||||
|
CMD ["node", "server.js"]
|
||||||
80
apps/web/docker-compose.yml
Normal file
80
apps/web/docker-compose.yml
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
# Main website - Next.js standalone
|
||||||
|
website:
|
||||||
|
image: registry.infra.mintel.me/mintel/mintel.me:latest
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: docker/Dockerfile
|
||||||
|
args:
|
||||||
|
- NEXT_PUBLIC_ANALYTICS_PROVIDER=${NEXT_PUBLIC_ANALYTICS_PROVIDER}
|
||||||
|
- NEXT_PUBLIC_UMAMI_WEBSITE_ID=${NEXT_PUBLIC_UMAMI_WEBSITE_ID}
|
||||||
|
- NEXT_PUBLIC_UMAMI_HOST_URL=${NEXT_PUBLIC_UMAMI_HOST_URL}
|
||||||
|
- NEXT_PUBLIC_PLAUSIBLE_DOMAIN=${NEXT_PUBLIC_PLAUSIBLE_DOMAIN}
|
||||||
|
- NEXT_PUBLIC_PLAUSIBLE_SCRIPT_URL=${NEXT_PUBLIC_PLAUSIBLE_SCRIPT_URL}
|
||||||
|
- NEXT_PUBLIC_GLITCHTIP_DSN=${NEXT_PUBLIC_GLITCHTIP_DSN}
|
||||||
|
container_name: mintel-website
|
||||||
|
restart: unless-stopped
|
||||||
|
# Port 3000 is internal to the docker network, Caddy will proxy to it.
|
||||||
|
# We can expose it for debugging if needed, but it's safer to keep it internal.
|
||||||
|
expose:
|
||||||
|
- "3000"
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=production
|
||||||
|
- REDIS_URL=redis://redis:6379
|
||||||
|
- NEXT_PUBLIC_ANALYTICS_PROVIDER=${NEXT_PUBLIC_ANALYTICS_PROVIDER}
|
||||||
|
- NEXT_PUBLIC_UMAMI_WEBSITE_ID=${NEXT_PUBLIC_UMAMI_WEBSITE_ID}
|
||||||
|
- NEXT_PUBLIC_UMAMI_HOST_URL=${NEXT_PUBLIC_UMAMI_HOST_URL}
|
||||||
|
- NEXT_PUBLIC_PLAUSIBLE_DOMAIN=${NEXT_PUBLIC_PLAUSIBLE_DOMAIN}
|
||||||
|
- NEXT_PUBLIC_PLAUSIBLE_SCRIPT_URL=${NEXT_PUBLIC_PLAUSIBLE_SCRIPT_URL}
|
||||||
|
- NEXT_PUBLIC_GLITCHTIP_DSN=${NEXT_PUBLIC_GLITCHTIP_DSN}
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
networks:
|
||||||
|
- app-network
|
||||||
|
|
||||||
|
# Redis cache for performance
|
||||||
|
redis:
|
||||||
|
image: redis:7-alpine
|
||||||
|
container_name: mintel-redis
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- redis-data:/data
|
||||||
|
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
|
||||||
|
networks:
|
||||||
|
- app-network
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "redis-cli", "ping"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 3s
|
||||||
|
retries: 3
|
||||||
|
|
||||||
|
# Caddy reverse proxy with automatic SSL
|
||||||
|
caddy:
|
||||||
|
image: caddy:2-alpine
|
||||||
|
container_name: mintel-caddy
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
- "443:443"
|
||||||
|
volumes:
|
||||||
|
- ./docker/Caddyfile:/etc/caddy/Caddyfile
|
||||||
|
- caddy-data:/data
|
||||||
|
- caddy-config:/config
|
||||||
|
environment:
|
||||||
|
- DOMAIN=${DOMAIN:-localhost}
|
||||||
|
- EMAIL=${ADMIN_EMAIL:-admin@example.com}
|
||||||
|
depends_on:
|
||||||
|
- website
|
||||||
|
networks:
|
||||||
|
- app-network
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
redis-data:
|
||||||
|
caddy-data:
|
||||||
|
caddy-config:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
app-network:
|
||||||
|
driver: bridge
|
||||||
10
apps/web/eslint.config.js
Normal file
10
apps/web/eslint.config.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import mintelConfig from "@mintel/eslint-config/next";
|
||||||
|
|
||||||
|
export default [
|
||||||
|
...mintelConfig,
|
||||||
|
{
|
||||||
|
rules: {
|
||||||
|
"no-console": "warn",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
73
apps/web/package.json
Normal file
73
apps/web/package.json
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
{
|
||||||
|
"name": "@mintel/web",
|
||||||
|
"type": "module",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"description": "Technical problem solver's blog - practical insights and learning notes",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "next dev",
|
||||||
|
"build": "next build",
|
||||||
|
"start": "next start",
|
||||||
|
"lint": "next lint",
|
||||||
|
"test": "npm run test:smoke",
|
||||||
|
"test:smoke": "tsx ./scripts/smoke-test.ts",
|
||||||
|
"test:links": "tsx ./scripts/test-links.ts",
|
||||||
|
"test:file-examples": "tsx ./scripts/test-file-examples-comprehensive.ts",
|
||||||
|
"clone-website": "tsx ./scripts/clone-recursive.ts",
|
||||||
|
"clone-page": "tsx ./scripts/clone-page.ts",
|
||||||
|
"generate-estimate": "tsx ./scripts/generate-estimate.ts",
|
||||||
|
"ai-estimate": "tsx ./scripts/ai-estimate.ts",
|
||||||
|
"video:preview": "remotion preview video/index.ts",
|
||||||
|
"video:render": "remotion render video/index.ts ButtonShowcase out/button-showcase.mp4",
|
||||||
|
"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:all": "npm run video:render:contact && npm run video:render:button"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@mintel/next-utils": "^1.0.1",
|
||||||
|
"@react-pdf/renderer": "^4.3.2",
|
||||||
|
"@remotion/bundler": "^4.0.414",
|
||||||
|
"@remotion/cli": "^4.0.414",
|
||||||
|
"@remotion/lottie": "^4.0.414",
|
||||||
|
"@remotion/renderer": "^4.0.414",
|
||||||
|
"@remotion/tailwind": "^4.0.414",
|
||||||
|
"@types/canvas-confetti": "^1.9.0",
|
||||||
|
"@types/ioredis": "^4.28.10",
|
||||||
|
"@types/react": "^19.2.8",
|
||||||
|
"@types/react-dom": "^19.2.3",
|
||||||
|
"@vercel/og": "^0.8.6",
|
||||||
|
"axios": "^1.13.4",
|
||||||
|
"canvas-confetti": "^1.9.4",
|
||||||
|
"clsx": "^2.1.1",
|
||||||
|
"crawlee": "^3.15.3",
|
||||||
|
"framer-motion": "^12.29.2",
|
||||||
|
"ioredis": "^5.9.1",
|
||||||
|
"lucide-react": "^0.468.0",
|
||||||
|
"mermaid": "^11.12.2",
|
||||||
|
"next": "^16.1.6",
|
||||||
|
"playwright": "^1.58.1",
|
||||||
|
"prismjs": "^1.30.0",
|
||||||
|
"puppeteer": "^24.36.1",
|
||||||
|
"qrcode": "^1.5.4",
|
||||||
|
"react": "^19.2.3",
|
||||||
|
"react-dom": "^19.2.3",
|
||||||
|
"remotion": "^4.0.414",
|
||||||
|
"shiki": "^1.24.2",
|
||||||
|
"tailwind-merge": "^3.4.0",
|
||||||
|
"tailwindcss": "^3.4.0",
|
||||||
|
"website-scraper": "^6.0.0",
|
||||||
|
"website-scraper-puppeteer": "^2.0.0",
|
||||||
|
"zod": "3.22.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@mintel/eslint-config": "^1.0.1",
|
||||||
|
"@mintel/tsconfig": "^1.0.1",
|
||||||
|
"@tailwindcss/typography": "^0.5.15",
|
||||||
|
"@types/node": "^25.0.6",
|
||||||
|
"@types/prismjs": "^1.26.5",
|
||||||
|
"@types/qrcode": "^1.5.6",
|
||||||
|
"autoprefixer": "^10.4.20",
|
||||||
|
"postcss": "^8.4.49",
|
||||||
|
"tsx": "^4.21.0",
|
||||||
|
"typescript": "5.9.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 3.5 MiB After Width: | Height: | Size: 3.5 MiB |
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user