Docker image pre-pull.
This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
name: "Pre-pull or Build Docker images"
|
name: "Pre-pull/build Docker images in parallel with timing"
|
||||||
description: "Prepares all services for docker compose dry-run by pulling images or building them"
|
description: "Prepares all services for docker compose dry-run by pulling or building them concurrently with logs"
|
||||||
inputs:
|
inputs:
|
||||||
services:
|
services:
|
||||||
description: "Space-separated list of docker-compose services"
|
description: "Space-separated list of docker-compose services"
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
@@ -12,26 +11,38 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if ! command -v yq >/dev/null 2>&1; then
|
if ! command -v yq >/dev/null 2>&1; then
|
||||||
|
echo "Installing yq..."
|
||||||
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.44.1/yq_linux_amd64
|
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.44.1/yq_linux_amd64
|
||||||
sudo chmod +x /usr/local/bin/yq
|
sudo chmod +x /usr/local/bin/yq
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Pre-pull/build images for services
|
- name: Pre-pull/build images in parallel
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "Services to resolve: ${{ inputs.services }}"
|
SERVICES="${{ inputs.services }}"
|
||||||
for svc in ${{ inputs.services }}; do
|
echo "Services to process: $SERVICES"
|
||||||
echo "Resolving image for service: $svc"
|
for svc in $SERVICES; do
|
||||||
image=$(docker compose config | yq -r ".services[\"$svc\"].image // empty")
|
(
|
||||||
build_dir=$(docker compose config | yq -r ".services[\"$svc\"].build.context // empty")
|
echo "🔹 Starting prep for service: $svc"
|
||||||
|
start_time=$(date +%s)
|
||||||
|
|
||||||
if [ -n "$image" ]; then
|
image=$(docker compose config | yq -r ".services[\"$svc\"].image // empty")
|
||||||
echo "Pulling image: $image"
|
build_dir=$(docker compose config | yq -r ".services[\"$svc\"].build.context // empty")
|
||||||
docker pull "$image"
|
|
||||||
elif [ -n "$build_dir" ]; then
|
if [ -n "$image" ]; then
|
||||||
echo "Building image for service: $svc from context: $build_dir"
|
echo "➡️ Pulling image: $image"
|
||||||
docker compose build "$svc"
|
docker pull "$image"
|
||||||
else
|
elif [ -n "$build_dir" ]; then
|
||||||
echo "⚠️ No image or build context for $svc — skipping"
|
echo "⚙️ Building service: $svc from context: $build_dir"
|
||||||
fi
|
docker compose build "$svc"
|
||||||
|
else
|
||||||
|
echo "⚠️ No image or build context found for $svc — skipping"
|
||||||
|
fi
|
||||||
|
|
||||||
|
end_time=$(date +%s)
|
||||||
|
duration=$((end_time - start_time))
|
||||||
|
echo "✅ Finished $svc in ${duration}s"
|
||||||
|
) &
|
||||||
done
|
done
|
||||||
|
wait
|
||||||
|
echo "🎯 All services processed."
|
||||||
|
|||||||
@@ -180,18 +180,18 @@ jobs:
|
|||||||
username: ${{ secrets.BOT_GITEA_USER }}
|
username: ${{ secrets.BOT_GITEA_USER }}
|
||||||
password: ${{ secrets.BOT_GITEA_PASSWORD }}
|
password: ${{ secrets.BOT_GITEA_PASSWORD }}
|
||||||
|
|
||||||
# - name: Install Vault (only if not cached)
|
- name: Install Vault (only if not cached)
|
||||||
# uses: cpanato/vault-installer@main
|
uses: cpanato/vault-installer@main
|
||||||
# with:
|
|
||||||
# version: ${{ env.HC_VAULT_VERSION }}
|
|
||||||
|
|
||||||
- name: Get env file
|
|
||||||
uses: Simporter/get-env-file-from-vault@v1.0.3
|
|
||||||
with:
|
with:
|
||||||
VAULT_ADDR: ${{ secrets.TREZ_VAULT_ADDR }}
|
version: ${{ env.HC_VAULT_VERSION }}
|
||||||
VAULT_USERNAME: ${{ secrets.VAULT_GITEA_USER }}
|
|
||||||
VAULT_PASSWORD: ${{ secrets.VAULT_GITEA_PASSWORD }}
|
# - name: Get env file
|
||||||
VAULT_SECRETS_PATH: rinoa-docker/env
|
# uses: Simporter/get-env-file-from-vault@v1.0.3
|
||||||
|
# with:
|
||||||
|
# VAULT_ADDR: ${{ secrets.TREZ_VAULT_ADDR }}
|
||||||
|
# VAULT_USERNAME: ${{ secrets.VAULT_GITEA_USER }}
|
||||||
|
# VAULT_PASSWORD: ${{ secrets.VAULT_GITEA_PASSWORD }}
|
||||||
|
# VAULT_SECRETS_PATH: rinoa-docker/env
|
||||||
|
|
||||||
- name: Gotify Notification
|
- name: Gotify Notification
|
||||||
uses: eikendev/gotify-action@master
|
uses: eikendev/gotify-action@master
|
||||||
@@ -201,13 +201,13 @@ jobs:
|
|||||||
notification_title: "GITEA: Docker Compose Dry Run @ Rinoa"
|
notification_title: "GITEA: Docker Compose Dry Run @ Rinoa"
|
||||||
notification_message: "Starting Docker Compose dry run..."
|
notification_message: "Starting Docker Compose dry run..."
|
||||||
|
|
||||||
# - name: Generate .env file for Docker Compose
|
- name: Generate .env file for Docker Compose
|
||||||
# run: |
|
run: |
|
||||||
# vault kv get -format=json rinoa-docker/env | jq -r '.data.data' | jq -r 'keys[] as $k | "\($k)='\''\(.[$k])'\''"' > .env
|
vault kv get -format=json rinoa-docker/env | jq -r '.data.data' | jq -r 'keys[] as $k | "\($k)='\''\(.[$k])'\''"' > .env
|
||||||
# echo ${DOCKER_SVC_LIST}
|
echo ${DOCKER_SVC_LIST}
|
||||||
|
|
||||||
- name: Pre-pull/build service images
|
- name: Pre-pull/build service images in parallel
|
||||||
uses: ./.gitea/actions/prepull-images
|
uses: ./.github/actions/docker-img-pre-pull
|
||||||
with:
|
with:
|
||||||
services: ${{ env.DOCKER_SVC_LIST }}
|
services: ${{ env.DOCKER_SVC_LIST }}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user