plankanban / planka

The realtime kanban board for workgroups built with React and Redux.
https://planka.app
GNU Affero General Public License v3.0
8.15k stars 769 forks source link

Docker build not accepting connections #34

Open rickyelopez opened 4 years ago

rickyelopez commented 4 years ago

Maybe I'm doing something silly, but don't see where I could be messing up...

docker-compose.yml:

version: '3'

services:
  planka:
    image: meltyshev/planka:latest
    command: >
      bash -c
        "for i in `seq 1 30`; do
          ./start.sh &&
          s=$$? && break || s=$$?;
          echo \"Tried $$i times. Waiting 5 seconds...\";
          sleep 5;
        done; (exit $$s)"
    restart: unless-stopped
    volumes:
      - /servers/planka/user-avatars:/app/public/user-avatars
      - /servers/planka/project-background-images:/app/public/project-background-images
      - /servers/planka/attachments:/app/public/attachments
    ports:
      - 3750:1337
    environment:
      - BASE_URL=http://192.168.2.15:3750
      - DATABASE_URL=postgresql://postgres@postgres/planka
      - SECRET_KEY=a0bafe5f4166c7b7052597dd61a715f72c12dcb40ba1fa6a03da879af6d864b0357a406dbf8f548a014d037dffabc157d40d25414d4016eb18adb1de949cfc12
    depends_on:

Can't connect at all (double checked port is open), I see this error in the docker-compose logs on first startup, no errors following that:

planka_1    | (node:9) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 172.30.0.2:5432
planka_1    |     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
planka_1    | (node:9) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 5)
planka_1    | (node:9) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
planka_1    | Tried 1 times. Waiting 5 seconds...

Any other info I can provide to be helpful?

meltyshev commented 4 years ago

Hi! It seems that the server cannot connect to the database. Do you have postgres service in the docker-compose.yml?

rickyelopez commented 4 years ago

Hi there! Yes, I do, I'm pretty much using the sample docker-compose.yml. See below for full docker-compose.yml file:

version: '3'

services:
  planka:
    image: meltyshev/planka:latest
    command: >
      bash -c
        "for i in `seq 1 30`; do
          ./start.sh &&
          s=$$? && break || s=$$?;
          echo \"Tried $$i times. Waiting 5 seconds...\";
          sleep 5;
        done; (exit $$s)"
    restart: unless-stopped
    volumes:
      - /servers/planka/user-avatars:/app/public/user-avatars
      - /servers/planka/project-background-images:/app/public/project-background-images
      - /servers/planka/attachments:/app/public/attachments
    ports:
      - 4000:1337
    environment:
      - BASE_URL=http://192.168.2.15:4000
      - DATABASE_URL=postgresql://postgres@postgres/planka
      - SECRET_KEY=a0bafe5f4166c7b7052597dd61a715f72c12dcb40ba1fa6a03da879af6d864b0357a406dbf8f548a014d037dffabc157d40d25414d4016eb18adb1de949cfc12
    depends_on:
      - postgres

  postgres:
    image: postgres:alpine
    restart: unless-stopped
    volumes:
      - /servers/planka/db-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=planka
      - POSTGRES_HOST_AUTH_METHOD=trust

volumes:
  user-avatars:
  project-background-images:
  attachments:
  db-data:
meltyshev commented 4 years ago

Ah no, it's an ok error, I have the same. It happens because Postgres doesn't have enough time to initialize (it fixes by retry timeout in the command section). What address do you use in the browser to access Planka?

rickyelopez commented 4 years ago

OK makes sense. I tried with the hostname and the ip, nothing. I also tried using the hostname, localhost and 0.0.0.0 in the base url in the docker-compose.yml. Tried different ports too. No luck

rickyelopez commented 4 years ago

Could it be because the containers that end up getting created are called planka_postgres_1 and planka_planka_1 but the docker-compose refers to the postgres server with postgres/planka?

rickyelopez commented 4 years ago

Nevermind, just tried adjusting the url in docker-compose.yml accordingly and it didn't change anything

rickyelopez commented 4 years ago

Here's a full log, maybe that will point to something:

Attaching to planka_postgres_1, planka_planka_1
postgres_1  | ********************************************************************************
postgres_1  | WARNING: POSTGRES_HOST_AUTH_METHOD has been set to "trust". This will allow
postgres_1  |          anyone with access to the Postgres port to access your database without
postgres_1  |          a password, even if POSTGRES_PASSWORD is set. See PostgreSQL
postgres_1  |          documentation about "trust":
postgres_1  |          https://www.postgresql.org/docs/current/auth-trust.html
postgres_1  |          In Docker's default configuration, this is effectively any other
postgres_1  |          container on the same system.
postgres_1  | 
postgres_1  |          It is not recommended to use POSTGRES_HOST_AUTH_METHOD=trust. Replace
postgres_1  |          it with "-e POSTGRES_PASSWORD=password" instead to set a password in
postgres_1  |          "docker run".
postgres_1  | ********************************************************************************
postgres_1  | The files belonging to this database system will be owned by user "postgres".
postgres_1  | This user must also own the server process.
postgres_1  | 
planka_1    | (node:9) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 192.168.64.2:5432
planka_1    |     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
postgres_1  | The database cluster will be initialized with locale "en_US.utf8".
postgres_1  | The default database encoding has accordingly been set to "UTF8".
postgres_1  | The default text search configuration will be set to "english".
postgres_1  | 
postgres_1  | Data page checksums are disabled.
postgres_1  | 
postgres_1  | fixing permissions on existing directory /var/lib/postgresql/data ... ok
planka_1    | (node:9) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 5)
planka_1    | (node:9) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
postgres_1  | creating subdirectories ... ok
postgres_1  | selecting dynamic shared memory implementation ... posix
postgres_1  | selecting default max_connections ... 100
postgres_1  | selecting default shared_buffers ... 128MB
postgres_1  | selecting default time zone ... UTC
postgres_1  | creating configuration files ... ok
postgres_1  | running bootstrap script ... ok
postgres_1  | performing post-bootstrap initialization ... sh: locale: not found
postgres_1  | 2020-09-09 20:31:51.540 UTC [32] WARNING:  no usable system locales were found
postgres_1  | ok
postgres_1  | syncing data to disk ... initdb: warning: enabling "trust" authentication for local connections
postgres_1  | You can change this by editing pg_hba.conf or using the option -A, or
postgres_1  | --auth-local and --auth-host, the next time you run initdb.
postgres_1  | ok
postgres_1  | 
postgres_1  | 
postgres_1  | Success. You can now start the database server using:
postgres_1  | 
postgres_1  |     pg_ctl -D /var/lib/postgresql/data -l logfile start
postgres_1  | 
postgres_1  | waiting for server to start....2020-09-09 20:31:52.642 UTC [37] LOG:  starting PostgreSQL 12.4 on x86_64-pc-linux-musl, compiled by gcc (Alpine 9.3.0) 9.3.0, 64-bit
postgres_1  | 2020-09-09 20:31:52.659 UTC [37] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
planka_1    | Tried 1 times. Waiting 5 seconds...
postgres_1  | 2020-09-09 20:31:52.735 UTC [38] LOG:  database system was shut down at 2020-09-09 20:31:51 UTC
postgres_1  | 2020-09-09 20:31:52.752 UTC [37] LOG:  database system is ready to accept connections
postgres_1  |  done
postgres_1  | server started
postgres_1  | CREATE DATABASE
postgres_1  | 
postgres_1  | 
postgres_1  | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
postgres_1  | 
postgres_1  | waiting for server to shut down....2020-09-09 20:31:53.137 UTC [37] LOG:  received fast shutdown request
postgres_1  | 2020-09-09 20:31:53.158 UTC [37] LOG:  aborting any active transactions
postgres_1  | 2020-09-09 20:31:53.159 UTC [37] LOG:  background worker "logical replication launcher" (PID 44) exited with exit code 1
postgres_1  | 2020-09-09 20:31:53.159 UTC [39] LOG:  shutting down
postgres_1  | 2020-09-09 20:31:53.248 UTC [37] LOG:  database system is shut down
postgres_1  |  done
postgres_1  | server stopped
postgres_1  | 
postgres_1  | PostgreSQL init process complete; ready for start up.
postgres_1  | 
postgres_1  | 2020-09-09 20:31:53.362 UTC [1] LOG:  starting PostgreSQL 12.4 on x86_64-pc-linux-musl, compiled by gcc (Alpine 9.3.0) 9.3.0, 64-bit
postgres_1  | 2020-09-09 20:31:53.362 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
postgres_1  | 2020-09-09 20:31:53.362 UTC [1] LOG:  listening on IPv6 address "::", port 5432
postgres_1  | 2020-09-09 20:31:53.396 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1  | 2020-09-09 20:31:53.480 UTC [48] LOG:  database system was shut down at 2020-09-09 20:31:53 UTC
postgres_1  | 2020-09-09 20:31:53.502 UTC [1] LOG:  database system is ready to accept connections
planka_1    | FS-related option specified for migration configuration. This resets migrationSource to default FsMigrations
planka_1    | FS-related option specified for migration configuration. This resets migrationSource to default FsMigrations
planka_1    | debug: Detected Sails environment is "production", but NODE_ENV is `undefined`.
planka_1    | debug: Automatically setting the NODE_ENV environment variable to "production".
planka_1    | debug: 
planka_1    | debug: -------------------------------------------------------
planka_1    | debug: :: Wed Sep 09 2020 20:32:00 GMT+0000 (Coordinated Universal Time)
planka_1    | debug: Environment : production
planka_1    | debug: Port        : 1337
planka_1    | debug: -------------------------------------------------------
Gracefully stopping... (press Ctrl+C again to force)
meltyshev commented 4 years ago

It looks like the server is properly lifted, so something in the network or docker settings. Try to exec docker container ls it should be 0.0.0.0:[YOUR_PORT]->1337/tcp in the PORTS column. Can you try to run some other app like Rocket.Chat?

rickyelopez commented 4 years ago

Yes the output of that command is as expected. I'm running about 5 other apps through docker containers, and all of the rest of them are accessible, so I doubt it's a network thing...

peterk commented 4 years ago

I tried to reproduce this error but could not. My docker environment is on Windows 10 with the Linux subsystem. I set ports to 4000:1337 and BASE_URL=http://localhost:4000

docker ps gives 0.0.0.0:4000->1337/tcp

What is the output of docker-compose exec planka wget -qO- 'http://0.0.0.0:1337' ? Is the web server in the container responding?

phrogg commented 4 years ago

I have the same issue, anyone found out something?

zahidhanif commented 4 years ago

I had the same issue was really disappointed because I wanted to get give this a go. Instead of using docker compose, I used the docker CLI. I created a separate Postgres container for shared databases across containers, a Postgres network and it all ran fine. I can post my docker CLI code if anyone is interested.

kaythomas0 commented 4 years ago

I was running into this same error, I fixed it by changing the postgres container's image to postgres:12-alpine in the docker-compose file.

phrogg commented 4 years ago

For me the problem was related to planka not finding postgres (I'm using Portainer). I fixed it by changing this line: - DATABASE_URL=postgresql://postgres@postgres/planka to my the ip of my portainer machine: - DATABASE_URL=postgresql://postgres@10.10.10.10/planka.

vorwd commented 7 months ago

I also had this issue, and it was due to my Nginx Proxy Manager setup. Had the proxy configured properly, with websockets enabled, but forgot to setup a stream for the database. Added a proxy stream with the protgres port pointing to postgres container and all started working.