Skip to content

Commit f6459cd

Browse files
committed
Add TiUP Playground Docker image pre-build and caching
- Add make build-tiup-playground-image target to pre-build the image locally - Build image in CI prepare-dependencies job with Docker Buildx layer caching - Use GitHub Actions cache (gha) for Docker layer caching across runs - Image will be available for all TiDB test runs, avoiding rebuilds
1 parent c0c60ca commit f6459cd

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

.github/workflows/main.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,23 @@ jobs:
7575
- name: Vendor Go dependencies
7676
run: go mod vendor
7777

78+
- name: Set up Docker Buildx
79+
uses: docker/setup-buildx-action@v3
80+
81+
- name: Build and cache TiUP Playground Docker image
82+
uses: docker/build-push-action@v5
83+
with:
84+
context: .
85+
file: ./Dockerfile.tiup-playground
86+
tags: terraform-provider-mysql-tiup-playground:latest
87+
cache-from: type=gha
88+
cache-to: type=gha,mode=max
89+
push: false
90+
load: true
91+
7892
# Note: Tests now use testcontainers - no mysql-client or Docker Buildx caching needed
7993
# Testcontainers handles container lifecycle and image pulling automatically
94+
# TiUP Playground image is pre-built above with layer caching to speed up builds
8095

8196
- name: Upload Terraform binary
8297
uses: actions/upload-artifact@v4
@@ -172,8 +187,16 @@ jobs:
172187
- name: Make Terraform executable
173188
run: chmod +x bin/terraform
174189

175-
# Note: Docker Buildx not needed - testcontainers handles Docker directly
176-
# Skipping Buildx prevents unnecessary image pulls during initialization
190+
- name: Set up Docker Buildx
191+
uses: docker/setup-buildx-action@v3
192+
193+
- name: Load cached TiUP Playground Docker image
194+
run: |
195+
# Try to load from cache - if not available, testcontainers will build it
196+
docker images | grep terraform-provider-mysql-tiup-playground || echo "TiUP Playground image not found, will be built on-demand"
197+
198+
# Note: Docker Buildx is used for TiUP Playground image caching
199+
# Testcontainers handles container lifecycle and image pulling automatically
177200

178201
- name: Run testcontainers tests via Makefile
179202
env:

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ clean: ## Aggressively clear Docker cache and test artifacts
7474
@echo "Docker cache cleared. Note: For MySQL 5.6/5.7 and Percona on Apple Silicon,"
7575
@echo "you may need to restart Docker Desktop to fully clear manifest cache."
7676

77+
build-tiup-playground-image: ## Pre-build TiUP Playground Docker image for caching
78+
@echo "Building TiUP Playground Docker image..."
79+
@if [ ! -f Dockerfile.tiup-playground ]; then \
80+
echo "ERROR: Dockerfile.tiup-playground not found"; \
81+
exit 1; \
82+
fi
83+
@docker build -f Dockerfile.tiup-playground -t terraform-provider-mysql-tiup-playground:latest .
84+
@echo "✓ TiUP Playground image built successfully: terraform-provider-mysql-tiup-playground:latest"
85+
7786
test: testcontainers-matrix ## Run all acceptance tests
7887
test-sequential: acceptance
7988

0 commit comments

Comments
 (0)