Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New docker containers always use the default app.config #742

Closed
nilsnolde opened this issue Jun 5, 2020 · 4 comments · Fixed by #745 or #772
Closed

New docker containers always use the default app.config #742

nilsnolde opened this issue Jun 5, 2020 · 4 comments · Fixed by #745 or #772

Comments

@nilsnolde
Copy link
Contributor

It's very annoying: whenever a new container is created (e.g. when just changing some env var in docker-compose.yml) the new container reads the default app.config provided by the image. Regardless if the user actually has a valid config in ./ors-conf.

Not hard to remedy:

The problem is that mvn package is run in the image itself, which packages the default app.config into the WAR file. So currently there's no way to access the app.config Tomcat will use since it's inside the WAR.

The lines

    mvn -q -f /ors-core/openrouteservice/pom.xml package -DskipTests && \
    cp -f /ors-core/openrouteservice/target/*.war /usr/local/tomcat/webapps/ors.war && \ 

need to be in docker-entrypoint.sh, not in the Dockerfile, with some logic so we don't package needlessly if nothing changed.

@nilsnolde nilsnolde added this to the 6.2 milestone Jun 5, 2020
@nilsnolde nilsnolde self-assigned this Jun 5, 2020
@nilsnolde nilsnolde mentioned this issue Jun 13, 2020
12 tasks
@takb takb closed this as completed in #745 Jun 16, 2020
@0xd3e
Copy link

0xd3e commented Jul 2, 2020

@nilsnolde I'm not entirely sure this fixes the issue.

The custom configuration is only copied when /usr/local/tomcat/webapps/ors exists, which means when a new container is started, it will still use the default config. In my case I only need one profile, but when I start the container, it always initializes cycling-regular and driving-car.

@EWouters
Copy link

How this is implemented now only works when you build the image yourself, and even then there is some code to scrub out all profiles except for "car".

This can easily be integrated to work with custom app.config at docker run time by checking if the app.config file exists before overwriting it on this line: https://github.com/GIScience/openrouteservice/blame/master/docker-entrypoint.sh#L26

@EWouters
Copy link

# if Tomcat built before, copy the mounted app.config to the Tomcat webapp app.config, else copy it from the source
if [ -d "/usr/local/tomcat/webapps/ors" ]; then
	cp -f /ors-conf/app.config $tomcat_appconfig
else
	if [ ! -f /ors-conf/app.config ]; then
		cp -f $source_appconfig /ors-conf/app.config
	fi
	echo "### Package openrouteservice and deploy to Tomcat ###"
	mvn -q -f /ors-core/openrouteservice/pom.xml package -DskipTests && \
	cp -f /ors-core/openrouteservice/target/*.war /usr/local/tomcat/webapps/ors.war
fi

Something like this, or add this argument to docker run:

-v $PWD/app.config:/ors-core/openrouteservice/src/main/resources/app.config \

@EWouters
Copy link

See #772

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment