Skip to content

Commit e2f2597

Browse files
trevorgowingclaude
andcommitted
Mirror Metabase's release pipeline for Docker publishing
Build the uberjar outside Docker using GHA-level dep caching (M2 and node_modules), then package with the thin bin/docker/Dockerfile runner image. Caches are keyed on deps.edn and bun.lock hashes so they invalidate exactly when deps change rather than on every source file change, reducing warm-cache build time from ~90 to ~20-30 minutes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3113c72 commit e2f2597

2 files changed

Lines changed: 67 additions & 11 deletions

File tree

.github/workflows/teal-docker-publish.yml

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ jobs:
6767
fi
6868
fi
6969
70-
# ── Build the Docker image and push to GHCR ──
70+
# ── Build uberjar then package into the thin runner image ──
71+
# Mirrors Metabase's own release pipeline: build outside Docker with cached
72+
# deps, then copy the jar into bin/docker/Dockerfile (the thin runner image).
73+
# This gives reliable GHA-level dep caching rather than fragile Docker layer
74+
# caching that invalidates on any source file change.
7175

7276
build-and-push:
7377
name: Build and push to GHCR
@@ -90,8 +94,65 @@ jobs:
9094
echo "name=ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" \
9195
>> "$GITHUB_OUTPUT"
9296
93-
- name: Set up Docker Buildx
94-
uses: docker/setup-buildx-action@v4
97+
# ── Build environment ────────────────────────────────────────────────
98+
99+
- name: Set up Java 21
100+
uses: actions/setup-java@v4
101+
with:
102+
java-version: '21'
103+
distribution: 'temurin'
104+
105+
- name: Install Clojure CLI
106+
run: |
107+
curl --retry 3 --retry-delay 5 --fail \
108+
-O https://download.clojure.org/install/linux-install-1.12.0.1488.sh
109+
sudo bash ./linux-install-1.12.0.1488.sh
110+
111+
- name: Set up Node.js
112+
uses: actions/setup-node@v4
113+
with:
114+
node-version-file: '.nvmrc'
115+
116+
- name: Set up Bun
117+
uses: oven-sh/setup-bun@v2
118+
with:
119+
bun-version: '1.3.7'
120+
121+
# ── Dependency caching ───────────────────────────────────────────────
122+
# Keyed on lockfile hashes so the cache is invalidated exactly when deps
123+
# change — more precise than Metabase's weekly-rotation strategy.
124+
125+
- name: Cache Maven/Clojure dependencies
126+
uses: actions/cache@v4
127+
with:
128+
path: |
129+
~/.m2
130+
~/.gitlibs
131+
key: m2-${{ runner.os }}-${{ hashFiles('deps.edn') }}
132+
restore-keys: m2-${{ runner.os }}-
133+
134+
- name: Cache node_modules
135+
uses: actions/cache@v4
136+
with:
137+
path: node_modules
138+
key: node-modules-${{ runner.os }}-${{ hashFiles('bun.lock') }}
139+
restore-keys: node-modules-${{ runner.os }}-
140+
141+
- name: Install frontend dependencies
142+
run: bun install --frozen-lockfile
143+
144+
# ── Build ────────────────────────────────────────────────────────────
145+
146+
- name: Build uberjar
147+
env:
148+
MB_EDITION: oss
149+
INTERACTIVE: false
150+
run: ./bin/build.sh :version ${{ needs.resolve.outputs.version }}
151+
152+
# ── Package and publish ──────────────────────────────────────────────
153+
154+
- name: Move uberjar into Docker context
155+
run: mv target/uberjar/metabase.jar bin/docker/metabase.jar
95156

96157
- name: Log in to GHCR
97158
uses: docker/login-action@v4
@@ -103,16 +164,11 @@ jobs:
103164
- name: Build and push
104165
uses: docker/build-push-action@v7
105166
with:
106-
context: .
167+
context: bin/docker
107168
push: true
108-
build-args: |
109-
MB_EDITION=oss
110-
VERSION=${{ needs.resolve.outputs.version }}
111169
tags: |
112170
${{ steps.image.outputs.name }}:${{ needs.resolve.outputs.version }}
113171
${{ steps.image.outputs.name }}:latest
114-
cache-from: type=gha
115-
cache-to: type=gha,mode=max
116172
117173
- name: Summary
118174
run: |

README-TEAL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Merges the latest upstream release tag into this fork's `master` daily, keeping
7474

7575
### Docker Publishing — `teal-docker-publish.yml`
7676

77-
Builds the Metabase OSS image from the root `Dockerfile` and publishes it to the GitHub Container Registry (GHCR).
77+
Builds the Metabase OSS uberjar outside of Docker (mirroring Metabase's own release pipeline), then packages it into the thin `bin/docker/Dockerfile` runner image and publishes to the GitHub Container Registry (GHCR).
7878

7979
```bash
8080
docker pull ghcr.io/decode-development/metabase-teal:latest
@@ -86,4 +86,4 @@ docker pull ghcr.io/decode-development/metabase-teal:v0.61.2 # specific version
8686
- Merge of a `sync/upstream-*` PR into master (conflict-resolution path)
8787
- Manual dispatch — accepts an optional version tag, defaults to the current latest upstream release
8888

89-
> **Note:** The build compiles the full frontend and backend from source and takes approximately 60–90 minutes on a standard GitHub-hosted runner. Layer caching (`type=gha`) reduces this significantly on subsequent builds.
89+
**Caching:** Maven/Clojure (`~/.m2`) and Node (`node_modules`) dependencies are cached at the GitHub Actions level, keyed on `deps.edn` and `bun.lock` hashes. A warm cache reduces build time from ~90 minutes to ~20–30 minutes.

0 commit comments

Comments
 (0)