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

docker compose environment variables encoded as KEY='value' are not longer accepted since 2.6 #91

Closed
eljef opened this issue Nov 18, 2024 · 7 comments · Fixed by #92
Closed
Assignees

Comments

@eljef
Copy link

eljef commented Nov 18, 2024

Gotify 2.6.1 is ignoring the postfix host settings. The same connection settings work fine in 2.5. After upgrading to 2.6.1, gotify only attempts to connect to [::1]:5432

I cannot test this on Gotify 2.6.0 due to bool value crashing.

Rolling back to 2.5 works. The configuration is never changed.

Digging through changes, I can't really find much except
2d6601747b546c81d364a87bcfaf070bdd4f9f74

I don't know if this directly correlates.

Can the issue be reproduced with the latest available release? (y/n) yes

Which one is the environment gotify server is running in?

  • Docker with compose
Docker startup command or config file here (please mask sensitive information)
compose configuration snippit

gotify:
container_name: gotify
image: gotify/server:latest
#image: gotify/server:2.5 # working image
restart: unless-stopped
environment:
- TZ=America/Los_Angeles
- GOTIFY_SERVER_PORT=<port_number>
- GOTIFY_SERVER_SSL_ENABLED=false
- GOTIFY_SERVER_SSL_REDIRECTTOHTTPS=false
- GOTIFY_DATABASE_DIALECT=postgres
- GOTIFY_DATABASE_CONNECTION='host=<ip_of_postgres_server> port=<port_of_postgres_server> user= dbname= password= sslmode='
- GOTIFY_PASSSTRENGTH=11
- GOTIFY_REGISTRATION=false
- GOTIFY_SERVER_KEEPALIVEPERIODSECONDS=75
- GOTIFY_SERVER_STREAM_PINGPERIODSECONDS=30
volumes:
-

Do you have an reverse proxy installed in front of gotify server? (Please select None if the problem can be reproduced without the presense of a reverse proxy)

  • I do have a reverse proxy, but I can replicate without it, so choosing None

On which client do you experience problems? (Select as many as you can see)

  • Backend issue

What did you do?
Upgraded

What did you expect to see?
Gotify server running

What did you see instead? (Include screenshots, android logcat/request dumps if possible)

Starting Gotify version 2.6.1@2024-11-16-08:49:43
panic: dial tcp [::1]:5432: connect: connection refused

goroutine 1 [running]:
main.main()
/src/gotify/app.go:47 +0x39c
Starting Gotify version 2.6.1@2024-11-16-08:49:43
panic: dial tcp [::1]:5432: connect: connection refused

goroutine 1 [running]:
main.main()
/src/gotify/app.go:47 +0x39c
Starting Gotify version 2.6.1@2024-11-16-08:49:43
panic: dial tcp [::1]:5432: connect: connection refused

goroutine 1 [running]:
main.main()
/src/gotify/app.go:47 +0x39c
Starting Gotify version 2.6.1@2024-11-16-08:49:43
panic: dial tcp [::1]:5432: connect: connection refused

goroutine 1 [running]:
main.main()
/src/gotify/app.go:47 +0x39c

@eljef
Copy link
Author

eljef commented Nov 18, 2024

In the report, the compose configuration template got messed up.

GOTIFY_DATABASE_CONNECTION='host=ip_of_postgres_server port=port_of_postgres_server user=username dbname=dbname password=password sslmode=sslmode'

@eternal-flame-AD eternal-flame-AD self-assigned this Nov 19, 2024
@eternal-flame-AD
Copy link
Member

I think the issue is docker-compose env is just a string not a key value pair so you don't need the single quote.

Looks like our stale fork diverged from upstream and silently stripped off single quotes in env values when upstream did not, removing the single quote seem to fix it on my reproduction.

I looked at the official documentation and did not see places where we suggested this syntax, however if this is common usage among users maybe we can manually strip off every environment variable starting with "GOTIFY_" before loading config?

@eljef
Copy link
Author

eljef commented Nov 19, 2024

I had the string in single quotes due to the password having characters needing escaping. Removing the quotes and escaping the characters myself does allow for 2.6.1 to start correctly. I don't mind doing this, but I believe YAML does allow for wrapping a string in quotes to avoid having to escape characters. Single quotes fully escape the entire string. Double quotes still allows for interpretation of some unescaped characters, though none that should be used in a password.

I did a test and the failed behavior happens for both single and double quotes. If the fix is to strip quotes, it should not be limited to single. Otherwise, I'd be happy with a documentation fix that says "properly escape your characters with a \ blockhead" 😄

@eternal-flame-AD
Copy link
Member

I think 'GOTIFY_DATABASE_CONNECTION=host=ip_of_postgres_server port=port_of_postgres_server user=username dbname=dbname password=password sslmode=sslmode' this might work, GOTIFY_DATABASE_CONNECTION='host=ip_of_postgres_server port=port_of_postgres_server user=username dbname=dbname password=password sslmode=sslmode' this may not.

Because KEY=VAL is a whole string in this context, if you write 'KEY=VAL' YAML knows you are quoting but if you write KEY='VAL' it may not.

The schema says list or dict, so maybe if you write it like this it might be more ergonomic

environment:
 GOTIFY_DATABASE_CONNECTION: 'port=5432 host="0.0.0.0"  ...'

@eljef
Copy link
Author

eljef commented Nov 19, 2024

Converting environment to a dictionary and escaping it as suggested works. Seems this is not an actual bug, but a case of user error.

I'd be happy to close this if you agree? Seems the previous operational state was just covering an incorrectly formatted compose yaml.

@eternal-flame-AD eternal-flame-AD changed the title Latest release does not honor postfix settings Latest 2.6 release does not interpret quoted environment variables in docker compose Nov 19, 2024
@eternal-flame-AD
Copy link
Member

I think the documentation could be better with the current compose template . We can close this or transfer this to the documentation repo. Thanks for the issue, I had some issues configuring it too ( I chose to just to mount a config file into the container for my own deployment so I don't have to deal with this complex escaping thing)

https://gotify.net/docs/install

@eljef
Copy link
Author

eljef commented Nov 19, 2024

Transferring it to the documentation repo seems like it would be the correct move, at least resulting in better documentation. Thanks for the ideas on getting to a fix.

@eternal-flame-AD eternal-flame-AD changed the title Latest 2.6 release does not interpret quoted environment variables in docker compose docker compose environment variables encoded as KEY='value' are not longer accepted since 2.6 Nov 19, 2024
@eternal-flame-AD eternal-flame-AD transferred this issue from gotify/server Nov 19, 2024
eternal-flame-AD added a commit that referenced this issue Nov 20, 2024
eternal-flame-AD added a commit that referenced this issue Nov 20, 2024
eternal-flame-AD added a commit that referenced this issue Nov 22, 2024
* clarify docker-compose environment format (#91)

---------

Signed-off-by: eternal-flame-AD <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants