Just-Moh-it / Pckd

The ⚡️ analytics-intensive, self-hostable link-shortener with a beautiful UI | AKA free bit.ly alternative 🚀
https://docs.pckd.me/
MIT License
784 stars 95 forks source link

Docker frontend crashing #34

Closed mind-overflow closed 1 year ago

mind-overflow commented 2 years ago

Using either the latest docker image or building it myself, I get this error:

frontend_1  | 2022/06/04 12:57:12 [emerg] 1#1: no host in upstream ":4000" in /etc/nginx/conf.d/default.conf:16
frontend_1  | nginx: [emerg] no host in upstream ":4000" in /etc/nginx/conf.d/default.conf:16
frontend_1  | Starting NGINX...
pckd-url-shortener_frontend_1 exited with code 1

Which makes Pckd unreachable from the web.

t-anc commented 2 years ago

Make sure you've set the env variable "BACKEND_URL" in your front container, it should fix the "nginx: [emerg] no host in upstream ":4000"" error.

gillbeits commented 2 years ago

This is because in docker-compose the client must depend on the server

version: "3"

services:
  server:
    build:
      context: ./server
    volumes:
      - ./logs:/home/node/app/logs
    environment:
      - DATABASE_URL=postgresql://postgres:postgres@db/pckd
      - DATABASE_TYPE=postgres

      - JWT_SECRET=verysecurestring
      - IPREGISTRY_API_KEY=f1ntkcjoqaazglj7
    depends_on:
      - db

  frontend:
    build:
      context: ./client
    ports:
      - 80:80
    environment:
      - BACKEND_URL=http://server:4000
    depends_on:
      - server

  db:
    image: postgres:13-alpine
    volumes:
      - ./db:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=pckd