Docker image pre-pull.
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
name: "Pre-pull or Build Docker images"
|
||||||
|
description: "Prepares all services for docker compose dry-run by pulling images or building them"
|
||||||
|
inputs:
|
||||||
|
services:
|
||||||
|
description: "Space-separated list of docker-compose services"
|
||||||
|
required: true
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Install yq (if missing)
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if ! command -v yq >/dev/null 2>&1; then
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Pre-pull/build images for services
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "Services to resolve: ${{ inputs.services }}"
|
||||||
|
for svc in ${{ inputs.services }}; do
|
||||||
|
echo "Resolving image for service: $svc"
|
||||||
|
image=$(docker compose config | yq -r ".services[\"$svc\"].image // empty")
|
||||||
|
build_dir=$(docker compose config | yq -r ".services[\"$svc\"].build.context // empty")
|
||||||
|
|
||||||
|
if [ -n "$image" ]; then
|
||||||
|
echo "Pulling image: $image"
|
||||||
|
docker pull "$image"
|
||||||
|
elif [ -n "$build_dir" ]; then
|
||||||
|
echo "Building image for service: $svc from context: $build_dir"
|
||||||
|
docker compose build "$svc"
|
||||||
|
else
|
||||||
|
echo "⚠️ No image or build context for $svc — skipping"
|
||||||
|
fi
|
||||||
|
done
|
||||||
@@ -160,10 +160,6 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
|
||||||
# - name: Login to Gitea Container Registry
|
|
||||||
# run: |
|
|
||||||
# docker login -u gitea-sonarqube-bot -p ${RINOA_REGISTRY_PASSWORD} git.trez.wtf
|
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
|
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
|
||||||
with:
|
with:
|
||||||
@@ -184,10 +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:
|
||||||
version: ${{ env.HC_VAULT_VERSION }}
|
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
|
||||||
@@ -197,24 +201,15 @@ 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 service images
|
- name: Pre-pull/build service images
|
||||||
run: |
|
uses: ./.gitea/actions/prepull-images
|
||||||
# Pull only the images needed for this dry run
|
with:
|
||||||
for svc in ${DOCKER_SVC_LIST}; do
|
services: ${{ env.DOCKER_SVC_LIST }}
|
||||||
echo "Resolving image for service: $svc"
|
|
||||||
image=$(docker compose config | yq -r ".services[\"$svc\"].image")
|
|
||||||
if [ -n "$image" ] && [ "$image" != "null" ]; then
|
|
||||||
echo "Pulling $image"
|
|
||||||
docker pull "$image"
|
|
||||||
else
|
|
||||||
echo "⚠️ No image defined for $svc (might be build-only)"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Docker Compose Dry Run
|
- name: Docker Compose Dry Run
|
||||||
uses: hoverkraft-tech/compose-action@b716db5b717cb9b81e391fe638e5aceaa2299e43 # v2.4.0
|
uses: hoverkraft-tech/compose-action@b716db5b717cb9b81e391fe638e5aceaa2299e43 # v2.4.0
|
||||||
|
|||||||
Reference in New Issue
Block a user