invoiceninja / dockerfiles

Docker files for Invoice Ninja
https://hub.docker.com/r/invoiceninja/invoiceninja
GNU General Public License v2.0
398 stars 264 forks source link

Brand new stack won't talk to the mysqldb #518

Closed Leopere closed 1 year ago

Leopere commented 1 year ago

The error

 2023-07-02T20:26:10Z [INFO] [Entrypoint]: Initialising Invoice Ninja...

    INFO  Configuration cached successfully.

    INFO  Caching the framework bootstrap files.

   config ........................................................... 36ms DONE
   routes ........................................................... 82ms DONE

 In Connection.php line 760:

   SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_s
   chema.tables where table_schema = ninja and table_name = accounts and table
   _type = 'BASE TABLE')

 In Connector.php line 70:

   SQLSTATE[HY000] [2002] Connection refused

 2023-07-02T20:26:13Z [ERROR] [Entrypoint]: Error connecting to DB

The seemingly functional mysql8 container.

 2023-07-02 20:22:11+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.33-1.el8 started.
 2023-07-02 20:22:13+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
 2023-07-02 20:22:13+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.33-1.el8 started.
 2023-07-02 20:22:14+00:00 [Note] [Entrypoint]: Initializing database files
 2023-07-02T20:22:14.319642Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
 2023-07-02T20:22:14.319761Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.33) initializing of server in progress as process 80
 2023-07-02T20:22:14.966659Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
 2023-07-02T20:23:36.379654Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
 2023-07-02T20:26:45.021438Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

The docker-compose.yml

version: '3.7'
x-environment: &environment
    environment:
      # IN application vars
      APP_URL: "https://invoice.example.com"
      APP_KEY: "base64:55L15WscB5cdmEOMvdbIIBbBwHt9Pb0G4p4sCAYCATw="
      APP_DEBUG: "false"
      REQUIRE_HTTPS: "true"
      PHANTOMJS_PDF_GENERATION: "false"
      PDF_GENERATOR: "snappdf"
      TRUSTED_PROXIES: '*'
      QUEUE_CONNECTION: "database"
      # DB connection
      DB_HOST: "db"
      DB_PORT: "3306"
      DB_DATABASE: "ninja"
      DB_USERNAME: "root"
      DB_PASSWORD: "ninja"
      # Create initial user
      # Default to these values if empty
      # IN_USER_EMAIL=admin@example.com
      # IN_PASSWORD=changeme!
      IN_USER_EMAIL: "REDACTED@example.com"
      IN_PASSWORD: "REDACTED"
      # Mail options
      MAIL_MAILER: "log"
      MAIL_HOST: "box.example.com"
      MAIL_PORT: "465"
      MAIL_USERNAME: "invoice@example.com"
      MAIL_PASSWORD: "REDACTED"
      MAIL_ENCRYPTION: "tls"
      MAIL_FROM_ADDRESS: "invoice@example.com"
      MAIL_FROM_NAME: "Invoices from REDACTED"
      # MySQL
      MYSQL_ROOT_PASSWORD: "ninja"
      MYSQL_USER: "ninja"
      MYSQL_PASSWORD: "ninja"
      MYSQL_DATABASE: "ninja"

services:
  app:
    image: invoiceninja/invoiceninja:5
    <<: *environment
    volumes:
      - /mnt/tank/persist/example.com/invoice/production/public:/var/www/app/public:rw,delegated
      - /mnt/tank/persist/example.com/invoice/production/storage:/var/www/app/storage:rw,delegated
    depends_on:
      - db
    networks:
      - default
      - traefik
    deploy:
      replicas: 1
      placement:
        constraints:
          - node.labels.mac-rack == true
      labels:
        - "traefik.enable=true"
        - "traefik.http.routers.invoice.tls=true"
        - "traefik.http.services.invoice.loadbalancer.server.port=9000"
        - "traefik.http.routers.invoice.rule=Host(`invoice.example.com`)"
        - "traefik.http.routers.invoice.entrypoints=websecure"
        - "traefik.http.routers.invoice.tls.certresolver=letsencryptresolver"
        - "traefik.http.routers.invoice.service=invoice"

  db:
    image: mysql:8

    <<: *environment
    volumes:
      - /mnt/tank/persist/example.com/invoice/production/db:/var/lib/mysql:rw,delegated

      # remove comments for next 4 lines if you want auto sql backups
      #- ./docker/mysql/bak:/backups:rw
      #- ./config/mysql/backup-script:/etc/cron.daily/daily:ro
      #- ./config/mysql/backup-script:/etc/cron.weekly/weekly:ro
      #- ./config/mysql/backup-script:/etc/cron.monthly/monthly:ro
    networks:
      - default
    deploy:
      replicas: 1
      placement:
        constraints:
          - node.labels.mac-rack == true
      labels:
        - traefik.enable=false

networks:
  traefik:
    external: true
  default:
Leopere commented 1 year ago

So it seems to be able to connect immediately after ditching mysql:8 for mariadb:latest