50 lines
1.0 KiB
Jsonnet
50 lines
1.0 KiB
Jsonnet
# Tag to set UID and GID to container
|
|
#
|
|
# Examples:
|
|
# tags:
|
|
# - docker-svc-tz:
|
|
# policy: always
|
|
# services:
|
|
# - srv1
|
|
# - mysqldb
|
|
|
|
# Default imports
|
|
local user_data = std.parseJson(std.extVar('user_data'));
|
|
local docker_data = std.parseJson(std.extVar('docker_data'));
|
|
|
|
# Init defaults
|
|
local default_svcs = std.get(user_data, 'PAASIFY_STACK_SVCS');
|
|
|
|
# Build default config
|
|
local config_default = {
|
|
APP_SERVICES: default_svcs,
|
|
APP_PUID: 1000,
|
|
APP_PGID: 1000,
|
|
APP_PUID_VAR: 'APP_PUID',
|
|
APP_PGID_VAR: 'APP_PGID',
|
|
};
|
|
|
|
local conf = config_default + user_data;
|
|
local services_names = std.split(conf.APP_SERVICES, ',') ;
|
|
|
|
# Internal functions
|
|
local ServiceUGI(var, val) =
|
|
if std.isString(val) || std.isNumber(val) then
|
|
{
|
|
[var]: std.toString(val),
|
|
} else {};
|
|
|
|
|
|
# Process
|
|
docker_data +
|
|
{
|
|
services+: {
|
|
[svc_name]+: {
|
|
environment+:
|
|
ServiceUGI(conf.APP_PUID_VAR, conf.APP_PUID) +
|
|
ServiceUGI(conf.APP_PGID_VAR, conf.APP_PGID),
|
|
} for svc_name in services_names
|
|
},
|
|
}
|
|
|