Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 51409099fc | |||
| 22cd20e639 | |||
| e7cc1c8ca5 | |||
| 0ccb15a929 | |||
| a94ddcfbb2 | |||
| d3a9af140c | |||
| 0dc3ba0da4 | |||
| 1a94465dba | |||
| 7e256025ea | |||
| e843de42da | |||
| 4d1b2231e3 |
12
.dockerignore
Normal file
12
.dockerignore
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
node_modules
|
||||||
|
.next
|
||||||
|
.git
|
||||||
|
.npmrc
|
||||||
|
dist
|
||||||
|
build
|
||||||
|
out
|
||||||
|
coverage
|
||||||
|
.vercel
|
||||||
|
.turbo
|
||||||
|
*.log
|
||||||
|
.DS_Store
|
||||||
@@ -13,6 +13,8 @@ jobs:
|
|||||||
qa:
|
qa:
|
||||||
name: 🧪 Quality Assurance
|
name: 🧪 Quality Assurance
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -26,7 +28,6 @@ jobs:
|
|||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node_version: 20
|
node_version: 20
|
||||||
cache: 'pnpm'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --frozen-lockfile
|
run: pnpm install --frozen-lockfile
|
||||||
@@ -47,6 +48,8 @@ jobs:
|
|||||||
needs: qa
|
needs: qa
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
env:
|
env:
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -65,7 +68,6 @@ jobs:
|
|||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node_version: 20
|
node_version: 20
|
||||||
cache: 'pnpm'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --frozen-lockfile
|
run: pnpm install --frozen-lockfile
|
||||||
@@ -81,6 +83,8 @@ jobs:
|
|||||||
needs: qa
|
needs: qa
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -89,49 +93,64 @@ jobs:
|
|||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: 🔐 Registry Login
|
- name: 🔐 Registry Login
|
||||||
run: |
|
uses: docker/login-action@v3
|
||||||
echo "${{ secrets.REGISTRY_PASS }}" | docker login registry.infra.mintel.me -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
with:
|
||||||
|
registry: registry.infra.mintel.me
|
||||||
|
username: ${{ secrets.REGISTRY_USER }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASS }}
|
||||||
|
|
||||||
- name: 🏗️ Build & Push Nextjs Build-Base
|
- name: 🏗️ Build & Push Nextjs Build-Base
|
||||||
env:
|
uses: docker/build-push-action@v5
|
||||||
TAG: ${{ github.ref_name }}
|
with:
|
||||||
run: |
|
context: .
|
||||||
docker buildx build \
|
file: packages/infra/docker/Dockerfile.nextjs
|
||||||
--platform linux/amd64,linux/arm64 \
|
platforms: linux/arm64
|
||||||
-t registry.infra.mintel.me/mintel/nextjs:$TAG \
|
pull: true
|
||||||
-t registry.infra.mintel.me/mintel/nextjs:latest \
|
push: true
|
||||||
-f packages/infra/docker/Dockerfile.nextjs \
|
secrets: |
|
||||||
--push .
|
NPM_TOKEN=${{ secrets.NPM_TOKEN }}
|
||||||
|
tags: |
|
||||||
|
registry.infra.mintel.me/mintel/nextjs:${{ github.ref_name }}
|
||||||
|
registry.infra.mintel.me/mintel/nextjs:latest
|
||||||
|
|
||||||
- name: 🏗️ Build & Push Production Runtime
|
- name: 🏗️ Build & Push Production Runtime
|
||||||
env:
|
uses: docker/build-push-action@v5
|
||||||
TAG: ${{ github.ref_name }}
|
with:
|
||||||
run: |
|
context: .
|
||||||
docker buildx build \
|
file: packages/infra/docker/Dockerfile.runtime
|
||||||
--platform linux/amd64,linux/arm64 \
|
platforms: linux/arm64
|
||||||
-t registry.infra.mintel.me/mintel/runtime:$TAG \
|
pull: true
|
||||||
-t registry.infra.mintel.me/mintel/runtime:latest \
|
push: true
|
||||||
-f packages/infra/docker/Dockerfile.runtime \
|
secrets: |
|
||||||
--push .
|
NPM_TOKEN=${{ secrets.NPM_TOKEN }}
|
||||||
|
tags: |
|
||||||
|
registry.infra.mintel.me/mintel/runtime:${{ github.ref_name }}
|
||||||
|
registry.infra.mintel.me/mintel/runtime:latest
|
||||||
|
|
||||||
- name: 🏗️ Build & Push Gatekeeper (Product)
|
- name: 🏗️ Build & Push Gatekeeper (Product)
|
||||||
env:
|
uses: docker/build-push-action@v5
|
||||||
TAG: ${{ github.ref_name }}
|
with:
|
||||||
run: |
|
context: .
|
||||||
docker buildx build \
|
file: packages/infra/docker/Dockerfile.gatekeeper
|
||||||
--platform linux/amd64,linux/arm64 \
|
platforms: linux/arm64
|
||||||
-t registry.infra.mintel.me/mintel/gatekeeper:$TAG \
|
pull: true
|
||||||
-t registry.infra.mintel.me/mintel/gatekeeper:latest \
|
push: true
|
||||||
-f packages/infra/docker/Dockerfile.gatekeeper \
|
secrets: |
|
||||||
--push .
|
NPM_TOKEN=${{ secrets.NPM_TOKEN }}
|
||||||
|
tags: |
|
||||||
|
registry.infra.mintel.me/mintel/gatekeeper:${{ github.ref_name }}
|
||||||
|
registry.infra.mintel.me/mintel/gatekeeper:latest
|
||||||
|
|
||||||
- name: 🏗️ Build & Push Directus (Base)
|
- name: 🏗️ Build & Push Directus (Base)
|
||||||
env:
|
uses: docker/build-push-action@v5
|
||||||
TAG: ${{ github.ref_name }}
|
with:
|
||||||
run: |
|
context: .
|
||||||
docker buildx build \
|
file: packages/infra/docker/Dockerfile.directus
|
||||||
--platform linux/amd64,linux/arm64 \
|
platforms: linux/arm64
|
||||||
-t registry.infra.mintel.me/mintel/directus:$TAG \
|
pull: true
|
||||||
-t registry.infra.mintel.me/mintel/directus:latest \
|
push: true
|
||||||
-f packages/infra/docker/Dockerfile.directus \
|
secrets: |
|
||||||
--push .
|
NPM_TOKEN=${{ secrets.NPM_TOKEN }}
|
||||||
|
tags: |
|
||||||
|
registry.infra.mintel.me/mintel/directus:${{ github.ref_name }}
|
||||||
|
registry.infra.mintel.me/mintel/directus:latest
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const config = {
|
const config = {
|
||||||
extends: ["@commitlint/config-conventional"],
|
extends: ["@commitlint/config-conventional"],
|
||||||
rules: {
|
rules: {
|
||||||
"header-max-length": [2, "always", 150],
|
"header-max-length": [2, "always", 250],
|
||||||
"subject-case": [0],
|
"subject-case": [0],
|
||||||
"subject-full-stop": [0],
|
"subject-full-stop": [0],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,30 +1,24 @@
|
|||||||
FROM node:20-alpine AS base
|
# Step 1: Builder stage
|
||||||
|
FROM node:20-alpine AS builder
|
||||||
RUN apk add --no-cache libc6-compat curl
|
RUN apk add --no-cache libc6-compat curl
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Enable pnpm
|
|
||||||
RUN corepack enable pnpm
|
RUN corepack enable pnpm
|
||||||
|
|
||||||
# Install dependencies (using monorepo root context)
|
# Copy source (honoring .dockerignore)
|
||||||
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json .npmrc* ./
|
|
||||||
COPY packages/gatekeeper/package.json ./packages/gatekeeper/
|
|
||||||
COPY packages/next-utils/package.json ./packages/next-utils/
|
|
||||||
COPY packages/tsconfig/package.json ./packages/tsconfig/
|
|
||||||
COPY packages/eslint-config/package.json ./packages/eslint-config/
|
|
||||||
COPY packages/next-config/package.json ./packages/next-config/
|
|
||||||
|
|
||||||
RUN --mount=type=cache,target=/root/.local/share/pnpm/store/v3 \
|
|
||||||
pnpm i --frozen-lockfile
|
|
||||||
|
|
||||||
# Copy source
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build Gatekeeper
|
# Use a secret for NPM_TOKEN to authenticate with private registry
|
||||||
RUN pnpm --filter @mintel/gatekeeper build
|
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 i --frozen-lockfile
|
||||||
|
|
||||||
# Runner
|
# Build Gatekeeper and its dependencies
|
||||||
FROM base AS runner
|
RUN pnpm --filter @mintel/gatekeeper... build
|
||||||
|
|
||||||
|
# Step 2: Runner stage
|
||||||
|
FROM node:20-alpine AS runner
|
||||||
|
RUN apk add --no-cache libc6-compat curl
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
RUN addgroup --system --gid 1001 nodejs
|
RUN addgroup --system --gid 1001 nodejs
|
||||||
|
|||||||
@@ -1,24 +1,19 @@
|
|||||||
FROM node:20-alpine AS base
|
# Step 1: Builder image
|
||||||
|
FROM node:20-alpine AS builder
|
||||||
RUN apk add --no-cache libc6-compat curl
|
RUN apk add --no-cache libc6-compat curl
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Enable pnpm
|
|
||||||
RUN corepack enable pnpm
|
RUN corepack enable pnpm
|
||||||
|
|
||||||
# Copy root configurations
|
# Step 2: Install dependencies
|
||||||
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json .npmrc* ./
|
# We copy everything first because we have a .dockerignore
|
||||||
|
# and we need the workspace structure for pnpm to work correctly
|
||||||
# Copy all package.json files to allow pnpm install to be cached
|
|
||||||
COPY packages/*/package.json ./packages/
|
|
||||||
COPY apps/*/package.json ./apps/
|
|
||||||
|
|
||||||
# Install dependencies for the entire monorepo
|
|
||||||
RUN --mount=type=cache,target=/root/.local/share/pnpm/store/v3 \
|
|
||||||
pnpm i --frozen-lockfile
|
|
||||||
|
|
||||||
# Copy the rest of the source code
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Post-install/Build shared packages if needed
|
# Use a secret for NPM_TOKEN to authenticate with private registry
|
||||||
RUN pnpm -r build --filter="./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 i --frozen-lockfile
|
||||||
|
|
||||||
|
# Step 3: Build shared packages
|
||||||
|
RUN pnpm --filter "./packages/*" -r build
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ jobs:
|
|||||||
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 }}
|
||||||
@@ -136,6 +138,8 @@ jobs:
|
|||||||
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:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -144,7 +148,6 @@ jobs:
|
|||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 20
|
||||||
cache: 'npm'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
@@ -171,6 +174,8 @@ jobs:
|
|||||||
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:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -179,23 +184,28 @@ jobs:
|
|||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: 🔐 Registry Login
|
- name: 🔐 Registry Login
|
||||||
run: |
|
uses: docker/login-action@v3
|
||||||
echo "${{ secrets.REGISTRY_PASS }}" | docker login registry.infra.mintel.me -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
with:
|
||||||
|
registry: registry.infra.mintel.me
|
||||||
|
username: ${{ secrets.REGISTRY_USER }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASS }}
|
||||||
|
|
||||||
- name: 🏗️ Docker Build & Push
|
- name: 🏗️ Docker Build & Push
|
||||||
env:
|
uses: docker/build-push-action@v5
|
||||||
IMAGE_TAG: ${{ needs.prepare.outputs.image_tag }}
|
with:
|
||||||
NEXT_PUBLIC_BASE_URL: ${{ needs.prepare.outputs.next_public_base_url }}
|
context: .
|
||||||
run: |
|
file: packages/infra/docker/Dockerfile.nextjs
|
||||||
docker buildx build \
|
platforms: linux/arm64
|
||||||
--pull \
|
pull: true
|
||||||
--platform linux/arm64 \
|
build-args: |
|
||||||
--build-arg NEXT_PUBLIC_BASE_URL="$NEXT_PUBLIC_BASE_URL" \
|
NEXT_PUBLIC_BASE_URL=${{ needs.prepare.outputs.next_public_base_url }}
|
||||||
--build-arg NEXT_PUBLIC_TARGET="${{ needs.prepare.outputs.target }}" \
|
NEXT_PUBLIC_TARGET=${{ needs.prepare.outputs.target }}
|
||||||
-t registry.infra.mintel.me/mintel/${{ github.event.repository.name }}:$IMAGE_TAG \
|
push: true
|
||||||
--cache-from type=registry,ref=registry.infra.mintel.me/mintel/${{ github.event.repository.name }}:buildcache \
|
secrets: |
|
||||||
--cache-to type=registry,ref=registry.infra.mintel.me/mintel/${{ github.event.repository.name }}:buildcache,mode=max \
|
NPM_TOKEN=${{ secrets.NPM_TOKEN }}
|
||||||
--push .
|
tags: registry.infra.mintel.me/mintel/${{ github.event.repository.name }}:${{ needs.prepare.outputs.image_tag }}
|
||||||
|
cache-from: type=registry,ref=registry.infra.mintel.me/mintel/${{ github.event.repository.name }}:buildcache
|
||||||
|
cache-to: type=registry,ref=registry.infra.mintel.me/mintel/${{ github.event.repository.name }}:buildcache,mode=max
|
||||||
|
|
||||||
# ──────────────────────────────────────────────────────────────────────────────
|
# ──────────────────────────────────────────────────────────────────────────────
|
||||||
# JOB 4: Deploy
|
# JOB 4: Deploy
|
||||||
@@ -205,6 +215,8 @@ jobs:
|
|||||||
needs: [prepare, build, qa]
|
needs: [prepare, build, qa]
|
||||||
if: needs.prepare.outputs.target != 'skip'
|
if: needs.prepare.outputs.target != 'skip'
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
env:
|
env:
|
||||||
TARGET: ${{ needs.prepare.outputs.target }}
|
TARGET: ${{ needs.prepare.outputs.target }}
|
||||||
IMAGE_TAG: ${{ needs.prepare.outputs.image_tag }}
|
IMAGE_TAG: ${{ needs.prepare.outputs.image_tag }}
|
||||||
@@ -271,6 +283,8 @@ jobs:
|
|||||||
needs: [prepare, deploy]
|
needs: [prepare, deploy]
|
||||||
if: always()
|
if: always()
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
steps:
|
steps:
|
||||||
- name: 🔔 Gotify - Success
|
- name: 🔔 Gotify - Success
|
||||||
if: needs.deploy.result == 'success'
|
if: needs.deploy.result == 'success'
|
||||||
|
|||||||
60
packages/infra/scripts/prune-registry.sh
Normal file
60
packages/infra/scripts/prune-registry.sh
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
REGISTRY_DATA="/opt/infra/registry/data/docker/registry/v2"
|
||||||
|
KEEP_TAGS=3
|
||||||
|
|
||||||
|
echo "🏥 Starting Aggressive Registry & Docker Maintenance..."
|
||||||
|
|
||||||
|
# 1. Prune Registry Tags (Filesystem level)
|
||||||
|
for repo_dir in "$REGISTRY_DATA/repositories/mintel/"*; do
|
||||||
|
repo_name=$(basename "$repo_dir")
|
||||||
|
tags_dir="$repo_dir/_manifests/tags"
|
||||||
|
|
||||||
|
if [ -d "$tags_dir" ]; then
|
||||||
|
echo "🔍 Processing repository: mintel/$repo_name"
|
||||||
|
|
||||||
|
# Prune main-* tags
|
||||||
|
echo " 📦 Pruning main tags..."
|
||||||
|
main_tags=$(ls -dt "$tags_dir"/main-* 2>/dev/null || true)
|
||||||
|
count=0
|
||||||
|
for tag_path in $main_tags; do
|
||||||
|
((++count))
|
||||||
|
if [ $count -gt $KEEP_TAGS ]; then
|
||||||
|
echo " 🗑️ Deleting old main tag: $(basename "$tag_path")"
|
||||||
|
rm -rf "$tag_path"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Prune version tags (v* and rc*)
|
||||||
|
echo " 🏷️ Pruning version tags..."
|
||||||
|
version_tags=$(ls -dt "$tags_dir"/v1* 2>/dev/null || true)
|
||||||
|
count=0
|
||||||
|
for tag_path in $version_tags; do
|
||||||
|
((++count))
|
||||||
|
if [ $count -gt $KEEP_TAGS ]; then
|
||||||
|
echo " 🗑️ Deleting old version tag: $(basename "$tag_path")"
|
||||||
|
rm -rf "$tag_path"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Always prune buildcache (as it rebuilds quickly)
|
||||||
|
if [ -d "$tags_dir/buildcache" ]; then
|
||||||
|
echo " 🧹 Deleting buildcache tag"
|
||||||
|
rm -rf "$tags_dir/buildcache"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# 2. Run Garbage Collection
|
||||||
|
echo "♻️ Running Registry Garbage Collection..."
|
||||||
|
docker exec registry-registry-1 bin/registry garbage-collect /etc/docker/registry/config.yml
|
||||||
|
|
||||||
|
# 3. Prune Host Docker resources (Shorter window: 24h)
|
||||||
|
echo "🧹 Pruning Host Docker resources..."
|
||||||
|
docker system prune -af --filter "until=24h"
|
||||||
|
docker volume prune -f
|
||||||
|
|
||||||
|
echo "✅ Maintenance complete!"
|
||||||
|
df -h /
|
||||||
Reference in New Issue
Block a user