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

POSTGRES_PASSWORD_FILE doesn't work #14

Open
nazmang opened this issue Dec 10, 2023 · 1 comment
Open

POSTGRES_PASSWORD_FILE doesn't work #14

nazmang opened this issue Dec 10, 2023 · 1 comment

Comments

@nazmang
Copy link

nazmang commented Dec 10, 2023

Hi,

It seems entrypoint.sh not recognizing POSTGRES_PASSWORD_FILE variable. Seeing output below in container logs

Starting pg_dump
/run/secrets/POSTGRES_PASSWORD: line 1: 7@: command not found
/run/secrets/POSTGRES_PASSWORD: line 1: XXXXXXXX: command not found
PGUSER='/run/secrets/POSTGRES_USER'
POSTGRES_DB='zabbix'
PGHOST='postgres-zabbix'
PGPORT='5432'
PGDUMP='/dump'
RETAIN_COUNT=3
S3_HOSTNAME='s3.amazonaws.com'
S3_HOST_BUCKET='%(bucket)s.s3.amazonaws.com'
S3_SSL_OPTION='--ssl'
0 3 * * * /dump.sh >> /dump/dump-log 2>&1 

I'm using 14.7 version of the image, there is a part of my docker-compose.yml

 postgres-backup:
    image: martlark/pg_dump:14.7
    deploy:
      placement:
        constraints:
          - node.platform.arch==x86_64
          - node.role == worker
    networks:
      - zabbix-net  
    depends_on:
      - postgres-zabbix
    env_file:
      - start.env  
    environment:
      PGUSER: /run/secrets/POSTGRES_USER
      POSTGRES_PASSWORD_FILE: /run/secrets/POSTGRES_PASSWORD
      PGHOST: postgres-zabbix
      PGPORT: 5432
      CRON_SCHEDULE: 0 3 * * * # Every day at 3am
      RETAIN_COUNT: 3 # Keep this number of backups
    secrets:
      - POSTGRES_USER
      - POSTGRES_PASSWORD 
 
secrets:      
  POSTGRES_USER:
    file: ./.POSTGRES_USER
    name: POSTGRES_USER_v${CONF_VERSION}
  POSTGRES_PASSWORD:
    file: ./.POSTGRES_PASSWORD
    name: POSTGRES_PASSWORD_v${CONF_VERSION}      

It looks like source construction doesn't work

if [[ -f "${POSTGRES_PASSWORD_FILE}" ]];
then
   source "${POSTGRES_PASSWORD_FILE}"

Can you help with that?
Thanks!

@Martlark
Copy link
Owner

Thanks for this. I'll work on it and see what the issue is.

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

2 participants