11# Main Rails Docker Image Build Workflows
22
3- Two GitHub Actions workflows for automatic building and publishing Main Rails image in multi-arch (ARM64, AMD64, and ARM/v7 ).
3+ Two GitHub Actions workflows for automatic building and publishing Main Rails image in multi-arch (ARM64 and AMD64 ).
44
55## 🎯 Key Feature: Flexible Base Image Selection
66
@@ -15,15 +15,24 @@ Main image can be built from **two different sources**:
1515
1616### 1. ` docker-main-image.yml ` - GHCR (GitHub Container Registry)
1717
18- ** Triggers:**
18+ ** Triggers (in priority order):**
19+
20+ 1 . ⏳ ** After Base Image Build** (` workflow_run ` )
21+
22+ - Waits for ` Build and Push Base Docker Image ` to complete successfully
23+ - Automatically starts building Main after Base is ready
24+ - Ensures Main uses fresh Base image
25+
26+ 2 . 🔄 ** Push to branch** (when Main or workflow files change)
1927
20- - 🔄 Push to ` main ` or ` master ` branches (if files in ` docker/IMAGES/ ` changed)
21- - 🔄 Pull Request to ` main ` or ` master ` branches
22- - ⚙️ Manual run (workflow_dispatch) - allows selecting base image source
28+ - Direct trigger if Base hasn't changed
29+
30+ 3 . ⚙️ ** Manual run** (workflow_dispatch)
31+ - Choose base image source manually
2332
2433** What it does:**
2534
26- - ✅ Builds image for ` linux/amd64 ` , ` linux/arm64 ` , and ` linux/arm/v7 `
35+ - ✅ Builds image for ` linux/amd64 ` and ` linux/arm64 `
2736- 📤 Pushes to GitHub Container Registry (ghcr.io)
2837- 💾 Caches layers to speed up future builds
2938- 🏷️ Automatically generates tags (branch, SHA, latest)
@@ -62,7 +71,7 @@ FROM ghcr.io/the-teacher/rails-start.main:latest
6271
6372** What it does:**
6473
65- - ✅ Builds image for ` linux/amd64 ` , ` linux/arm64 ` , and ` linux/arm/v7 `
74+ - ✅ Builds image for ` linux/amd64 ` and ` linux/arm64 `
6675- 📤 Pushes to Docker Hub
6776- 🔀 Allows choosing base image source (GHCR or Docker Hub)
6877
@@ -110,11 +119,10 @@ Uses `${{ secrets.GITHUB_TOKEN }}` - automatically available.
110119
111120## 🏗️ Supported Architectures
112121
113- | Architecture | Usage |
114- | ---------------- | -------------------------------------- |
115- | ** linux/amd64** | Intel/AMD 64-bit (desktops, servers) |
116- | ** linux/arm64** | ARM 64-bit (M1/M2 Mac, modern servers) |
117- | ** linux/arm/v7** | ARM 32-bit (Raspberry Pi, legacy ARM) |
122+ | Architecture | Usage |
123+ | --------------- | -------------------------------------- |
124+ | ** linux/amd64** | Intel/AMD 64-bit (desktops, servers) |
125+ | ** linux/arm64** | ARM 64-bit (M1/M2 Mac, modern servers) |
118126
119127---
120128
@@ -133,18 +141,50 @@ Uses `${{ secrets.GITHUB_TOKEN }}` - automatically available.
133141
134142## 🚀 Typical Workflow
135143
144+ ### Automatic Build Chain (Recommended)
145+
146+ ```
147+ 1. You push changes to docker/IMAGES/_Base.Dockerfile
148+ ↓
149+ 2. GitHub automatically triggers Base workflow
150+ ↓
151+ 3. Base image builds for arm64 + amd64
152+ ↓
153+ 4. Base image pushes to ghcr.io successfully
154+ ↓
155+ 5. Main workflow AUTOMATICALLY triggered (workflow_run)
156+ ↓
157+ 6. Main image builds using fresh Base image
158+ ↓
159+ 7. Main image pushes to ghcr.io
160+ ```
161+
162+ ** Result:** Main always uses the latest Base image! ✅
163+
136164### Development (GHCR)
137165
138166``` bash
139- # Improve Main Dockerfile
140- git commit -am " Add new tools to Main image"
167+ # Improve Base Dockerfile
168+ git commit -am " Add new tools to Base image"
141169git push origin master
142170
143- # → GHA automatically (using GHCR base):
144- # 1. Pulls ghcr.io/the-teacher/rails-start.base:latest
145- # 2. Builds image for arm64 + amd64 + arm/v7
146- # 3. Pushes to ghcr.io
147- # 4. Caches layers
171+ # → GHA automatically:
172+ # 1. Builds Base image for arm64 + amd64
173+ # 2. Pushes to ghcr.io
174+ # 3. Main workflow starts automatically
175+ # 4. Builds Main using new Base
176+ # 5. Pushes Main to ghcr.io
177+ ```
178+
179+ ### Manual Build with specific Base
180+
181+ ``` bash
182+ # If you want to rebuild Main with specific Base source:
183+ # 1. GitHub → Actions
184+ # 2. "Build and Push Main Docker Image"
185+ # 3. "Run workflow"
186+ # 4. Choose Base image source (ghcr or dockerhub)
187+ # 5. "Run workflow"
148188```
149189
150190### Release (Docker Hub)
0 commit comments