Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 61 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,67 @@
# Git
.git
.gitignore

# Documentation
LICENSE
NOTICE
README.md
*.md
docs/

# IDE and editor
.vscode
.idea
*.swp
*.swo

# Environment and config
.env*
!.env.example
.prettierrc
.prettierignore
README.md
.gitignore
.husky
.eslintrc*
.eslintignore

# CI/CD and DevOps
.github
.devcontainer
.env.example
node_modules
.husky
docker-compose*.yml
Dockerfile*

# Build artifacts and caches
.next
.turbo
.cache
dist
build
out
coverage
*.log

# Dependencies (will be installed fresh in container)
node_modules
.bun

# Test files
**/*.test.ts
**/*.test.tsx
**/*.spec.ts
**/*.spec.tsx
__tests__
__mocks__
jest.config.*
vitest.config.*

# TypeScript build info
*.tsbuildinfo

# OS files
.DS_Store
Thumbs.db

# Temporary files
tmp
temp
*.tmp
62 changes: 57 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,35 @@ jobs:
uses: ./.github/workflows/test-build.yml
secrets: inherit

# Detect if this is a version release commit (e.g., "v0.5.24: ...")
detect-version:
name: Detect Version
runs-on: blacksmith-4vcpu-ubuntu-2404
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging')
outputs:
version: ${{ steps.extract.outputs.version }}
is_release: ${{ steps.extract.outputs.is_release }}
steps:
- name: Extract version from commit message
id: extract
run: |
COMMIT_MSG="${{ github.event.head_commit.message }}"
# Only tag versions on main branch
if [ "${{ github.ref }}" = "refs/heads/main" ] && [[ "$COMMIT_MSG" =~ ^(v[0-9]+\.[0-9]+\.[0-9]+): ]]; then
VERSION="${BASH_REMATCH[1]}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "is_release=true" >> $GITHUB_OUTPUT
echo "✅ Detected release commit: ${VERSION}"
else
echo "version=" >> $GITHUB_OUTPUT
echo "is_release=false" >> $GITHUB_OUTPUT
echo "ℹ️ Not a release commit"
fi

# Build AMD64 images and push to ECR immediately (+ GHCR for main)
build-amd64:
name: Build AMD64
needs: test-build
needs: [test-build, detect-version]
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging')
runs-on: blacksmith-8vcpu-ubuntu-2404
permissions:
Expand Down Expand Up @@ -93,6 +118,14 @@ jobs:
GHCR_AMD64="${GHCR_IMAGE}:latest-amd64"
GHCR_SHA="${GHCR_IMAGE}:${{ github.sha }}-amd64"
TAGS="${TAGS},$GHCR_AMD64,$GHCR_SHA"

# Add version tag if this is a release commit
if [ "${{ needs.detect-version.outputs.is_release }}" = "true" ]; then
VERSION="${{ needs.detect-version.outputs.version }}"
GHCR_VERSION="${GHCR_IMAGE}:${VERSION}-amd64"
TAGS="${TAGS},$GHCR_VERSION"
echo "📦 Adding version tag: ${VERSION}-amd64"
fi
fi

echo "tags=${TAGS}" >> $GITHUB_OUTPUT
Expand All @@ -111,7 +144,7 @@ jobs:
# Build ARM64 images for GHCR (main branch only, runs in parallel)
build-ghcr-arm64:
name: Build ARM64 (GHCR Only)
needs: test-build
needs: [test-build, detect-version]
runs-on: blacksmith-8vcpu-ubuntu-2404-arm
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
Expand Down Expand Up @@ -146,7 +179,16 @@ jobs:
id: meta
run: |
IMAGE="${{ matrix.image }}"
echo "tags=${IMAGE}:latest-arm64,${IMAGE}:${{ github.sha }}-arm64" >> $GITHUB_OUTPUT
TAGS="${IMAGE}:latest-arm64,${IMAGE}:${{ github.sha }}-arm64"

# Add version tag if this is a release commit
if [ "${{ needs.detect-version.outputs.is_release }}" = "true" ]; then
VERSION="${{ needs.detect-version.outputs.version }}"
TAGS="${TAGS},${IMAGE}:${VERSION}-arm64"
echo "📦 Adding version tag: ${VERSION}-arm64"
fi

echo "tags=${TAGS}" >> $GITHUB_OUTPUT

- name: Build and push ARM64 to GHCR
uses: useblacksmith/build-push-action@v2
Expand All @@ -162,8 +204,8 @@ jobs:
# Create GHCR multi-arch manifests (only for main, after both builds)
create-ghcr-manifests:
name: Create GHCR Manifests
runs-on: blacksmith-8vcpu-ubuntu-2404
needs: [build-amd64, build-ghcr-arm64]
runs-on: blacksmith-2vcpu-ubuntu-2404
needs: [build-amd64, build-ghcr-arm64, detect-version]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
packages: write
Expand Down Expand Up @@ -198,6 +240,16 @@ jobs:
"${IMAGE_BASE}:${{ github.sha }}-arm64"
docker manifest push "${IMAGE_BASE}:${{ github.sha }}"

# Create version manifest if this is a release commit
if [ "${{ needs.detect-version.outputs.is_release }}" = "true" ]; then
VERSION="${{ needs.detect-version.outputs.version }}"
echo "📦 Creating version manifest: ${VERSION}"
docker manifest create "${IMAGE_BASE}:${VERSION}" \
"${IMAGE_BASE}:${VERSION}-amd64" \
"${IMAGE_BASE}:${VERSION}-arm64"
docker manifest push "${IMAGE_BASE}:${VERSION}"
fi

# Check if docs changed
check-docs-changes:
name: Check Docs Changes
Expand Down
17 changes: 9 additions & 8 deletions docker/app.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app

# Install turbo globally (cached separately, changes infrequently)
RUN bun install -g turbo

COPY package.json bun.lock turbo.json ./
RUN mkdir -p apps packages/db
COPY apps/sim/package.json ./apps/sim/package.json
COPY packages/db/package.json ./packages/db/package.json

# Install dependencies (this layer will be cached if package files don't change)
RUN bun install --omit dev --ignore-scripts
# Install turbo globally and dependencies with cache mount for faster builds
RUN --mount=type=cache,id=bun-cache,target=/root/.bun/install/cache \
bun install -g turbo && \
bun install --frozen-lockfile --omit dev --ignore-scripts

# ========================================
# Builder Stage: Build the Application
# ========================================
FROM base AS builder
WORKDIR /app

# Install turbo globally (cached separately, changes infrequently)
RUN bun install -g turbo
# Install turbo globally (cached for fast reinstall)
RUN --mount=type=cache,id=bun-cache,target=/root/.bun/install/cache \
bun install -g turbo

# Copy node_modules from deps stage (cached if dependencies don't change)
COPY --from=deps /app/node_modules ./node_modules
Expand All @@ -50,7 +50,8 @@ COPY packages ./packages

# Required for standalone nextjs build
WORKDIR /app/apps/sim
RUN bun install sharp
RUN --mount=type=cache,id=bun-cache,target=/root/.bun/install/cache \
bun install sharp

ENV NEXT_TELEMETRY_DISABLED=1 \
VERCEL_TELEMETRY_DISABLED=1 \
Expand Down
5 changes: 3 additions & 2 deletions docker/db.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ COPY package.json bun.lock turbo.json ./
RUN mkdir -p packages/db
COPY packages/db/package.json ./packages/db/package.json

# Install dependencies (this layer will be cached if package files don't change)
RUN bun install --ignore-scripts
# Install dependencies with cache mount for faster builds
RUN --mount=type=cache,id=bun-cache,target=/root/.bun/install/cache \
bun install --frozen-lockfile --ignore-scripts

# ========================================
# Runner Stage: Production Environment
Expand Down
8 changes: 3 additions & 5 deletions docker/realtime.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app

# Install turbo globally (cached separately, changes infrequently)
RUN bun install -g turbo

COPY package.json bun.lock turbo.json ./
RUN mkdir -p apps packages/db
COPY apps/sim/package.json ./apps/sim/package.json
COPY packages/db/package.json ./packages/db/package.json

# Install dependencies (this layer will be cached if package files don't change)
RUN bun install --omit dev --ignore-scripts
# Install dependencies with cache mount for faster builds
RUN --mount=type=cache,id=bun-cache,target=/root/.bun/install/cache \
bun install --frozen-lockfile --omit dev --ignore-scripts

# ========================================
# Builder Stage: Prepare source code
Expand Down