Refactor: unify Docker build config via build.yml.j2 include

Replaced duplicated inline build definitions in multiple docker-compose.yml.j2
templates with a shared include (roles/docker-container/templates/build.yml.j2).
This ensures consistent use of pull_policy: never and Dockerfile context across
services (Postgres, Bookwyrm, Bridgy Fed, Chess, Confluence, Jira, Moodle,
OpenProject, Pretix, Roulette Wheel, WordPress, XWiki, Simpleicons).

Conversation: https://chatgpt.com/share/68cd8f35-b764-800f-9b00-2c837103d2fb
This commit is contained in:
2025-09-19 19:13:44 +02:00
parent 96ded68ef4
commit a4a8061998
14 changed files with 20 additions and 43 deletions

View File

@@ -0,0 +1,6 @@
{# integrate it into service sections to be build by Dockerfile #}
pull_policy: never
build:
context: .
dockerfile: Dockerfile
{# pass Arguments here #}

View File

@@ -3,10 +3,7 @@
postgres: postgres:
container_name: "{{ POSTGRES_CONTAINER }}" container_name: "{{ POSTGRES_CONTAINER }}"
image: "{{ POSTGRES_CUSTOM_IMAGE_NAME }}" image: "{{ POSTGRES_CUSTOM_IMAGE_NAME }}"
build: {% include 'roles/docker-container/templates/build.yml.j2' %}
context: .
dockerfile: Dockerfile
pull_policy: never
command: command:
- "postgres" - "postgres"
- "-c" - "-c"

View File

@@ -9,9 +9,7 @@
(python manage.py initdb || true) && (python manage.py initdb || true) &&
python -m gunicorn bookwyrm.wsgi:application --bind 0.0.0.0:{{ container_port }} python -m gunicorn bookwyrm.wsgi:application --bind 0.0.0.0:{{ container_port }}
' '
build: {% include 'roles/docker-container/templates/build.yml.j2' %}
context: .
dockerfile: Dockerfile
image: "{{ BOOKWYRM_CUSTOM_IMAGE }}" image: "{{ BOOKWYRM_CUSTOM_IMAGE }}"
container_name: "{{ BOOKWYRM_CONTAINER }}" container_name: "{{ BOOKWYRM_CONTAINER }}"
hostname: "{{ BOOKWYRM_HOSTNAME }}" hostname: "{{ BOOKWYRM_HOSTNAME }}"

View File

@@ -1,9 +1,7 @@
{% include 'roles/docker-compose/templates/base.yml.j2' %} {% include 'roles/docker-compose/templates/base.yml.j2' %}
application: application:
build: {% include 'roles/docker-container/templates/build.yml.j2' %}
context: .
dockerfile: Dockerfile
args: args:
BRIDGY_REPO_URL: "{{ BRIDGY_REPO_URL }}" BRIDGY_REPO_URL: "{{ BRIDGY_REPO_URL }}"
BRIDGY_REPO_BRANCH: "{{ BRIDGY_REPO_BRANCH }}" BRIDGY_REPO_BRANCH: "{{ BRIDGY_REPO_BRANCH }}"

View File

@@ -1,8 +1,6 @@
{% include 'roles/docker-compose/templates/base.yml.j2' %} {% include 'roles/docker-compose/templates/base.yml.j2' %}
application: application:
build: {% include 'roles/docker-container/templates/build.yml.j2' %}
context: .
dockerfile: Dockerfile
args: args:
CHESS_VERSION: "{{ CHESS_VERSION }}" CHESS_VERSION: "{{ CHESS_VERSION }}"
CHESS_REPO_URL: "{{ CHESS_REPO_URL }}" CHESS_REPO_URL: "{{ CHESS_REPO_URL }}"

View File

@@ -1,8 +1,6 @@
{% include 'roles/docker-compose/templates/base.yml.j2' %} {% include 'roles/docker-compose/templates/base.yml.j2' %}
application: application:
build: {% include 'roles/docker-container/templates/build.yml.j2' %}
context: .
dockerfile: Dockerfile
image: "{{ CONFLUENCE_CUSTOM_IMAGE }}" image: "{{ CONFLUENCE_CUSTOM_IMAGE }}"
container_name: "{{ CONFLUENCE_CONTAINER }}" container_name: "{{ CONFLUENCE_CONTAINER }}"
hostname: '{{ CONFLUENCE_HOSTNAME}}' hostname: '{{ CONFLUENCE_HOSTNAME}}'

View File

@@ -1,9 +1,7 @@
{% include 'roles/docker-compose/templates/base.yml.j2' %} {% include 'roles/docker-compose/templates/base.yml.j2' %}
application: application:
build: {% include 'roles/docker-container/templates/build.yml.j2' %}
context: .
dockerfile: Dockerfile
image: "{{ JIRA_CUSTOM_IMAGE }}" image: "{{ JIRA_CUSTOM_IMAGE }}"
container_name: "{{ JIRA_CONTAINER }}" container_name: "{{ JIRA_CONTAINER }}"
hostname: '{{ JIRA_HOSTNAME }}' hostname: '{{ JIRA_HOSTNAME }}'

View File

@@ -3,10 +3,7 @@
moodle: moodle:
{% set container_port = 8080 %} {% set container_port = 8080 %}
container_name: {{ moodle_container }} container_name: {{ moodle_container }}
build: {% include 'roles/docker-container/templates/build.yml.j2' %}
context: .
dockerfile: Dockerfile
pull_policy: never
image: moodle_custom image: moodle_custom
ports: ports:
- 127.0.0.1:{{ ports.localhost.http[application_id] }}:{{ container_port }} - 127.0.0.1:{{ ports.localhost.http[application_id] }}:{{ container_port }}

View File

@@ -3,10 +3,7 @@ x-op-app: &app
logging: logging:
driver: journald driver: journald
image: {{ openproject_custom_image }} image: {{ openproject_custom_image }}
build: {% include 'roles/docker-container/templates/build.yml.j2' %}
context: .
dockerfile: Dockerfile
pull_policy: never
{% include 'roles/docker-compose/templates/base.yml.j2' %} {% include 'roles/docker-compose/templates/base.yml.j2' %}
@@ -19,6 +16,7 @@ x-op-app: &app
{% include 'roles/docker-container/templates/base.yml.j2' %} {% include 'roles/docker-container/templates/base.yml.j2' %}
image: {{ openproject_custom_image }} image: {{ openproject_custom_image }}
container_name: {{ openproject_proxy_name }} container_name: {{ openproject_proxy_name }}
pull_policy: never
command: "./docker/prod/proxy" command: "./docker/prod/proxy"
ports: ports:
- "127.0.0.1:{{ ports.localhost.http[application_id] }}:80" - "127.0.0.1:{{ ports.localhost.http[application_id] }}:80"

View File

@@ -1,8 +1,6 @@
{% include 'roles/docker-compose/templates/base.yml.j2' %} {% include 'roles/docker-compose/templates/base.yml.j2' %}
application: application:
build: {% include 'roles/docker-container/templates/build.yml.j2' %}
context: .
dockerfile: Dockerfile
image: "{{ PRETIX_IMAGE_CUSTOM }}" image: "{{ PRETIX_IMAGE_CUSTOM }}"
container_name: "{{ PRETIX_CONTAINER }}" container_name: "{{ PRETIX_CONTAINER }}"
hostname: '{{ PRETIX_HOSTNAME}}' hostname: '{{ PRETIX_HOSTNAME}}'

View File

@@ -1,9 +1,7 @@
{% include 'roles/docker-compose/templates/base.yml.j2' %} {% include 'roles/docker-compose/templates/base.yml.j2' %}
application: application:
container_name: roulette_application container_name: roulette_application
build: {% include 'roles/docker-container/templates/build.yml.j2' %}
context: .
pull_policy: never
ports: ports:
- 127.0.0.1:{{ ports.localhost.http[application_id] }}:8080 - 127.0.0.1:{{ ports.localhost.http[application_id] }}:8080
restart: {{ DOCKER_RESTART_POLICY }} restart: {{ DOCKER_RESTART_POLICY }}

View File

@@ -3,9 +3,7 @@
{% include 'roles/docker-container/templates/base.yml.j2' %} {% include 'roles/docker-container/templates/base.yml.j2' %}
image: {{ WORDPRESS_CUSTOM_IMAGE }} image: {{ WORDPRESS_CUSTOM_IMAGE }}
container_name: {{ WORDPRESS_CONTAINER }} container_name: {{ WORDPRESS_CONTAINER }}
build: {% include 'roles/docker-container/templates/build.yml.j2' %}
context: .
pull_policy: never
ports: ports:
- "127.0.0.1:{{ ports.localhost.http[application_id] }}:80" - "127.0.0.1:{{ ports.localhost.http[application_id] }}:80"
volumes: volumes:

View File

@@ -1,8 +1,6 @@
{% include 'roles/docker-compose/templates/base.yml.j2' %} {% include 'roles/docker-compose/templates/base.yml.j2' %}
application: application:
build: {% include 'roles/docker-container/templates/build.yml.j2' %}
context: .
dockerfile: Dockerfile
image: "{{ XWIKI_IMAGE_CUSTOM }}" image: "{{ XWIKI_IMAGE_CUSTOM }}"
container_name: "{{ XWIKI_CONTAINER }}" container_name: "{{ XWIKI_CONTAINER }}"
hostname: '{{ XWIKI_HOSTNAME}}' hostname: '{{ XWIKI_HOSTNAME}}'

View File

@@ -1,9 +1,6 @@
{% include 'roles/docker-compose/templates/base.yml.j2' %} {% include 'roles/docker-compose/templates/base.yml.j2' %}
application: application:
build: {% include 'roles/docker-container/templates/build.yml.j2' %}
context: .
dockerfile: Dockerfile
pull_policy: never
image: simpleicons-server:latest image: simpleicons-server:latest
container_name: simpleicons-server container_name: simpleicons-server
ports: ports: