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

ghost using SQLite despite env variables using Mysql #192

Closed
Windyo opened this issue Aug 23, 2019 · 5 comments
Closed

ghost using SQLite despite env variables using Mysql #192

Windyo opened this issue Aug 23, 2019 · 5 comments

Comments

@Windyo
Copy link

Windyo commented Aug 23, 2019

Probably linked to #176

Steps:

  • have docker
  • launch a ghost container using the demo setup:

services:

  ghost:
    image: ghost:1-alpine
    restart: always
    ports:
      - 8080:2368
    environment:
      # see https://docs.ghost.org/docs/config#section-running-ghost-with-config-env-variables
      database__client: mysql
      database__connection__host: db
      database__connection__user: root
      database__connection__password: example
      database__connection__database: ghost

  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example```

note that ghost is still using SQLite instead of MySQL on run
@tianon
Copy link
Member

tianon commented Aug 23, 2019

Have you tried with Ghost 2? Did the configuration parameters change between 1 and 2?

@wglambert
Copy link

I can't reproduce

when starting the containers ghost will error and restart while mysql initializes

[2019-08-23 22:01:50] ERROR

NAME: RollbackError                                                                                                                               
CODE: ECONNREFUSED
MESSAGE: connect ECONNREFUSED 192.168.80.3:3306

level:normal

OuterError: The server has encountered an error.
RollbackError: connect ECONNREFUSED 192.168.80.3:3306
    at RollbackError.KnexMigrateError (/var/lib/ghost/versions/1.26.0/node_modules/knex-migrator/lib/errors.js:7:26)                              
    at new RollbackError (/var/lib/ghost/versions/1.26.0/node_modules/knex-migrator/lib/errors.js:32:26)                                          
    at /var/lib/ghost/versions/1.26.0/node_modules/knex-migrator/lib/index.js:212:23                                                              
    at tryCatcher (/var/lib/ghost/versions/1.26.0/node_modules/bluebird/js/release/util.js:16:23)                                                 
    at Promise._settlePromiseFromHandler (/var/lib/ghost/versions/1.26.0/node_modules/bluebird/js/release/promise.js:512:31)                      
    at Promise._settlePromise (/var/lib/ghost/versions/1.26.0/node_modules/bluebird/js/release/promise.js:569:18)                                 
    at Promise._settlePromise0 (/var/lib/ghost/versions/1.26.0/node_modules/bluebird/js/release/promise.js:614:10)                                
    at Promise._settlePromises (/var/lib/ghost/versions/1.26.0/node_modules/bluebird/js/release/promise.js:689:18)                                
    at Async._drainQueue (/var/lib/ghost/versions/1.26.0/node_modules/bluebird/js/release/async.js:133:16)                                        
    at Async._drainQueues (/var/lib/ghost/versions/1.26.0/node_modules/bluebird/js/release/async.js:143:10)                                       
    at Immediate.Async.drainQueues (/var/lib/ghost/versions/1.26.0/node_modules/bluebird/js/release/async.js:17:14)                               
    at runCallback (timers.js:810:20)                                                                                                             
    at tryOnImmediate (timers.js:768:5)                                                                                                           
    at processImmediate [as _immediateCallback] (timers.js:745:5)                                                                                 

Error: connect ECONNREFUSED 192.168.80.3:3306                                                                                                     
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)                                                                               
    --------------------                                                                                                                          
    at Protocol._enqueue (/var/lib/ghost/versions/1.26.0/node_modules/mysql/lib/protocol/Protocol.js:145:48)                                      
    at Protocol.handshake (/var/lib/ghost/versions/1.26.0/node_modules/mysql/lib/protocol/Protocol.js:52:23)                                      
    at Connection.connect (/var/lib/ghost/versions/1.26.0/node_modules/mysql/lib/Connection.js:130:18)                                            
    at /var/lib/ghost/versions/1.26.0/node_modules/knex/lib/dialects/mysql/index.js:109:18                                                        
    at Promise._execute (/var/lib/ghost/versions/1.26.0/node_modules/bluebird/js/release/debuggability.js:303:9)                                  
    at Promise._resolveFromExecutor (/var/lib/ghost/versions/1.26.0/node_modules/bluebird/js/release/promise.js:483:18)                           
    at new Promise (/var/lib/ghost/versions/1.26.0/node_modules/bluebird/js/release/promise.js:79:10)                                             
    at Client_MySQL.acquireRawConnection (/var/lib/ghost/versions/1.26.0/node_modules/knex/lib/dialects/mysql/index.js:104:12)                    
    at create (/var/lib/ghost/versions/1.26.0/node_modules/knex/lib/client.js:283:23)                                                             
    at tryPromise (/var/lib/ghost/versions/1.26.0/node_modules/tarn/lib/Pool.js:366:22)                                                           
    at tryPromise (/var/lib/ghost/versions/1.26.0/node_modules/tarn/lib/utils.js:57:20)                                                           
    at Promise (/var/lib/ghost/versions/1.26.0/node_modules/tarn/lib/Pool.js:366:5)                                                               
    at Promise._execute (/var/lib/ghost/versions/1.26.0/node_modules/bluebird/js/release/debuggability.js:303:9)                                  
    at Promise._resolveFromExecutor (/var/lib/ghost/versions/1.26.0/node_modules/bluebird/js/release/promise.js:483:18)                           
    at new Promise (/var/lib/ghost/versions/1.26.0/node_modules/bluebird/js/release/promise.js:79:10)                                             
    at callbackOrPromise (/var/lib/ghost/versions/1.26.0/node_modules/tarn/lib/Pool.js:357:10)

Eventually ghost will establish a connection

[2019-08-23 22:02:26] INFO Creating table: posts
[2019-08-23 22:02:30] INFO Creating table: users
[2019-08-23 22:02:32] INFO Creating table: posts_authors
[2019-08-23 22:02:38] INFO Creating table: roles
[2019-08-23 22:02:40] INFO Creating table: roles_users
[2019-08-23 22:02:42] INFO Creating table: permissions
[2019-08-23 22:02:44] INFO Creating table: permissions_users
[2019-08-23 22:02:46] INFO Creating table: permissions_roles
[2019-08-23 22:02:48] INFO Creating table: permissions_apps
[2019-08-23 22:02:50] INFO Creating table: settings
[2019-08-23 22:02:52] INFO Creating table: tags
[2019-08-23 22:02:58] INFO Creating table: posts_tags
[2019-08-23 22:03:03] INFO Creating table: apps
[2019-08-23 22:03:07] INFO Creating table: app_settings
[2019-08-23 22:03:11] INFO Creating table: app_fields
[2019-08-23 22:03:15] INFO Creating table: clients
[2019-08-23 22:03:17] INFO Creating table: client_trusted_domains
[2019-08-23 22:03:21] INFO Creating table: accesstokens
[2019-08-23 22:03:30] INFO Creating table: refreshtokens
[2019-08-23 22:03:36] INFO Creating table: subscribers
[2019-08-23 22:03:38] INFO Creating table: invites
[2019-08-23 22:03:40] INFO Creating table: brute
[2019-08-23 22:03:40] INFO Creating table: webhooks
[2019-08-23 22:03:42] INFO Model: Tag
[2019-08-23 22:03:42] INFO Model: Client
[2019-08-23 22:03:42] INFO Model: Role
[2019-08-23 22:03:42] INFO Model: Permission
[2019-08-23 22:03:42] INFO Model: User
[2019-08-23 22:03:43] INFO Model: Post
[2019-08-23 22:03:45] INFO Relation: Role to Permission
[2019-08-23 22:03:46] INFO Relation: Post to Tag
[2019-08-23 22:03:46] INFO Relation: User to Role
[2019-08-23 22:03:46] INFO Finished database migration! 
[2019-08-23 22:03:50] WARN Theme's file locales/en.json not found.
[2019-08-23 22:03:50] INFO Ghost is running in production...
[2019-08-23 22:03:50] INFO Your blog is now available on http://localh
[2019-08-23 22:03:50] INFO Ctrl+C to shut down
[2019-08-23 22:03:50] INFO Ghost boot 3.521s

Verifying the data is in the mysql container

$ docker exec -it ghost_db_1 mysql -pexample

mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 34
Server version: 5.7.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> USE ghost;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+------------------------+
| Tables_in_ghost        |
+------------------------+
| accesstokens           |
| app_fields             |
| app_settings           |
| apps                   |
| brute                  |
| client_trusted_domains |
| clients                |
| invites                |
| migrations             |
| migrations_lock        |
| permissions            |
| permissions_apps       |
| permissions_roles      |
| permissions_users      |
| posts                  |
| posts_authors          |
| posts_tags             |
| refreshtokens          |
| roles                  |
| roles_users            |
| settings               |
| subscribers            |
| tags                   |
| users                  |
| webhooks               |
+------------------------+
25 rows in set (0.00 sec)

@Windyo
Copy link
Author

Windyo commented Aug 23, 2019

weird. I've tried with 1 and 2, both still use SQlite...
I'll look into it tomorrow

@tianon
Copy link
Member

tianon commented Sep 5, 2019

Closing since this appears to be resolved and/or environmental.

For further help, I'd suggest trying the Docker Community Forums, the Docker Community Slack, or Stack Overflow.

@tianon tianon closed this as completed Sep 5, 2019
@Torqu3Wr3nch
Copy link

Same issue here, though oddly enough the database is created and the tables are populated appropriately. Head scratch Not sure why this appears to be working...

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

4 participants