In am using jsonnet to create docker compose file. I am at just initial stages, and I need an alias &image because I will reuse this in other section later.
function(spec, service) {
version: spec.version.compose_version,
services: {
[service + '-primary']: {
image: '&image ' + spec.registry + '/' + service ':' + spec.version
}
}
}
But this will output
"services":
"ourproduct-primary":
"image": "&image mycompany.com/ourproduct:${VERSION:-master}"
"version": "3.9"
I think this is not valid as &image and the link are both enclosed in same double quotes, I don’t know how to solve.
Also is there a way to remove the double quotes? So it would look like this?
version: '3.9'
services:
ourproduct-primary:
image: &image mycompany.com/ourproduct:${VERSION:-master}
I am using manifestYamlDoc
function(spec){
['compose.%s.yaml' % service]: std.manifestYamlDoc(services[service](spec, service))
for service in spec.services
}