DOMjudge / domjudge-packaging

DOMjudge packaging for (Linux) distributions and live image
32 stars 40 forks source link

Can the BaseURL be specified when the container is started #103

Closed Dup4 closed 2 years ago

Dup4 commented 2 years ago

I tend to use docker to run domserver.

I found that in the official docker image, the default BaseURL is /.

And this is configured during compilation.

But because the university only provided us with a domain name, and there is no subdomain available.

But at the same time we have many other services.

So we can only forward domjudge through path forwarding, like http://localhost/domjudge.

But we can't simply configure path forwarding in Nginx of the gateway server.

Because web pages require static resources to beloaded, their request paths also need to be prefixed accordingly.

image

Just like the picture above, it needs to be prefixed with /domjudge or other you like.

I note that BaseURL will be specified when the domserver image is compiled.

https://github.com/DOMjudge/domjudge-packaging/blob/49e2c5af0a6779f460f024a150824dd23e27eab4/docker/domserver/build.sh#L7

It may be used to get the path prfix of asset(), maybe it will be used in other places.

https://github.com/DOMjudge/domjudge/blob/222c4ae5af23f03b316c25dcea99e8cf51792d9c/webapp/templates/base.html.twig#L7-L20

image

And also need to change the forwarding path in Nginx.

https://github.com/DOMjudge/domjudge-packaging/blob/49e2c5af0a6779f460f024a150824dd23e27eab4/docker/domserver/configure.sh#L68-L77

If want to specify BaseURL through environment variables when the container is started.

It should be easier to replace the Nginx configuration.

So for the modification of BaseURL in webapp, is there a more lightweight method?

And you agree to add an environment variable to be able to specify BaseURL when the container starts?

nickygerritsen commented 2 years ago

See webapp/config/static.yaml (or the .in version on git), that is where we place the base URL. Besides that we also put it in the docs, but there is no easy way to fix that. But we could use sed to replace that if BASEURL is set. Indeed the nginx config should also be updated. You are welcome to send in a PR.

Dup4 commented 2 years ago

OK, I will do it later.

Dup4 commented 2 years ago

See webapp/config/static.yaml (or the .in version on git), that is where we place the base URL. Besides that we also put it in the docs, but there is no easy way to fix that. But we could use sed to replace that if BASEURL is set. Indeed the nginx config should also be updated. You are welcome to send in a PR.

image

ok, I got it.

nickygerritsen commented 2 years ago

See webapp/config/static.yaml (or the .in version on git), that is where we place the base URL. Besides that we also put it in the docs, but there is no easy way to fix that. But we could use sed to replace that if BASEURL is set. Indeed the nginx config should also be updated. You are welcome to send in a PR.

image

ok, I got it.

Note this requires a webapp/bin/console cache:clear after doing so. Not sure if we already do this.

Dup4 commented 2 years ago

Yes, you have already done this.

https://github.com/DOMjudge/domjudge-packaging/blob/b7ebf8f02ec8e0014a595d9c8bfacf4e3db8982f/docker/domserver/scripts/start.d/90-symfony-cache.sh#L3