Reputation: 1217
I have an application that on play that use aerospike
in application.conf i have a param that i can rewrite from environments
aerospike.hosts = ["192.168.33.10"]
aerospike.hosts = ${?DS_AEROSPIKE_HOSTS}
how i can set list of hosts in my docker compose file?
version: '3.1'
services:
ds-aerospike-db:
image: aerospike/aerospike-server
restart: always
volumes:
- volume:/opt/aerospike/etc
command: ["--config-file","/opt/aerospike/etc/aerospike.conf"]
ports:
- 3000:3000
dashboard:
image: dashboard:0.1
restart: always
ports:
- 9000:9000
environment:
DS_AEROSPIKE_HOSTS: '["192.168.33.10"]'
this format is an error DS_AEROSPIKE_HOSTS: '["192.168.33.10"]'
Upvotes: 5
Views: 13353
Reputation: 3251
You have a couple of options:
You can include a docker.conf
file in your Docker build and inject the settings you want into that file. Then you can include the docker.conf
file from your application.conf
. E.g. add this to your application.conf
:
include "docker.conf"
You can use an environment varible to pass a string value (as suggested by Stanislav) but then convert it to a sequence. The idiomatic way to do this is to make a ConfigLoader
and then use it to convert a String
to a Seq[String]
. E.g. something like:
implicit val stringSeqLoader: ConfigLoader[Seq[String]] =
ConfigLoader(_.getString).map(_.split(','))
Upvotes: 0
Reputation: 4386
I believe you can't pass an array to the ENV variable. But you can pass it as a string, and then, later, parse string at your application.
environment:
- DS_AEROSPIKE_HOSTS='192.168.33.10,192.168.33.11'
the valid docker-compose.yml syntax is stated at docs https://docs.docker.com/compose/environment-variables/
I'm not familiar with scala, but I believe you can do something like
aerospike.hosts = ${?DS_AEROSPIKE_HOSTS}.split(',')
Upvotes: 3