mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-07-20 12:10:50 +08:00
Adding another service in the frontend-dev docker compose configuration to make it easier to do email based login. Also adding env variables that work by default with the docker services
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
# This DB is for the FastAPI Backend.
|
||||
db:
|
||||
extends:
|
||||
file: ../backend-development/docker-compose.yaml
|
||||
@@ -10,6 +11,23 @@ services:
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 10
|
||||
|
||||
# This DB is for Web Authentication and data caching.
|
||||
webdb:
|
||||
image: postgres
|
||||
restart: always
|
||||
ports:
|
||||
- 5433:5432
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
healthcheck:
|
||||
test: ["CMD", "pg_isready", "-U", "postgres"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 10
|
||||
|
||||
# This lets you manually inspect the web and backend databases.
|
||||
adminer:
|
||||
extends:
|
||||
file: ../backend-development/docker-compose.yaml
|
||||
@@ -26,3 +44,15 @@ services:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- "8080:8080"
|
||||
|
||||
# This fakes and SMTP email server. User registration emails can be found by going to
|
||||
# localhost:1080 and opening the emails listed.
|
||||
maildev:
|
||||
image: maildev/maildev
|
||||
restart: always
|
||||
environment:
|
||||
- MAILDEV_WEB_PORT=1080
|
||||
- MAILDEV_SMTP_PORT=1025
|
||||
ports:
|
||||
- "1080:1080"
|
||||
- "1025:1025"
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# The database created by running the jobs in /scripts/frontend-development/docker-compose.yaml
|
||||
DATABASE_URL=postgres://postgres:postgres@localhost:5433/ocgpt_website
|
||||
|
||||
# The FastAPI backend found by running the jobs in /scripts/frontend-development/docker-compose.yaml
|
||||
FASTAPI_URL=http://localhost:8080
|
||||
FASTAPI_KEY=1234
|
||||
|
||||
# A dev Auth Secret. Can be exposed if we never use this publically.
|
||||
NEXTAUTH_SECRET=O/M2uIbGj+lDD2oyNa8ax4jEOJqCPJzO53UbWShmq98=
|
||||
|
||||
# The SMTP host and port found by running the jobs in /scripts/frontend-development/docker-compose.yaml
|
||||
EMAIL_SERVER_HOST=localhost
|
||||
EMAIL_SERVER_PORT=1025
|
||||
EMAIL_FROM=info@example.com
|
||||
@@ -1,8 +0,0 @@
|
||||
FASTAPI_URL=http://xamla.com:8080
|
||||
FASTAPI_KEY=magic_key
|
||||
|
||||
DISCORD_CLIENT_ID=your_discord_bot_client_id
|
||||
DISCORD_CLIENT_SECRET=your_discord_bot_client_secret
|
||||
|
||||
# Run "openssl rand -base64 32" to get this.
|
||||
NEXTAUTH_SECRET=openssl_result
|
||||
@@ -26,7 +26,6 @@ yarn-error.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# local env files
|
||||
.env
|
||||
.env*.local
|
||||
|
||||
# vercel
|
||||
|
||||
@@ -5,16 +5,12 @@ import { PrismaAdapter } from "@next-auth/prisma-adapter";
|
||||
|
||||
import prisma from "src/lib/prismadb";
|
||||
|
||||
export const authOptions = {
|
||||
// Ensure we can store user data in a database.
|
||||
adapter: PrismaAdapter(prisma),
|
||||
providers: [
|
||||
// Register a Discord auth method.
|
||||
DiscordProvider({
|
||||
clientId: process.env.DISCORD_CLIENT_ID,
|
||||
clientSecret: process.env.DISCORD_CLIENT_SECRET,
|
||||
}),
|
||||
// Register an email magic link auth method.
|
||||
const providers = [];
|
||||
|
||||
console.log(process.env);
|
||||
// Register an email magic link auth method.
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
providers.push(
|
||||
EmailProvider({
|
||||
server: {
|
||||
host: process.env.EMAIL_SERVER_HOST,
|
||||
@@ -25,8 +21,37 @@ export const authOptions = {
|
||||
},
|
||||
},
|
||||
from: process.env.EMAIL_FROM,
|
||||
}),
|
||||
],
|
||||
})
|
||||
);
|
||||
} else {
|
||||
// Register an email magic link auth method.
|
||||
providers.push(
|
||||
EmailProvider({
|
||||
server: {
|
||||
host: process.env.EMAIL_SERVER_HOST,
|
||||
port: process.env.EMAIL_SERVER_PORT,
|
||||
},
|
||||
from: process.env.EMAIL_FROM,
|
||||
async generateVerificationToken() {
|
||||
return "1234";
|
||||
},
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (process.env.DISCORD_CLIENT_ID) {
|
||||
providers.push(
|
||||
DiscordProvider({
|
||||
clientId: process.env.DISCORD_CLIENT_ID,
|
||||
clientSecret: process.env.DISCORD_CLIENT_SECRET,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export const authOptions = {
|
||||
// Ensure we can store user data in a database.
|
||||
adapter: PrismaAdapter(prisma),
|
||||
providers,
|
||||
pages: {
|
||||
signIn: "/auth/signin",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user