metacpan / metacpan-docker

DEVELOPMENT Docker configs for MetaCPAN
Artistic License 2.0
26 stars 23 forks source link

Pg exits after "up" in workflow run #70

Closed oalders closed 1 year ago

oalders commented 4 years ago

It's not clear why the Pg container exits early.

              Name                             Command                       State                             Ports                   
---------------------------------------------------------------------------------------------------------------------------------------
metacpan_api_1                      /wait-for-it.sh db:5432 -- ...   Up                      0.0.0.0:5000->5000/tcp                    
metacpan_elasticsearch_1            /docker-entrypoint.sh elas ...   Up                      0.0.0.0:9200->9200/tcp, 9300/tcp          
metacpan_elasticsearch_test_1       /docker-entrypoint.sh elas ...   Up                      0.0.0.0:9900->9200/tcp, 9300/tcp          
metacpan_github-meets-cpan-cron_1   /wait-for-it.sh mongodb:27 ...   Exit 255                                                          
metacpan_github-meets-cpan_1        /wait-for-it.sh mongodb:27 ...   Up                      3000/tcp                                  
metacpan_grep_1                     /bin/sh -c plackup -p 3000 ...   Up                      3000/tcp                                  
metacpan_logspout_1                 /bin/logspout                    Up                      0.0.0.0:8100->80/tcp                      
metacpan_mongodb_1                  docker-entrypoint.sh mongod      Up (health: starting)   27017/tcp                                 
metacpan_pgdb_1                     docker-entrypoint.sh postgres    Exit 1                                                            
metacpan_traefik_1                  /entrypoint.sh --api.insec ...   Up                      0.0.0.0:80->80/tcp, 0.0.0.0:8080->8080/tcp
metacpan_web_1                      plackup -p 5001 -r               Up                      0.0.0.0:5001->5001/tcp   
waterkip commented 2 years ago
$ docker-compose up pgdb
Attaching to metacpan_pgdb_1
pgdb_1                    | Error: Database is uninitialized and superuser password is not specified.
pgdb_1                    |        You must specify POSTGRES_PASSWORD to a non-empty value for the
pgdb_1                    |        superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".
pgdb_1                    |
pgdb_1                    |        You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all
pgdb_1                    |        connections without a password. This is *not* recommended.
pgdb_1                    |
pgdb_1                    |        See PostgreSQL documentation about "trust":
pgdb_1                    |        https://www.postgresql.org/docs/current/auth-trust.html

It seems you need to supply a username/password to the env of the postgres container. The following patch already resolves the issue of exit 1 and configures the container.

$ git d
diff --git i/docker-compose.yml w/docker-compose.yml
index 8dac455..dd05bf4 100644
--- i/docker-compose.yml
+++ w/docker-compose.yml
@@ -244,6 +244,10 @@ services:
       context: "./pg"
       args:
         PG_TAG: "${PG_VERSION_TAG:-9.6-alpine}"
+    environment:
+      POSTGRES_PASSWORD: metacpan
+      POSTGRES_USERNAME: metacpan123
+      POSTGRES_DB: metacpan
     networks:
       - database
     healthcheck:

Which leads to another issue:

api_1                     | wait-for-it.sh: timeout occurred after waiting 15 seconds for db:5432
api_1                     | Server available at http://127.0.0.1:5000
api_1                     | Can't load application from file "/metacpan-api/bin/api.pl": DBI connect('dbname=minion_queue;host=pgdb','metacpan',...) failed: fe_sendauth: no password supplied at /usr/local/lib/perl5/site_perl/5.30.1/Mojo/Pg.pm line 91.
api_1                     | Compilation failed in require at (eval 91) line 1.
bodo-hugo-barwich commented 1 year ago

I noticed the suggested changes were implemented. And also the Automated Operativity Test is successful Automated Operativity Test for the Component pgdb

Component 'pgdb' finished with:
 pgdb_1 | PostgreSQL init process complete; ready for start up. 
 pgdb_1 | 
pgdb_1 | LOG: database system was shut down at 2022-12-29 13:19:11 UTC 
pgdb_1 | LOG: MultiXact member wraparound protections are now enabled 
pgdb_1 | LOG: database system is ready to accept connections 
pgdb_1 | LOG: autovacuum launcher started 
pgdb_1 | LOG: incomplete startup packet

So, it seems as if this issue is solved now.

oalders commented 1 year ago

Thanks so much @bodo-hugo-barwich!