Skip to content

Commit 323e035

Browse files
authored
feat(releases): tag releases to main with version numbers, speed up docker builds (#2337)
* feat(releases): tag releases to main with version numbers, speed up docker builds * resize runners
1 parent ffcaa65 commit 323e035

File tree

5 files changed

+133
-25
lines changed

5 files changed

+133
-25
lines changed

.dockerignore

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,67 @@
1+
# Git
2+
.git
3+
.gitignore
4+
5+
# Documentation
16
LICENSE
27
NOTICE
8+
README.md
9+
*.md
10+
docs/
11+
12+
# IDE and editor
13+
.vscode
14+
.idea
15+
*.swp
16+
*.swo
17+
18+
# Environment and config
19+
.env*
20+
!.env.example
321
.prettierrc
422
.prettierignore
5-
README.md
6-
.gitignore
7-
.husky
23+
.eslintrc*
24+
.eslintignore
25+
26+
# CI/CD and DevOps
827
.github
928
.devcontainer
10-
.env.example
11-
node_modules
29+
.husky
30+
docker-compose*.yml
31+
Dockerfile*
32+
33+
# Build artifacts and caches
34+
.next
35+
.turbo
36+
.cache
37+
dist
38+
build
39+
out
40+
coverage
41+
*.log
42+
43+
# Dependencies (will be installed fresh in container)
44+
node_modules
45+
.bun
46+
47+
# Test files
48+
**/*.test.ts
49+
**/*.test.tsx
50+
**/*.spec.ts
51+
**/*.spec.tsx
52+
__tests__
53+
__mocks__
54+
jest.config.*
55+
vitest.config.*
56+
57+
# TypeScript build info
58+
*.tsbuildinfo
59+
60+
# OS files
61+
.DS_Store
62+
Thumbs.db
63+
64+
# Temporary files
65+
tmp
66+
temp
67+
*.tmp

.github/workflows/ci.yml

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,35 @@ jobs:
1616
uses: ./.github/workflows/test-build.yml
1717
secrets: inherit
1818

19+
# Detect if this is a version release commit (e.g., "v0.5.24: ...")
20+
detect-version:
21+
name: Detect Version
22+
runs-on: blacksmith-4vcpu-ubuntu-2404
23+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging')
24+
outputs:
25+
version: ${{ steps.extract.outputs.version }}
26+
is_release: ${{ steps.extract.outputs.is_release }}
27+
steps:
28+
- name: Extract version from commit message
29+
id: extract
30+
run: |
31+
COMMIT_MSG="${{ github.event.head_commit.message }}"
32+
# Only tag versions on main branch
33+
if [ "${{ github.ref }}" = "refs/heads/main" ] && [[ "$COMMIT_MSG" =~ ^(v[0-9]+\.[0-9]+\.[0-9]+): ]]; then
34+
VERSION="${BASH_REMATCH[1]}"
35+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
36+
echo "is_release=true" >> $GITHUB_OUTPUT
37+
echo "✅ Detected release commit: ${VERSION}"
38+
else
39+
echo "version=" >> $GITHUB_OUTPUT
40+
echo "is_release=false" >> $GITHUB_OUTPUT
41+
echo "ℹ️ Not a release commit"
42+
fi
43+
1944
# Build AMD64 images and push to ECR immediately (+ GHCR for main)
2045
build-amd64:
2146
name: Build AMD64
22-
needs: test-build
47+
needs: [test-build, detect-version]
2348
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging')
2449
runs-on: blacksmith-8vcpu-ubuntu-2404
2550
permissions:
@@ -93,6 +118,14 @@ jobs:
93118
GHCR_AMD64="${GHCR_IMAGE}:latest-amd64"
94119
GHCR_SHA="${GHCR_IMAGE}:${{ github.sha }}-amd64"
95120
TAGS="${TAGS},$GHCR_AMD64,$GHCR_SHA"
121+
122+
# Add version tag if this is a release commit
123+
if [ "${{ needs.detect-version.outputs.is_release }}" = "true" ]; then
124+
VERSION="${{ needs.detect-version.outputs.version }}"
125+
GHCR_VERSION="${GHCR_IMAGE}:${VERSION}-amd64"
126+
TAGS="${TAGS},$GHCR_VERSION"
127+
echo "📦 Adding version tag: ${VERSION}-amd64"
128+
fi
96129
fi
97130
98131
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
@@ -111,7 +144,7 @@ jobs:
111144
# Build ARM64 images for GHCR (main branch only, runs in parallel)
112145
build-ghcr-arm64:
113146
name: Build ARM64 (GHCR Only)
114-
needs: test-build
147+
needs: [test-build, detect-version]
115148
runs-on: blacksmith-8vcpu-ubuntu-2404-arm
116149
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
117150
permissions:
@@ -146,7 +179,16 @@ jobs:
146179
id: meta
147180
run: |
148181
IMAGE="${{ matrix.image }}"
149-
echo "tags=${IMAGE}:latest-arm64,${IMAGE}:${{ github.sha }}-arm64" >> $GITHUB_OUTPUT
182+
TAGS="${IMAGE}:latest-arm64,${IMAGE}:${{ github.sha }}-arm64"
183+
184+
# Add version tag if this is a release commit
185+
if [ "${{ needs.detect-version.outputs.is_release }}" = "true" ]; then
186+
VERSION="${{ needs.detect-version.outputs.version }}"
187+
TAGS="${TAGS},${IMAGE}:${VERSION}-arm64"
188+
echo "📦 Adding version tag: ${VERSION}-arm64"
189+
fi
190+
191+
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
150192
151193
- name: Build and push ARM64 to GHCR
152194
uses: useblacksmith/build-push-action@v2
@@ -162,8 +204,8 @@ jobs:
162204
# Create GHCR multi-arch manifests (only for main, after both builds)
163205
create-ghcr-manifests:
164206
name: Create GHCR Manifests
165-
runs-on: blacksmith-8vcpu-ubuntu-2404
166-
needs: [build-amd64, build-ghcr-arm64]
207+
runs-on: blacksmith-2vcpu-ubuntu-2404
208+
needs: [build-amd64, build-ghcr-arm64, detect-version]
167209
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
168210
permissions:
169211
packages: write
@@ -198,6 +240,16 @@ jobs:
198240
"${IMAGE_BASE}:${{ github.sha }}-arm64"
199241
docker manifest push "${IMAGE_BASE}:${{ github.sha }}"
200242
243+
# Create version manifest if this is a release commit
244+
if [ "${{ needs.detect-version.outputs.is_release }}" = "true" ]; then
245+
VERSION="${{ needs.detect-version.outputs.version }}"
246+
echo "📦 Creating version manifest: ${VERSION}"
247+
docker manifest create "${IMAGE_BASE}:${VERSION}" \
248+
"${IMAGE_BASE}:${VERSION}-amd64" \
249+
"${IMAGE_BASE}:${VERSION}-arm64"
250+
docker manifest push "${IMAGE_BASE}:${VERSION}"
251+
fi
252+
201253
# Check if docs changed
202254
check-docs-changes:
203255
name: Check Docs Changes

docker/app.Dockerfile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@ FROM base AS deps
1010
RUN apk add --no-cache libc6-compat
1111
WORKDIR /app
1212

13-
# Install turbo globally (cached separately, changes infrequently)
14-
RUN bun install -g turbo
15-
1613
COPY package.json bun.lock turbo.json ./
1714
RUN mkdir -p apps packages/db
1815
COPY apps/sim/package.json ./apps/sim/package.json
1916
COPY packages/db/package.json ./packages/db/package.json
2017

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

2423
# ========================================
2524
# Builder Stage: Build the Application
2625
# ========================================
2726
FROM base AS builder
2827
WORKDIR /app
2928

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

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

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

5556
ENV NEXT_TELEMETRY_DISABLED=1 \
5657
VERCEL_TELEMETRY_DISABLED=1 \

docker/db.Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ COPY package.json bun.lock turbo.json ./
1414
RUN mkdir -p packages/db
1515
COPY packages/db/package.json ./packages/db/package.json
1616

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

2021
# ========================================
2122
# Runner Stage: Production Environment

docker/realtime.Dockerfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@ FROM base AS deps
1010
RUN apk add --no-cache libc6-compat
1111
WORKDIR /app
1212

13-
# Install turbo globally (cached separately, changes infrequently)
14-
RUN bun install -g turbo
15-
1613
COPY package.json bun.lock turbo.json ./
1714
RUN mkdir -p apps packages/db
1815
COPY apps/sim/package.json ./apps/sim/package.json
1916
COPY packages/db/package.json ./packages/db/package.json
2017

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

2422
# ========================================
2523
# Builder Stage: Prepare source code

0 commit comments

Comments
 (0)