synapse-admin icon indicating copy to clipboard operation
synapse-admin copied to clipboard

Default homeserver env-var via docker-compose

Open mm28ajos opened this issue 3 years ago • 8 comments

Hello,

I have an issue getting the default homeserver env-var running. The default value can be set by an env-var via docker-compose, see example below, or did I miss something?

synapse-admin:
container_name: synapse-admin
image: awesometechnologies/synapse-admin:latest
ports:
  - "8080:80"
environment:
  - "REACT_APP_SERVER=http://10.1.1.1:8008"
restart: unless-stopped

mm28ajos avatar Jul 08 '21 23:07 mm28ajos

It does not work with current Dockerfile See here: https://github.com/facebook/create-react-app/issues/982 Docker uses REACT_APP_SERVER during the build the container and not in runtime.

dklimpel avatar Aug 03 '21 20:08 dklimpel

Ahhh yes, thanks!

mm28ajos avatar Aug 03 '21 20:08 mm28ajos

Take a look at the new README.md. Now you can pass the build variables PUBLIC_URL and REACT_APP_SERVER as a build arg and build the Docker image yourself in Docker Compose.

MexHigh avatar May 23 '22 17:05 MexHigh

Take a look at the new README.md. Now you can pass the build variables PUBLIC_URL and REACT_APP_SERVER as a build arg and build the Docker image yourself in Docker Compose.

Wouldn't it be possible to instead use those variables as environment ones like most other images do? I honestly wouldn't consider this issue 100% closed if that's not supported.

mind-overflow avatar Jun 06 '22 11:06 mind-overflow

Take a look at the new README.md. Now you can pass the build variables PUBLIC_URL and REACT_APP_SERVER as a build arg and build the Docker image yourself in Docker Compose.

Wouldn't it be possible to instead use those variables as environment ones like most other images do? I honestly wouldn't consider this issue 100% closed if that's not supported.

Correct. This was my initial idea - so setting those options without building your own image.

mm28ajos avatar Jun 06 '22 19:06 mm28ajos

Well this would require modifying the build/index.html file while starting the docker container. In the nginx image this can be done by using a new entrypoint.sh file like this:

FROM nginx:alpine
...
COPY docker-entrypoint.sh /docker-entrypoint.d/99-synpase-admin.sh
RUN chmod +x /docker-entrypoint.d/99-synpase-admin.sh
...

(Source: https://github.com/nginxinc/docker-nginx/blob/master/entrypoint/docker-entrypoint.sh#L16-L30)

The entrypoint file would prepend the current script import paths in /app/index.html with the value of the envvar PUBLIC_URL using sed or something similar. This would allow setting PUBLIC_URL as docker runtime envvar.

Considerations

  • This will break the option to define PUBLIC_URL during build as it might get overwritten when starting the container. Maybe this feature could be removed all together?
  • I don't know if this will also work for REACT_APP_SERVER, as I don't know where and how React handles envvars, sadly.

Hope this will help for implementing this.

Maybe I can find time to do this myself this weekend.

MexHigh avatar Jun 07 '22 09:06 MexHigh

Yes, a PUBLIC_URL env variable (or other runtime configuration) would be very useful, similar to element-web's default_server_config configuration.

schildbach avatar Aug 27 '22 18:08 schildbach

If we could have official support for those of us who run synapse in a docker container that would be great. I used to run a matrix server I had built from scratch and came to rely on synapse-admin, but I recently rebuilt everything and ported the DB over to a docker system for various reasons, and I was unaware that SA wasn't going to work anymore. Its a super useful tool for anyone running an Enterprise environment. If someone feels like they could contribute that, or do it for my needs, I'm sure I could get my company to pay you for your time.

sobriant74 avatar Dec 08 '22 14:12 sobriant74