fix: unify Docker registry URLs to localhost:5000
Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Successful in 27s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Successful in 13s
🚀 Build & Deploy Image / Build Docker Image (push) Successful in 4m6s
Security Vulnerability Scan / Check for Dependency Changes (push) Successful in 27s
🚀 Build & Deploy Image / Run Tests & Quality Checks (push) Successful in 56s
Security Vulnerability Scan / Composer Security Audit (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Failing after 56s
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been skipped
Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Successful in 27s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Successful in 13s
🚀 Build & Deploy Image / Build Docker Image (push) Successful in 4m6s
Security Vulnerability Scan / Check for Dependency Changes (push) Successful in 27s
🚀 Build & Deploy Image / Run Tests & Quality Checks (push) Successful in 56s
Security Vulnerability Scan / Composer Security Audit (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Failing after 56s
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been skipped
- Change docker-compose.staging.yml: git.michaelschiemer.de:5000 -> localhost:5000 - Update deploy-image.yml playbook to: - Pull images from registry.michaelschiemer.de (source registry) - Tag and push to localhost:5000 (local registry) for local containers - Remove hardcoded git.michaelschiemer.de:5000 logic - Use local_registry from compose files for deployment This ensures: - Workflow pushes to registry.michaelschiemer.de (external, HTTPS) - Containers use localhost:5000 (local, faster, no HTTPS overhead) - Consistent registry usage across staging and production
This commit is contained in:
@@ -47,18 +47,26 @@
|
|||||||
grep -h "image:" docker-compose.base.yml docker-compose.{{ application_compose_suffix }} 2>/dev/null | \
|
grep -h "image:" docker-compose.base.yml docker-compose.{{ application_compose_suffix }} 2>/dev/null | \
|
||||||
grep -E "{{ app_name }}" | head -1 | \
|
grep -E "{{ app_name }}" | head -1 | \
|
||||||
sed -E 's/.*image:\s*([^\/]+).*/\1/' | \
|
sed -E 's/.*image:\s*([^\/]+).*/\1/' | \
|
||||||
sed -E 's/\/.*$//' || echo "{{ docker_registry }}"
|
sed -E 's/\/.*$//' || echo "localhost:5000"
|
||||||
register: compose_registry_url
|
register: compose_registry_url
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
|
||||||
- name: Set actual registry from compose file or use default
|
- name: Set local registry (where containers expect the image)
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
actual_registry: "{{ (compose_registry_url.stdout | trim) if (compose_registry_url.stdout | trim != '' and compose_registry_url.stdout | trim != docker_registry) else docker_registry }}"
|
local_registry: "{{ (compose_registry_url.stdout | trim) if (compose_registry_url.stdout | trim != '') else 'localhost:5000' }}"
|
||||||
|
|
||||||
- name: Set deploy_image from actual registry, app_name and tag
|
- name: Set source registry (where workflow pushes the image)
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
deploy_image: "{{ actual_registry }}/{{ app_name }}:{{ image_tag }}"
|
source_registry: "{{ docker_registry }}"
|
||||||
|
|
||||||
|
- name: Set deploy_image from source registry (for pulling)
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
deploy_image: "{{ source_registry }}/{{ app_name }}:{{ image_tag }}"
|
||||||
|
|
||||||
|
- name: Set local_image (where containers expect the image)
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
local_image: "{{ local_registry }}/{{ app_name }}:{{ image_tag }}"
|
||||||
|
|
||||||
- name: Set database and MinIO variables from vault or defaults
|
- name: Set database and MinIO variables from vault or defaults
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
@@ -135,10 +143,30 @@
|
|||||||
register: image_info
|
register: image_info
|
||||||
failed_when: image_info.failed | default(false)
|
failed_when: image_info.failed | default(false)
|
||||||
|
|
||||||
|
- name: Tag image for local registry (if source and local registry differ)
|
||||||
|
community.docker.docker_image:
|
||||||
|
name: "{{ deploy_image }}"
|
||||||
|
repository: "{{ local_image }}"
|
||||||
|
tag: "{{ image_tag }}"
|
||||||
|
source: local
|
||||||
|
when: source_registry != local_registry
|
||||||
|
register: image_tag_result
|
||||||
|
|
||||||
|
- name: Push image to local registry (if source and local registry differ)
|
||||||
|
community.docker.docker_image:
|
||||||
|
name: "{{ local_image }}"
|
||||||
|
push: true
|
||||||
|
source: local
|
||||||
|
when:
|
||||||
|
- source_registry != local_registry
|
||||||
|
- image_tag_result.changed | default(false)
|
||||||
|
ignore_errors: yes
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
- name: Update docker-compose file with new image tag
|
- name: Update docker-compose file with new image tag
|
||||||
ansible.builtin.replace:
|
ansible.builtin.replace:
|
||||||
path: "{{ application_code_dest }}/docker-compose.{{ application_compose_suffix }}"
|
path: "{{ application_code_dest }}/docker-compose.{{ application_compose_suffix }}"
|
||||||
regexp: '^(\s+image:\s+)({{ actual_registry }}/{{ app_name }}:)(.*)$'
|
regexp: '^(\s+image:\s+)({{ local_registry }}/{{ app_name }}:)(.*)$'
|
||||||
replace: '\1\2{{ image_tag }}'
|
replace: '\1\2{{ image_tag }}'
|
||||||
register: compose_update_result
|
register: compose_update_result
|
||||||
failed_when: false
|
failed_when: false
|
||||||
@@ -148,7 +176,7 @@
|
|||||||
ansible.builtin.replace:
|
ansible.builtin.replace:
|
||||||
path: "{{ application_code_dest }}/docker-compose.{{ application_compose_suffix }}"
|
path: "{{ application_code_dest }}/docker-compose.{{ application_compose_suffix }}"
|
||||||
regexp: '^(\s+image:\s+)([^\/]+\/{{ app_name }}:)(.*)$'
|
regexp: '^(\s+image:\s+)([^\/]+\/{{ app_name }}:)(.*)$'
|
||||||
replace: '\1{{ actual_registry }}/{{ app_name }}:{{ image_tag }}'
|
replace: '\1{{ local_registry }}/{{ app_name }}:{{ image_tag }}'
|
||||||
register: compose_update_alt
|
register: compose_update_alt
|
||||||
when: compose_update_result.changed == false
|
when: compose_update_result.changed == false
|
||||||
failed_when: false
|
failed_when: false
|
||||||
@@ -211,11 +239,9 @@
|
|||||||
set_fact:
|
set_fact:
|
||||||
insecure_registries_list: >-
|
insecure_registries_list: >-
|
||||||
{%- set existing = docker_daemon_config_dict.get('insecure-registries', []) | list -%}
|
{%- set existing = docker_daemon_config_dict.get('insecure-registries', []) | list -%}
|
||||||
{%- if 'git.michaelschiemer.de:5000' not in existing -%}
|
{%- set needed_registries = [local_registry] | list -%}
|
||||||
{{ existing + ['git.michaelschiemer.de:5000'] }}
|
{%- set all_registries = (existing + needed_registries) | unique | list -%}
|
||||||
{%- else -%}
|
{{ all_registries }}
|
||||||
{{ existing }}
|
|
||||||
{%- endif -%}
|
|
||||||
|
|
||||||
- name: Merge insecure registry into Docker daemon config
|
- name: Merge insecure registry into Docker daemon config
|
||||||
set_fact:
|
set_fact:
|
||||||
@@ -248,28 +274,13 @@
|
|||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Extract registry URLs with ports from docker-compose files
|
- name: Set list of registries to login to (source registry for pulling, local registry for pushing)
|
||||||
ansible.builtin.shell: |
|
|
||||||
cd {{ application_code_dest }}
|
|
||||||
grep -h "image:" docker-compose.base.yml docker-compose.{{ application_compose_suffix }} 2>/dev/null | \
|
|
||||||
sed -E 's/.*image:\s*([^\/]+).*/\1/' | \
|
|
||||||
sed -E 's/\/.*$//' | \
|
|
||||||
sort -u || echo ""
|
|
||||||
register: actual_registry_urls_full
|
|
||||||
changed_when: false
|
|
||||||
failed_when: false
|
|
||||||
|
|
||||||
- name: Set list of registries to login to (filter out service names, preserve ports)
|
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
registries_to_login: >-
|
registries_to_login: >-
|
||||||
{%- set found_registries = actual_registry_urls_full.stdout | trim | split('\n') | select('match', '.+') | list -%}
|
{%- set source_list = [source_registry] if source_registry != local_registry else [] -%}
|
||||||
{%- set filtered_registries = found_registries | select('match', '.*\.(de|com|org|net|io|dev)(:[0-9]+)?$|^[^:]+:[0-9]+$|^localhost(:[0-9]+)?$') | list -%}
|
{%- set local_list = [local_registry] -%}
|
||||||
{%- set default_registry = [docker_registry] -%}
|
{%- set all_registries = source_list + local_list -%}
|
||||||
{%- if filtered_registries | length > 0 -%}
|
{{ all_registries | unique | list }}
|
||||||
{{ filtered_registries | unique | list }}
|
|
||||||
{%- else -%}
|
|
||||||
{{ default_registry }}
|
|
||||||
{%- endif -%}
|
|
||||||
|
|
||||||
- name: Login to all Docker registries before compose up
|
- name: Login to all Docker registries before compose up
|
||||||
community.docker.docker_login:
|
community.docker.docker_login:
|
||||||
|
|||||||
@@ -11,11 +11,12 @@
|
|||||||
services:
|
services:
|
||||||
# PHP-FPM Application Runtime
|
# PHP-FPM Application Runtime
|
||||||
staging-app:
|
staging-app:
|
||||||
image: git.michaelschiemer.de:5000/framework:latest
|
image: localhost:5000/framework:latest
|
||||||
container_name: staging-app
|
container_name: staging-app
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
- staging-internal
|
- staging-internal
|
||||||
|
- postgres-staging-internal
|
||||||
environment:
|
environment:
|
||||||
- TZ=Europe/Berlin
|
- TZ=Europe/Berlin
|
||||||
- APP_ENV=staging
|
- APP_ENV=staging
|
||||||
@@ -28,8 +29,8 @@ services:
|
|||||||
- GIT_TOKEN=${GIT_TOKEN:-}
|
- GIT_TOKEN=${GIT_TOKEN:-}
|
||||||
- GIT_USERNAME=${GIT_USERNAME:-}
|
- GIT_USERNAME=${GIT_USERNAME:-}
|
||||||
- GIT_PASSWORD=${GIT_PASSWORD:-}
|
- GIT_PASSWORD=${GIT_PASSWORD:-}
|
||||||
# Database (can share with production or use separate)
|
# Database - using separate staging database
|
||||||
- DB_HOST=${DB_HOST:-postgres}
|
- DB_HOST=${DB_HOST:-postgres-staging}
|
||||||
- DB_PORT=${DB_PORT:-5432}
|
- DB_PORT=${DB_PORT:-5432}
|
||||||
- DB_DATABASE=${DB_DATABASE:-michaelschiemer_staging}
|
- DB_DATABASE=${DB_DATABASE:-michaelschiemer_staging}
|
||||||
- DB_USERNAME=${DB_USERNAME}
|
- DB_USERNAME=${DB_USERNAME}
|
||||||
@@ -208,7 +209,7 @@ services:
|
|||||||
condition: service_started
|
condition: service_started
|
||||||
# Nginx Web Server
|
# Nginx Web Server
|
||||||
staging-nginx:
|
staging-nginx:
|
||||||
image: git.michaelschiemer.de:5000/framework:latest
|
image: localhost:5000/framework:latest
|
||||||
container_name: staging-nginx
|
container_name: staging-nginx
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
@@ -344,17 +345,18 @@ services:
|
|||||||
|
|
||||||
# Queue Worker (Background Jobs)
|
# Queue Worker (Background Jobs)
|
||||||
staging-queue-worker:
|
staging-queue-worker:
|
||||||
image: git.michaelschiemer.de:5000/framework:latest
|
image: localhost:5000/framework:latest
|
||||||
container_name: staging-queue-worker
|
container_name: staging-queue-worker
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
- staging-internal
|
- staging-internal
|
||||||
|
- postgres-staging-internal
|
||||||
environment:
|
environment:
|
||||||
- TZ=Europe/Berlin
|
- TZ=Europe/Berlin
|
||||||
- APP_ENV=staging
|
- APP_ENV=staging
|
||||||
- APP_DEBUG=${APP_DEBUG:-true}
|
- APP_DEBUG=${APP_DEBUG:-true}
|
||||||
# Database (can share with production or use separate)
|
# Database - using separate staging database
|
||||||
- DB_HOST=${DB_HOST:-postgres}
|
- DB_HOST=${DB_HOST:-postgres-staging}
|
||||||
- DB_PORT=${DB_PORT:-5432}
|
- DB_PORT=${DB_PORT:-5432}
|
||||||
- DB_DATABASE=${DB_DATABASE:-michaelschiemer_staging}
|
- DB_DATABASE=${DB_DATABASE:-michaelschiemer_staging}
|
||||||
- DB_USERNAME=${DB_USERNAME}
|
- DB_USERNAME=${DB_USERNAME}
|
||||||
@@ -399,17 +401,18 @@ services:
|
|||||||
|
|
||||||
# Scheduler (Cron Jobs)
|
# Scheduler (Cron Jobs)
|
||||||
staging-scheduler:
|
staging-scheduler:
|
||||||
image: git.michaelschiemer.de:5000/framework:latest
|
image: localhost:5000/framework:latest
|
||||||
container_name: staging-scheduler
|
container_name: staging-scheduler
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
- staging-internal
|
- staging-internal
|
||||||
|
- postgres-staging-internal
|
||||||
environment:
|
environment:
|
||||||
- TZ=Europe/Berlin
|
- TZ=Europe/Berlin
|
||||||
- APP_ENV=staging
|
- APP_ENV=staging
|
||||||
- APP_DEBUG=${APP_DEBUG:-true}
|
- APP_DEBUG=${APP_DEBUG:-true}
|
||||||
# Database (can share with production or use separate)
|
# Database - using separate staging database
|
||||||
- DB_HOST=${DB_HOST:-postgres}
|
- DB_HOST=${DB_HOST:-postgres-staging}
|
||||||
- DB_PORT=${DB_PORT:-5432}
|
- DB_PORT=${DB_PORT:-5432}
|
||||||
- DB_DATABASE=${DB_DATABASE:-michaelschiemer_staging}
|
- DB_DATABASE=${DB_DATABASE:-michaelschiemer_staging}
|
||||||
- DB_USERNAME=${DB_USERNAME}
|
- DB_USERNAME=${DB_USERNAME}
|
||||||
@@ -471,6 +474,9 @@ networks:
|
|||||||
external: true
|
external: true
|
||||||
staging-internal:
|
staging-internal:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
postgres-staging-internal:
|
||||||
|
external: true
|
||||||
|
name: postgres-staging-internal
|
||||||
app-internal:
|
app-internal:
|
||||||
external: true
|
external: true
|
||||||
name: app-internal
|
name: app-internal
|
||||||
|
|||||||
Reference in New Issue
Block a user