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

Config fix for postgres docker defaults #183

Merged
merged 2 commits into from
Oct 9, 2023

Conversation

Fmstrat
Copy link
Contributor

@Fmstrat Fmstrat commented Oct 6, 2023

Default Docker configurations in Alpine have a different override path, which causes problems if people switch to the Ansible deployment.

Reproduction of the issue:

  • Fire up a Lemmy DB in Docker without a volume mount for /etc/postgresql.conf
  • Use SHOW config_file to see the location of the config file (it will be in /var/lib/data)
  • Take down the DB, and add a volume mount for /etc/postgresql.conf
  • Use SHOW config_file to see the location of the config file (it will still be in /var/lib/data)

Also, official docker instructions for Postgres is to use /etc/postgresql/postgresql.conf, though this is irrelevant given this PR.

To force the use of /etc/postgresql.conf for if users switch from bare mode to Ansible, the compose file was edited to include a forced command.

In addition, the default for PG15 alpine listen_address is localhost, not *, which is required for the lemmy container to connect. This default is overwritten by the docker container normally, but is not included in the tuning samples provided.

NOTE: It is highly possible there are a number of smaller self-hosted instances who have no idea their poor performance is because PG is not properly tuned, as the defaults are pretty meager.

@codyro
Copy link
Collaborator

codyro commented Oct 7, 2023

Taking a quick look, I think we may run into issues with the /etc/postgresql.conf being mounted with permissions the postgres user cannot read:

/ # ls -lh /etc/postgresql.conf
-rw-------    1 1000     1000         733 Oct  2 18:12 /etc/postgresql.conf

/ # grep postgres /etc/passwd
postgres:x:70:70:Linux User,,,:/var/lib/postgresql:/bin/sh
2023-10-07 20:01:21.001 GMT [1] LOG:  could not open configuration file "/etc/postgresql.conf": Permission denied
2023-10-07 20:01:21.001 GMT [1] FATAL:  configuration file "/etc/postgresql.conf" contains errors

The playbooks are distributing the postgres configuration with 1000:1000 ownership and 0600 permissions (https://github.com/LemmyNet/lemmy-ansible/blob/main/lemmy.yml#L222-L224 & https://github.com/LemmyNet/lemmy-ansible/blob/main/lemmy-almalinux.yml#L189-L191). I see no reason why this is needed, so we could either change the ownership to 70:70 and keep the 0600 permissions or just set the user and owner to root with 0644 permissions (IMO the most logical).

Could you fix this in your PR?

EDIT

I realized you might have been coming from the primary project, which references this docker-compose.yml. If you're uncomfortable adjusting the playbooks (or don't have time), let me know, and I'll submit a separate PR to fix it :).

Good luck with the move!

@codyro codyro self-assigned this Oct 7, 2023
@Fmstrat
Copy link
Contributor Author

Fmstrat commented Oct 7, 2023

Happy to do it, while I don't deploy lemmy this way (I just happened to notice it) I'm prretty familiar with ansible. I'll knock it out after the move. And thanks!

@ticoombs
Copy link
Collaborator

ticoombs commented Oct 9, 2023

Thanks @Fmstrat ! I've been meaning to fix this up. As i've helped solve this on the matrix rooms multiple times.

Once #186 is merged please rebase and we'll merge

@ticoombs ticoombs added this to the 1.2.1 milestone Oct 9, 2023
@dessalines dessalines merged commit 22aa431 into LemmyNet:main Oct 9, 2023
1 check passed
codyro added a commit to codyro/lemmy-ansible that referenced this pull request Oct 9, 2023
usr3 pushed a commit to usr3/futurology-lemmy that referenced this pull request Dec 23, 2023
Co-authored-by: Dessalines <tyhou13@gmx.com>
usr3 pushed a commit to usr3/futurology-lemmy that referenced this pull request Dec 23, 2023
snowe2010 pushed a commit to programming-dot-dev/lemmy-ansible that referenced this pull request Jan 30, 2024
Co-authored-by: Dessalines <tyhou13@gmx.com>
snowe2010 pushed a commit to programming-dot-dev/lemmy-ansible that referenced this pull request Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants