I'm developping an application using spring-boot and Docker. For security reasons I want to not use any more application.properties and use only environnement variable.
If you have best practices I will be grateful.
This is a snipet of my docker-compose.yml
version: "2.1"
services:
app_users:
image: images/app_users
container_name: app_user_ctn
build:
context: ../..
dockerfile: docker/dev/Dockerfile
ports:
- "30333:8080"
external_links:
- mysql
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://mysql/myDB?autoReconnect=true
SPRING_DATASOURCE_USERNAME: mysqluser1
SPRING_DATASOURCE_PASSWORD: mysqlpwsword
SPRING_DATASOURCE_DRIVER_CLASS_NAME: com.mysql.jdbc.Driver
LDAP_PASSWORD: ldapPswd
LDAP_URLS: ldap://myServer:389
LDAP_USERNAME: cn=admin,dc=com,dc=expl
When I make a request to ldap I get NulPointerException because ldap environnement variables are not initialize.
When I use application.yml it works.
...
spring:
ldap:
password: ldapPswd
urls: ldap://myServer:389
username: cn=admin,dc=com,dc=expl
....
Would you have any ideas ?
Best regards
LDAP_PASSWORD
!=spring.ldap.password
. You should useSPRING_LDAP_PASSWORD
.The SPRING_APPLICATION_JSON properties can be supplied on the command line with an environment variable. For example in a UN*X shell: $ SPRING_APPLICATION_JSON='{"foo":{"bar":"spam"}}' java -jar myapp.jar
. The way i read that is that you can define all properties in json format using the above variable and that way you don't have to specify X variables in your docker file. It is just a personal preference thing