sambecker / exif-photo-blog

Photo blog, reporting 🤓 EXIF camera details (aperture, shutter speed, ISO) for each image.
https://photos.sambecker.com
644 stars 92 forks source link

Errors while trying to deploy with docker #116

Closed amgno closed 2 weeks ago

amgno commented 2 weeks ago

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 commented 2 weeks ago

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

amgno commented 2 weeks ago
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 commented 2 weeks ago

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

amgno commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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.