InvoiceShelf / docker

InvoiceShelf Docker Image public repository
https://hub.docker.com/r/invoiceshelf/invoiceshelf
17 stars 5 forks source link

Invoiceshelf cannot configure db connection after container is restarted #17

Closed Lulu300 closed 3 months ago

Lulu300 commented 3 months ago

I've encoutered a major issue with the docker image. With at every image tags (latest, nightly and alpha) when i do the command docker compose stop invoiceshelf and then docker compose start invoiceshelf, invoiceshelf will nerver come back to life. When i check the logs here's what it says: image

As long as i don't stop the container it works really great, but everytime I stop it I can't make it work again. The only solution to get it working again is to remove all volumes and reinstalling it again and again.

Here's my docker-compose.yml:

services:
  ### BEGIN INVOICE CONTAINER ###
  invoice-pgsql:
    container_name: invoice-pgsql
    image: postgres:${INVOICE_PGSQL_VERSION}
    env_file:
      - ${INVOICE_PGSQL_ENV_FILE}
    volumes:
      - ${INVOICE_PGSQL_DATA_FOLDER}:/var/lib/postgresql/data
    secrets:
      - invoice_pgsql_password
    networks:
      invoice:
        ipv4_address: X.X.X.X
    restart: unless-stopped

  invoice:
    image: invoiceshelf/invoiceshelf:${INVOICE_VERSION}
    container_name: invoice
    hostname: invoice
    user: root
    env_file:
      - ${INVOICE_ENV_FILE}
    volumes:
      - ${INVOICE_CONFIG_FOLDER}:/conf
      - ${INVOICE_DATA_FOLDER}:/data
      # - ${INVOICE_HTML_FOLDER}:/var/www/html
    secrets:
      - invoice_pgsql_password
      - mail_noreply_password
    networks:
      swag:
        ipv4_address: X.X.X.X
      invoice:
        ipv4_address: X.X.X.X
    restart: unless-stopped
    depends_on:
      - invoice-pgsql
  ### END INVOICE CONTAINER ###
networks:
  swag:
    name: swag
    driver: bridge
    ipam:
     config:
       - subnet: 172.18.1.0/24
         gateway: 172.18.1.1
  invoice:
    name: invoice
    driver: bridge
    ipam:
     config:
       - subnet: 172.18.14.0/24
         gateway: 172.18.14.1
secrets:
  ### BEGIN MAIL_NOREPLY SECRETS ###
  mail_noreply_password:
    file: .secrets/mail_noreply_password.txt
  ### END MAIL_NOREPLY SECRETS ###
  ### BEGIN INVOICE SECRETS ###
  invoice_pgsql_password:
    file: .secrets/invoice_pgsql_password.txt
  ### END INVOICE SECRETS ###

Here's my env file for the invoicehself container (I've just replaced my real domain name by https://invoice.example.com):

PHP_TZ=Europe/Paris
TIMEZONE=Europe/Paris
APP_NAME=Laravel
APP_ENV=local
APP_DEBUG=true
APP_URL=https://invoice.example.com
DB_CONNECTION=postgres
DB_HOST=invoice-pgsql
DB_PORT=5432
DB_DATABASE=invoice
DB_USERNAME=invoice
DB_PASSWORD_FILE=/run/secrets/invoice_pgsql_password
CACHE_STORE=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=invoice.example.com
SANCTUM_STATEFUL_DOMAINS=invoice.example.com
STARTUP_DELAY=2
MAIL_DRIVER=smtp
MAIL_HOST=${MAIL_NOREPLY_HOST}
MAIL_PORT=${MAIL_NOREPLY_SMTP_PORT}
MAIL_USERNAME=${MAIL_NOREPLY_USER}
MAIL_PASSWORD_FILE=${MAIL_NOREPLY_PASSWORD_FILE}
MAIL_ENCRYPTION=TLS

I hope this is enough information for you to see what's happening

gdarko commented 3 months ago

Hey @Lulu300

I rhink we have a typo. Instead of DATABASE_CONNECTION=postgres it should be DATABASE_CONNECTION=pgsql

Can you try to re-run it like that?

Thanks,

Best regards, Darko

Lulu300 commented 3 months ago

Hello,

I've just made the change and indeed it was just a typo error, it works perfectly now, thank you! I think it'll be a great idea to edit the docker-compose.pgsql.yml file to prevent others from having the same problem

Best regards

gdarko commented 3 months ago

Thanks for the update @Lulu300

I just updated the pgsql file.

Closing this now.