container: make dockerfile variable officially supported and more modular

This commit is contained in:
uumas
2023-07-05 15:41:42 +03:00
parent 8812459beb
commit 4d9edf1532
5 changed files with 17 additions and 11 deletions

View File

@@ -3,6 +3,7 @@
docker_host_user: false
docker_volume_type: named
docker_mariadb_config: {}
dockerfile: []
docker_phpmyadmin_basicauth: true
docker_phpmyadmin_basicauth_users: {}

View File

@@ -17,6 +17,12 @@ argument_specs:
description: "Docker image to use for the container. If dockerfile is defined, it will be used as base for locally built image (example: gitea/gitea:latest)"
type: str
required: true
dockerfile:
description: "A list of dockerfile instructions to add to the base image"
type: list
elements: str
required: false
default: []
docker_host_user:
description: "If true, creates a user on the host for this service. The container will run as this user's uid/gid. Bind mount volumes will be owned by this user."
type: bool

View File

@@ -39,7 +39,7 @@
set_fact:
template_mounts_needed: "{{ docker_mounts | selectattr('template', 'defined') | list | length > 0 }}"
volumes_needed: "{{ docker_mounts | selectattr('name', 'defined') | list | length > 0 or docker_database != 'none' }}"
dockerfile_needed: "{{ dockerfile is defined and dockerfile | length > 0 }}"
dockerfile_needed: "{{ dockerfile | length > 0 }}"
db_config_mounts_needed: "{{ docker_mariadb_config | length > 0 }}"
- name: Set more assistive variables
set_fact:

View File

@@ -1,9 +1,6 @@
# {{ ansible_managed }}
FROM {{ docker_image }}
{% if dockerfile.run is iterable %}
{% for cmd in dockerfile.run %}
RUN {{ cmd }}
{% for item in dockerfile %}
{{ item }}
{% endfor %}
{% endif %}