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

Can't use Postgres Unix Sockets with Wallabag Docker container... #174

Open
dslovin opened this issue Dec 28, 2019 · 4 comments
Open

Can't use Postgres Unix Sockets with Wallabag Docker container... #174

dslovin opened this issue Dec 28, 2019 · 4 comments

Comments

@dslovin
Copy link

dslovin commented Dec 28, 2019

Trying to setup wallabag with postgres database, using unix sockets instead of TCP. Seems like adding this to ansible's entry point should work:
database_socket: "{{ lookup('env', 'SYMFONYENVDATABASE_SOCKET')|default('~', true) }}"
but unfortunately it isn't.

I have a patch, but it didn't work (so no use in a PR)

Any insights in how to make this work?

@ptman
Copy link

ptman commented Jul 29, 2020

Have you mounted the socket to the correct container?

@roomcays
Copy link

I can not also connect to host's PostgreSQL socket. Maybe SYMFONY__ENV__DATABASE_SOCKET isn't supported as an environment variable?

My docker-compose.yml:

version: "3.8"

services:

  app:
    image: wallabag/wallabag
    ports:
      - "8081:80"
    environment:
      POSTGRES_PASSWORD: wallabag
      POSTGRES_USER: wallabag
      SYMFONY__ENV__DATABASE_DRIVER: pdo_pgsql
      SYMFONY__ENV__DATABASE_DRIVER_CLASS: Wallabag\CoreBundle\Doctrine\DBAL\Driver\CustomPostgreSQLDriver
      SYMFONY__ENV__DATABASE_SOCKET: /var/run/.s.PGSQL.5432
      SYMFONY__ENV__DATABASE_NAME: wallabag
      SYMFONY__ENV__DATABASE_USER: wallabag
      SYMFONY__ENV__DATABASE_PASSWORD: wallabag
    volumes:
      - type: bind
        source: /var/run/postgresql/.s.PGSQL.5432
        target: /var/run/.s.PGSQL.5432

@kevinschachtschneider
Copy link

I also can not get the docker container to respect the SYMFONY__ENV__DATABASE_SOCKET variable. It looks like the container tries to read the SYMFONY__ENV__DATABASE_PORT option which this documentation says it shouldn't (granted that is for the parameters.yml file and not the environment variables)

FAILED! => {"changed": false, "msg": "argument port is of type <class 'str'> and we were unable to convert to int: <class 'str'> cannot be converted to an int"}
wallabag_1  | Starting provisioner...
wallabag_1  | [WARNING]: Found both group and host with same name: localhost
wallabag_1  | [WARNING]: Platform linux on host localhost is using the discovered Python
wallabag_1  | interpreter at /usr/bin/python3, but future installation of another Python
wallabag_1  | interpreter could change this. See https://docs.ansible.com/ansible/2.9/referen
wallabag_1  | ce_appendices/interpreter_discovery.html for more information.
wallabag_1  | PLAY [localhost] bin dev entrypoint.sh etc home lib media mnt opt proc root run sbin srv sys tmp usr var TASK [Gathering Facts] bin dev entrypoint.sh etc home lib media mnt opt proc root run sbin srv sys tmp usr var ok: [localhost] TASK [needed dirs] bin dev entrypoint.sh etc home lib media mnt opt proc root run sbin srv sys tmp usr var ok: [localhost] => (item=/var/www/wallabag/app) ok: [localhost] => (item=/var/www/wallabag/app/config) ok: [localhost] => (item=/var/www/wallabag/data) changed: [localhost] => (item=/var/www/wallabag/data/assets) ok: [localhost] => (item=/var/www/wallabag/data/db) TASK [write parameters.yml] bin dev entrypoint.sh etc home lib media mnt opt proc root run sbin srv sys tmp usr var changed: [localhost] TASK [stat] bin dev entrypoint.sh etc home lib media mnt opt proc root run sbin srv sys tmp usr var skipping: [localhost] TASK [notify install for sqlite] bin dev entrypoint.sh etc home lib media mnt opt proc root run sbin srv sys tmp usr var skipping: [localhost] TASK [wait for db container] bin dev entrypoint.sh etc home lib media mnt opt proc root run sbin srv sys tmp usr var fatal: [localhost]: FAILED! => {"changed": false, "msg": "argument port is of type <class 'str'> and we were unable to convert to int: <class 'str'> cannot be converted to an int"} RUNNING HANDLER [chown dir] bin dev entrypoint.sh etc home lib media mnt opt proc root run sbin srv sys tmp usr var PLAY RECAP bin dev entrypoint.sh etc home lib media mnt opt proc root run sbin srv sys tmp usr var localhost : ok=3 changed=2 unreachable=0 failed=1 skipped=2 rescued=0 ignored=0
wallabag_1  | Provisioner finished.

Here is my docker-compose file:

version: '3'
services:
  wallabag:
    image: wallabag/wallabag
    volumes:
      - /var/run/postgresql:/var/run/postgresql
      - images:/var/www/wallabag/web/assets/images
    environment:
      - SYMFONY__ENV__DOMAIN_NAME=http://myhosthere
      - SYMFONY__ENV__FOSUSER_REGISTRATION=false
      - SYMFONY__ENV__DATABASE_DRIVER=pdo_pgsql
      - SYMFONY__ENV__DATABASE_SOCKET=/var/run/postgresql
      - SYMFONY__ENV__DATABASE_NAME=wallabag
      - SYMFONY__ENV__DATABASE_USER=wallabag
      - SYMFONY__ENV__DATABASE_PASSWORD=mypasswordhere
      - SYMFONY__ENV__SECRET=mysecrethere
    ports:
      - "8083:80"
    restart: unless-stopped
volumes:
  images: {}

I have confirmed that this method of exposing the socket to an Ubuntu container running the psql command does work.

Hope this helps!

@jtagcat
Copy link

jtagcat commented Aug 25, 2021

PLAY [localhost] bin dev entrypoint.sh etc home lib media mnt opt proc root run sbin srv sys tmp usr var TASK [Gathering Facts] bin dev entrypoint.sh etc home lib media mnt opt proc root run sbin srv sys tmp usr var ok: [localhost] TASK [needed dirs] bin dev entrypoint.sh etc home lib media mnt opt proc root run sbin srv sys tmp usr var ok: [localhost] => (item=/var/www/wallabag/app) ok: [localhost] => (item=/var/www/wallabag/app/config) ok: [localhost] => (item=/var/www/wallabag/data) changed: [localhost] => (item=/var/www/wallabag/data/assets) ok: [localhost] => (item=/var/www/wallabag/data/db) TASK [write parameters.yml] bin dev entrypoint.sh etc home lib media mnt opt proc root run sbin srv sys tmp usr var changed: [localhost] TASK [stat] bin dev entrypoint.sh etc home lib media mnt opt proc root run sbin srv sys tmp usr var skipping: [localhost] TASK [notify install for sqlite] bin dev entrypoint.sh etc home lib media mnt opt proc root run sbin srv sys tmp usr var skipping: [localhost] TASK [wait for db container] bin dev entrypoint.sh etc home lib media mnt opt proc root run sbin srv sys tmp usr var fatal: [localhost]: FAILED! => {"changed": false, "msg": "argument port is of type <class 'str'> and we were unable to convert to int: <class 'str'> cannot be converted to an int"} RUNNING HANDLER [chown dir] bin dev entrypoint.sh etc home lib media mnt opt proc root run sbin srv sys tmp usr var PLAY RECAP bin dev entrypoint.sh etc home lib media mnt opt proc root run sbin srv sys tmp usr var localhost : ok=3 changed=2 unreachable=0 failed=1 skipped=2 rescued=0 ignored=0

@kevinschachtschneider your setup fails because Ansible can't chown images to nobody:nobody on startup.

Try mounting it somewhere else, where it has permissions to chown.
(Using --user nobody doesn't work either, as then Ansible fails differently.)

A bind mount might work for you: - ./wallabag-images:/var/www/wallabag/web/assets/images

#256 might fix this.

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

No branches or pull requests

5 participants