Skip to content

Commit

Permalink
ix-app: use v2 (#1120)
Browse files Browse the repository at this point in the history
* whoogle: use v2

* fix test and add labels

* whoops

* init

* m

* wordpress: use v2

* lib

* fix descv

* syncthing: use v2

* update lib

* add home dir

* fix setup container

* v2-lib: rocm device

* fix validation

* handle rocm

* rm old

* regen hash

* ix-app: use v2

* rm old
  • Loading branch information
stavros-k authored Dec 5, 2024
1 parent 5e6fc26 commit 002d953
Show file tree
Hide file tree
Showing 120 changed files with 6,224 additions and 1,407 deletions.
6 changes: 3 additions & 3 deletions ix-dev/stable/ix-app/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ home: https://www.truenas.com/
host_mounts: []
icon: https://media.sys.truenas.net/apps/ix-chart/icons/icon.webp
keywords: []
lib_version: 1.1.7
lib_version_hash: d05e43e25b7dc1736be6cc1efa4b9255368aa346e3e7a4350a38440f29b73186
lib_version: 2.0.34
lib_version_hash: 54c507c0a47e2a10aee421ec5a67c04f73692bd865d4d5057f57711e322a7951
maintainers:
- email: [email protected]
name: truenas
Expand All @@ -19,4 +19,4 @@ screenshots: []
sources: []
title: iX App
train: stable
version: 1.0.14
version: 1.1.0
37 changes: 37 additions & 0 deletions ix-dev/stable/ix-app/questions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ groups:
description: Configure Portals
- name: Storage Configuration
description: Configure Storage for the container
- name: Labels Configuration
description: Configure Labels for the container
- name: Resources Configuration
description: Configure Resources for the container

Expand Down Expand Up @@ -135,6 +137,17 @@ questions:
description: On Failure - Restarts the container if the exit code indicates an error.
- value: always
description: Always - Restarts the container until its removal.
- variable: max_retry_count
label: Maximum Retry Count
group: Container Configuration
description: |
Maximum number of retries allowed for a container to exit with a code indicating an error. </br>
Setting this to zero, will keep restarting the container if it exits with a code indicating an error.
schema:
type: int
required: true
default: 0
show_if: [["restart_policy", "on-failure"]]

- variable: disable_builtin_healthcheck
label: Disable Builtin Healthcheck
Expand Down Expand Up @@ -530,6 +543,30 @@ questions:
type: int
default: 500
required: true

- variable: labels
label: ""
group: Labels Configuration
schema:
type: list
default: []
items:
- variable: label
label: Label
schema:
type: dict
attrs:
- variable: key
label: Key
schema:
type: string
required: true
- variable: value
label: Value
schema:
type: string
required: true

- variable: resources
label: ""
group: Resources Configuration
Expand Down
163 changes: 90 additions & 73 deletions ix-dev/stable/ix-app/templates/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,73 +1,90 @@
services:
{{ values.ix_context.app_name }}:
{# Image Configuration #}
image: {{ "%s:%s" | format(values.image.repository, (values.image.tag or "latest")) }}

{# Container Configuration #}
restart: {{ values.restart_policy }}
tty: {{ values.tty }}
stdin_open: {{ values.stdin }}

{% if values.entrypoint %}
entrypoint: {{ values.entrypoint | tojson }}
{% endif %}

{% if values.command %}
command: {{ values.command | tojson }}
{% endif %}

{% if values.disable_builtin_healthcheck %}
healthcheck: {"disable": true}
{% endif %}

environment: {{ ix_lib.base.environment.envs(app={}, user=values.envs, values={"TZ": values.TZ}) | tojson }}
{# Network Configuration #}
{% if values.dns_config.nameservers %}
dns: {{ values.dns_config.nameservers | tojson }}
{% endif %}

{% if values.dns_config.searches %}
dns_search: {{ values.dns_config.searches | tojson }}
{% endif %}

{% if values.dns_config.options %}
dns_opt: {{ ix_lib.base.network.dns_opts(values.dns_config.options) | tojson }}
{% endif %}

{% if values.host_network %}
network_mode: host
{% endif %}

{% if not values.host_network and values.ports %}
ports:
{% for port in values.ports %}
- {{ ix_lib.base.ports.get_port(port=port) | tojson }}
{% endfor %}
{% endif %}

{# Security Context Configuration #}
privileged: {{ values.privileged }}
{% set caps = ix_lib.base.security.get_caps(add=values.capabilities.add, drop=[]) %}
{% if caps.add %}
cap_add: {{ caps.add | tojson }}
{% endif %}

{% if values.run_as_custom_user %}
user: {{ "%d:%d" | format(values.run_as.user, values.run_as.group) }}
{% endif %}

{# Storage Configuration #}
{% if values.storage %}
volumes:
{% for store in values.storage %}
- {{ ix_lib.base.storage.storage_item(data=store, values=values).vol_mount | tojson }}
{% endfor %}
{% endif %}

{# Resources Configuration #}
deploy:
resources: {{ ix_lib.base.resources.resources(values.resources, not values.resources.enable_resource_limits) | tojson }}
devices: {{ ix_lib.base.resources.get_devices(values.resources) | tojson }}

x-portals: {{ ix_lib.base.metadata.get_portals(values.portals) | tojson }}
x-notes: {{ ix_lib.base.metadata.get_notes("iX App") | tojson }}
{# Adjust values to library will pick some things automatically #}
{% do values.update({
"skip_generic_variables": true,
"images": {
"image": {
"repository": values.image.repository,
"tag": values.image.tag or "latest",
}
},
"network": {
"dns_opts": values.dns_config.get("options", []),
"dns_searches": values.dns_config.get("searches", []),
"dns_nameservers": values.dns_config.get("nameservers", []),
}
}) %}

{% for label in values.labels %}
{% do label.update({"containers": [values.ix_context.app_name]}) %}
{% endfor %}

{# Any manipulation to values should be done before this point #}

{# Template starts here #}
{% set tpl = ix_lib.base.render.Render(values) %}

{# Image Configuration #}
{% set c1 = tpl.add_container(values.ix_context.app_name, "image") %}
{% do c1.set_pull_policy(values.image.pull_policy) %}

{# Container Configuration #}
{% if values.restart_policy == "on-failure" %}
{% do c1.restart.set_policy(values.restart_policy, values.max_retry_count) %}
{% else %}
{% do c1.restart.set_policy(values.restart_policy) %}
{% endif %}

{% do c1.set_tty(values.tty) %}
{% do c1.set_stdin(values.stdin) %}

{% if values.entrypoint %}
{% do c1.set_entrypoint(values.entrypoint) %}
{% endif %}

{% if values.command %}
{% do c1.set_command(values.command) %}
{% endif %}

{% if values.disable_builtin_healthcheck %}
{% do c1.healthcheck.disable() %}
{% else %}
{% do c1.healthcheck.use_built_in() %}
{% endif %}

{% do c1.environment.add_env("TZ", values.TZ) %}
{% do c1.environment.add_user_envs(values.envs) %}

{# Network Configuration #}
{% if values.host_network %}
{% do c1.set_network_mode("host") %}
{% else %}
{% if values.ports %}
{% for port in values.ports %}
{% do c1.ports.add_port(port.published, port.target, {"protocol": port.protocol}) %}
{% endfor %}
{% endif %}
{% endif %}

{# Security Context Configuration #}
{% do c1.set_privileged(values.privileged) %}
{% do c1.clear_caps() %}
{% do c1.remove_security_opt("no-new-privileges") %}

{% do c1.add_caps(values.capabilities.add) %}
{% if values.run_as_custom_user %}
{% do c1.set_user(values.run_as.user, values.run_as.group) %}
{% endif %}

{% for store in values.storage %}
{% do c1.add_storage(store.mount_path, store) %}
{% endfor %}

{% if not values.resources.enable_resource_limits %}
{% do c1.deploy.resources.remove_cpus_and_memory() %}
{% endif %}

{% for portal in values.portals %}
{% do tpl.portals.add_portal(portal) %}
{% endfor %}

{{ tpl.render() | tojson }}
98 changes: 0 additions & 98 deletions ix-dev/stable/ix-app/templates/library/base_v1_1_7/environment.py

This file was deleted.

Loading

0 comments on commit 002d953

Please sign in to comment.