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

secret missing in docker image. #31

Open
P6g9YHK6 opened this issue Mar 18, 2023 · 7 comments
Open

secret missing in docker image. #31

P6g9YHK6 opened this issue Mar 18, 2023 · 7 comments

Comments

@P6g9YHK6
Copy link

the new docker image produce this error on my side:

[next-auth][error][NO_SECRET]
https://next-auth.js.org/errors#no_secret
Warning: For production Image Optimization with Next.js, the optional 'sharp' package is strongly recommended. Run 'yarn add sharp', and Next.js will use it automatically for Image Optimization.
Read more: https://nextjs.org/docs/messages/sharp-missing-in-production
[next-auth][error][NO_SECRET]
https://next-auth.js.org/errors#no_secret Please define a secret in production. MissingSecret [MissingSecretError]: Please define a secret in production.
at assertConfig (/app/node_modules/next-auth/core/lib/assert.js:42:12)
at AuthHandler (/app/node_modules/next-auth/core/index.js:70:52)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async NextAuthHandler (/app/node_modules/next-auth/next/index.js:24:19)
at async /app/node_modules/next-auth/next/index.js:60:32
at async Object.apiResolver (/app/node_modules/next/dist/server/api-utils/node.js:372:9)
at async NextNodeServer.runApi (/app/node_modules/next/dist/server/next-server.js:514:9)
at async Object.fn (/app/node_modules/next/dist/server/next-server.js:828:35)
at async Router.execute (/app/node_modules/next/dist/server/router.js:243:32)
at async NextNodeServer.runImpl (/app/node_modules/next/dist/server/base-server.js:432:29) {
code: 'NO_SECRET'
}
[next-auth][error][NO_SECRET]
https://next-auth.js.org/errors#no_secret
[next-auth][error][NO_SECRET]
https://next-auth.js.org/errors#no_secret
[next-auth][error][NO_SECRET]
https://next-auth.js.org/errors#no_secret
[next-auth][error][NO_SECRET]
https://next-auth.js.org/errors#no_secret Please define a secret in production. MissingSecret [MissingSecretError]: Please define a secret in production.

@thomasWos
Copy link

thomasWos commented Mar 19, 2023

docker run -p 3000:3000 -e NEXTAUTH_SECRET=<random strong password> docker.io/bitswired/ai-chat-app

But then I'm stuck after sign in
Screenshot 2023-03-19 at 12 35 18 pm

@jimzer
Copy link
Contributor

jimzer commented Mar 19, 2023

Hi guys,

With the new version you need to run the Docker image with environment variables as follows:

docker run -p 3000:3000 --env-file=.env aichatapp

Inside the .env file you need the following variables for the single user setup:

DATABASE_URL="file:./db.sqlite"
NEXTAUTH_SECRET="secret"
NEXTAUTH_URL="http://localhost:3000"

[email protected]
ADMIN_PASSWORD=password

For the multi-user setup:

DATABASE_URL="file:./db.sqlite"
NEXTAUTH_SECRET="secret"
NEXTAUTH_URL="http://localhost:3000"

[email protected]

NEXT_PUBLIC_MULTI_USER=1
EMAIL_SERVER_HOST=smtp.gmail.com
EMAIL_SERVER_PORT=465
[email protected]
EMAIL_SERVER_PASSWORD=password
[email protected]

If you use the single-user setup, it uses the ADMIN_EMAIL and ADMIN_PASSWORD for login.

Otherwise, it uses password-less authentication.

Does it solves your issue?

@thomasWos
Copy link

Thanks for that.
For some reasons... the URL with double quotes doesn't work .
Using DATABASE_URL=file:./db.sqlite instead of DATABASE_URL="file:./db.sqlite" fixes the problem.

But then, same result, I cannot login, the page stays blocked on Sign In

@jimzer
Copy link
Contributor

jimzer commented Mar 20, 2023

@thomasWos

Could you try this exact command? It's the one I use, and it works for me. It''s for the single user setup.

docker run -p 3000:3000 \
  -e DATABASE_URL=file:./db.sqlite \
  -e NEXTAUTH_SECRET=secret \
  -e NEXTAUTH_URL=http://localhost:3000/ \
  -e [email protected] \
  -e ADMIN_PASSWORD=password \
  bitswired/ai-chat-app:single-user-latest

Then you should be able to log in with:

@thomasWos
Copy link

It works with this exact command. I can login, thanks!

@jimzer
Copy link
Contributor

jimzer commented Mar 24, 2023

I'm glad it works for you now @thomasWos :)

@thomasWos
Copy link

yeah it works! still have no chat output, but that's another issue.

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

No branches or pull requests

3 participants