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

Errors while trying to deploy with docker #116

Closed
amgno opened this issue Jun 26, 2024 · 7 comments
Closed

Errors while trying to deploy with docker #116

amgno opened this issue Jun 26, 2024 · 7 comments
Labels
troubleshooting Debugging user application

Comments

@amgno
Copy link

amgno commented Jun 26, 2024

image

nextjs-app-1  | sql get error: password authentication failed for user "postgres" 
postgres-1    | 2024-06-26 12:18:56.804 UTC [37] FATAL:  password authentication failed for user "postgres"
nextjs-app-1  | sql get error: password authentication failed for user "postgres" 
nextjs-app-1  | sql get error: password authentication failed for user "postgres" 
nextjs-app-1  | sql get error: password authentication failed for user "postgres" 
postgres-1    | 2024-06-26 12:18:56.804 UTC [37] DETAIL:  Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256"
nextjs-app-1  | sql get error: password authentication failed for user "postgres" 
nextjs-app-1  | sql get error: password authentication failed for user "postgres" 
postgres-1    | 2024-06-26 12:18:56.804 UTC [36] FATAL:  password authentication failed for user "postgres"
postgres-1    | 2024-06-26 12:18:56.804 UTC [36] DETAIL:  Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256"
postgres-1    | 2024-06-26 12:18:56.804 UTC [38] FATAL:  password authentication failed for user "postgres"
postgres-1    | 2024-06-26 12:18:56.804 UTC [38] DETAIL:  Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256"
postgres-1    | 2024-06-26 12:18:56.804 UTC [34] FATAL:  password authentication failed for user "postgres"
nextjs-app-1  | sql get error: password authentication failed for user "postgres" 
postgres-1    | 2024-06-26 12:18:56.804 UTC [34] DETAIL:  Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256"
postgres-1    | 2024-06-26 12:18:56.804 UTC [35] FATAL:  password authentication failed for user "postgres"
postgres-1    | 2024-06-26 12:18:56.804 UTC [35] DETAIL:  Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256"
postgres-1    | 2024-06-26 12:18:56.804 UTC [39] FATAL:  password authentication failed for user "postgres"
postgres-1    | 2024-06-26 12:18:56.804 UTC [39] DETAIL:  Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256"
postgres-1    | 2024-06-26 12:18:56.804 UTC [40] FATAL:  password authentication failed for user "postgres"
postgres-1    | 2024-06-26 12:18:56.804 UTC [40] DETAIL:  Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256"
postgres-1    | 2024-06-26 12:18:56.805 UTC [33] FATAL:  password authentication failed for user "postgres"
postgres-1    | 2024-06-26 12:18:56.805 UTC [33] DETAIL:  Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256"
postgres-1    | 2024-06-26 12:18:57.237 UTC [41] FATAL:  password authentication failed for user "postgres"
postgres-1    | 2024-06-26 12:18:57.237 UTC [41] DETAIL:  Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256"

.env file:

POSTGRES_URL="postgresql://postgres:postgres@postgres:5432/postgres"
DISABLE_POSTGRES_SSL=1

Docker-compose file:

version: '3.9'

services:
  nextjs-app:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    depends_on:
      - postgres

  postgres:
    image: 'postgres:latest'
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: postgres
    ports:
      - '5432:5432'
    volumes:
      - postgres-data:/var/lib/postgresql/data

volumes:
  postgres-data:

Dockerfile:

FROM node

WORKDIR /app

RUN npm install -g pnpm

COPY . .

RUN pnpm install


EXPOSE 3000


CMD ["npm", "run", "dev"]
@amgno
Copy link
Author

amgno commented Jun 26, 2024

Ok I fixed it, problem on my part. My bad
But I keep getting this error when trying to upload an image:
image

@amgno amgno changed the title Postgres connection problem, password authentication failed Errors while trying to deploy with docker Jun 26, 2024
@amgno
Copy link
Author

amgno commented Jun 26, 2024

Trying to host behind caddy and getting this:
nextjs-app_1  | [auth][error] UntrustedHost: Host must be trusted. URL was: https://myhostname/api/auth/session. Read more at https://errors.authjs.dev#untrustedhost
nextjs-app_1  |     at h (/app/.next/server/chunks/6763.js:405:1241)
nextjs-app_1  |     at c (/app/.next/server/chunks/6763.js:29:23635)

Evne tho the env variable is correct

@amgno
Copy link
Author

amgno commented Jun 26, 2024

When trying to login it sends me to:
https://localhost:3000/admin/photos

@amgno
Copy link
Author

amgno commented Jun 27, 2024

Managed to get it to work, even if it redirects me to another page.
Still now I'm getting "failed to fetch" when trying to upload an image

@amgno
Copy link
Author

amgno commented Jun 27, 2024

Everything works now. I'll leave what I did here since I don't really know how to use git

Dockerfile


FROM node

WORKDIR /app

RUN npm install -g pnpm

COPY . .

RUN pnpm install

EXPOSE 3000

RUN npm run build

CMD ["npm", "start"]

Docker-compose

version: '3.9'

services:
  nextjs-app:
    build:
      context: .
      dockerfile: Dockerfile
    depends_on:
      - postgres
    volumes:
      - .env:/app/.env

  postgres:
    image: 'postgres:latest'
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: postgres
    ports:
      - '5432:5432'
    volumes:
      - ./db:/var/lib/postgresql/data


networks:
  caddy:
    external: true


.dockerignore

db/**/*
db
db/*

.env

AUTH_TRUST_HOST=1
POSTGRES_URL=postgresql://postgres:postgres@dev.magno.me:5432/postgres
DISABLE_POSTGRES_SSL=1

Might be not optimized or efficient, I'm a beginner 🙌

@amgno
Copy link
Author

amgno commented Jun 27, 2024

Only thing that remains is the storage, i'm using cloudflare but I would love to use a selfhosted method.
I'm no capable to do it myself tho.
😭

@sambecker sambecker added the troubleshooting Debugging user application label Jun 29, 2024
@sambecker
Copy link
Owner

Not sure how a self-hosted image solution would work, especially given the constraints of next/image. Closing for now, but linking to this issue in the FAQ in case there's more curiosity on the topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
troubleshooting Debugging user application
Projects
None yet
Development

No branches or pull requests

2 participants