Skip to content

Commit 9215d77

Browse files
szachovyCopilot
andcommitted
Pre-pull container images during Terraform provisioning
Add docker pull commands in the Terraform provisioner for each node type. MySQL nodes pre-pull mysql-server, mgmt nodes pre-pull mysql-mgmt, superset-service, and redis. Pulls run in background with wait. Images are cached by the time ansible-playbook runs. Closes #46 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0ab8ce7 commit 9215d77

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
* Dependabot updates for `github-actions` and `terraform` ecosystems. (#29)
1616
* CI workflow to build and push service images to GitHub Container Registry on master merge. (#97)
1717
* Pull-first with local build fallback for container images during deployment. (#97)
18+
* Pre-pull container images during Terraform provisioning for faster startup. (#46)
1819

1920
### Changed
2021

tests/setup/main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ resource "docker_container" "nodes" {
118118
echo -e 'nameserver 8.8.8.8\nnameserver 8.8.4.4' >> /etc/resolv.conf && \
119119
usermod --append --groups docker superset && \
120120
chown --recursive superset:superset /opt/superset-testing"
121+
docker exec $HOSTNAME /bin/bash -c " \
122+
if [ $NODE_INDEX -ge 2 ]; then \
123+
docker pull ghcr.io/szachovy/superset-cluster-mysql-server:latest & \
124+
else \
125+
docker pull ghcr.io/szachovy/superset-cluster-mysql-mgmt:latest & \
126+
docker pull ghcr.io/szachovy/superset-cluster-superset-service:latest & \
127+
docker pull redis:latest & \
128+
fi; \
129+
wait" || true
121130
echo "Host $HOSTNAME
122131
Hostname $IP_ADDRESS
123132
StrictHostKeyChecking no
@@ -128,6 +137,7 @@ resource "docker_container" "nodes" {
128137
environment = {
129138
HOSTNAME = "${var.node_prefix}-${count.index}"
130139
IP_ADDRESS = cidrhost(var.subnet, 2 + count.index)
140+
NODE_INDEX = count.index
131141
}
132142
}
133143

0 commit comments

Comments
 (0)