What is the "Correct" way to set values in alfresco-global.properties with docker-compose?

cancel
Showing results for 
Search instead for 
Did you mean: 
mangar
Established Member II

What is the "Correct" way to set values in alfresco-global.properties with docker-compose?

I am using the Alfresco SDK,  and everything seems to be working fine.  I now need to move my stack from dev to test.  So all of my hard coded values in the alfresco-platform-docker/src/main/docker/alfresco-global.properties need to change.  

I know I could just write a script that switches out files before deploying,  but I know that's not "right"

I want to be able to set these as environment variables that get injected at deploy time.  

Any way to do this?

*******  Update

I found that adding properties under different profiles in the pom works fine, just build with the right profile and done.  But again,  I am asking for what alfresco considers the "correct" way

3 Replies
abhinavmishra14
Advanced

Re: What is the "Correct" way to set values in alfresco-global.properties with docker-comp

In my opinion the better way is to use "JAVA_OPTS" (JVM runtime parameters) to set environment specific properties. 

Building artificats per environment defeats the purpose of "build once and deploy everywhere" approach.

Even alfresco's base image has empty alfresco-global.properties and all properties are set via JVM params. See the example here: https://github.com/Alfresco/acs-deployment/blob/master/docker-compose/community-docker-compose.yml#L...

For example setting db properties per environment:

Dev:
JAVA_OPTS: " -Ddb.username=alfresco_dev -Ddb.password=alfresco_Dev -Ddb.url=jdbc:postgresql://dev.alfresco.db:5432/alfresco "

QA:

JAVA_OPTS: "-Ddb.username=alfresco_qa
-Ddb.password=alfresco_qa
-Ddb.url=jdbc:postgresql://qa.alfresco.db:5432/alfresco
"

The above example requires you to have environemt specific docker-compose.yml file. On the same lines there is another better way, you would have one docker-compose.yml but you can use 'environment-file (--env-file)' with docker-compose to pass the environment specific variable file. 

For example:

.env

DB_USERNAME=alfresco
DB_PASS=alfresco
DB_URL=jdbc:postgresql://postgres:5432/alfresco

.env.dev
DB_USERNAME=alfresco_dev DB_PASS=alfresco_dev DB_URL=jdbc:postgresql://dev.alfresco.db:5432/alfresco .env.qa DB_USERNAME=alfresco_qa DB_PASS=alfresco_qa DB_URL=jdbc:postgresql://qa.alfresco.db:5432/alfresco

In your standard docker-compose.yml:

JAVA_OPTS: "
     -Ddb.username=${DB_USERNAME}
     -Ddb.password=${DB_PASS}
     -Ddb.url=${DB_URL}
   "

When starting the containers you would use following like command:

To Start local containers:

docker-compose --env-file .env up

or (When --env-file param is not passed, docker-compose by default looks for a .env file if available)


docker-compose up

To Start Dev containers:
docker-compose --env-file .env.dev up To Start QA containers: docker-compose --env-file .env.qa up

Ofcourse you can manage these environment files as per your org standards. 

Checkout this repository as well: https://github.com/Alfresco/acs-deployment 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)
mangar
Established Member II

Re: What is the "Correct" way to set values in alfresco-global.properties with docker-comp

This does not work using the ./run.sh build_start that comes with the SDK. 

abhinavmishra14
Advanced

Re: What is the "Correct" way to set values in alfresco-global.properties with docker-comp

Ofcourse it won't. You have to update those scripts. These are new commands that won't be there in basic script you get. What you get with sdk is generally for development purposes only.

You have to update "run.sh" something like:

case "$1" in
  build_start_dev)
    down_dev
    build
    start_dev
    tail
    ;;

.....
.... down_dev() { if [ -f "$COMPOSE_FILE_PATH" ]; then docker-compose -f "$COMPOSE_FILE_PATH" --env-file .env.dev down fi } start_dev() { #create volumes ... .... #Start docker-compose -f "$COMPOSE_FILE_PATH" --env-file .env.dev up ... }
~Abhinav
(ACSCE, AWS SAA, Azure Admin)