asciinema / asciinema-server

Platform for hosting and sharing terminal session recordings
https://docs.asciinema.org/manual/server/
Apache License 2.0
2.31k stars 265 forks source link

Revisit Issue 398 - 502 Bad Gateway (nginx) Resulting from Postgres Issue #399

Closed jeffh-cloudflare closed 10 months ago

jeffh-cloudflare commented 2 years ago

Hello,

I opened issue 398 (502 Bad Gateway) the other day (via an alternate GitHub account), then closed it prematurely. I thought adding a comment to the issue after it was closed would automatically re-open it, but it did not.

The original issue still needs to be resolved. I just tried a fresh installation of asciinema-server using the latest contents in the repository, and still ran into the same issue.

There's far more detail in the original issue, but the crux of it is there's two lines that need to be added to the docker-compose.yml file. Without them, Postgres will not fully instantiate. Without Postgres fully instantiated, the 4 other containers will start, but they will not serve requests.

If you use the current version of docker-compose.yml, and run docker-compose up -d postgres the Postgres container will appear to run, but Postgres never fires us a listener on :5432.

The Postgres container logs display the following message:

Error: Database is uninitialized and superuser password is not specified.
       You must specify POSTGRES_PASSWORD to a non-empty value for the
       superuser. 

If you continue building the remaining containers by running docker-compose up -d they will all appear to start, but you will receive a 502 Bad Gateway error from Nginx.

It's simple enough to resolve this issue by adding the following within the Postgres stanza in docker-compose.yml:

    environment:
      POSTGRES_HOST_AUTH_METHOD: trust

The complete version of the postgres stanza looks like this:

services:
  postgres:
    image: postgres:12-alpine
    environment:
      POSTGRES_HOST_AUTH_METHOD: trust
    container_name: asciinema_postgres
    restart: unless-stopped
    volumes:
      - ./volumes/postgres:/var/lib/postgresql/data
    ### See https://hub.docker.com/_/postgres/ for more
    ### configuration options for this image.

Again, there is far more detail covered in the original issue.

I went ahead and attached a modified version of the original docker-compose.yml file that already contains the fix.

working-docker-compose.yml.txt

ku1ik commented 10 months ago

Thanks for troubleshooting this. I've created new docs site, https://docs.asciinema.org/manual/server/self-hosting/quick-start/ , where I've added the POSTGRES_HOST_AUTH_METHOD=true example.