feat: support self-host docker build (#5506)

Test command: `docker compose -f ./.github/deployment/self-host/compose.yaml up`
This commit is contained in:
LongYinan
2024-01-10 08:35:21 +00:00
parent 0d7ffb0511
commit 237722f7f9
20 changed files with 241 additions and 37 deletions
@@ -179,7 +179,7 @@ export const NextAuthOptionsProvider: FactoryProvider<NextAuthOptions> = {
);
}
if (config.auth.oauthProviders.google) {
if (config.auth.oauthProviders.google?.enabled) {
nextAuthOptions.providers.push(
// @ts-expect-error esm interop issue
Google.default({
@@ -186,15 +186,17 @@ export class NextAuthController {
}
let nextAuthTokenCookie: (CookieOption & { value: string }) | undefined;
const cookiePrefix = this.config.node.prod ? '__Secure-' : '';
const sessionCookieName = `${cookiePrefix}next-auth.session-token`;
const secureCookiePrefix = '__Secure-';
const sessionCookieName = `next-auth.session-token`;
// next-auth credentials login only support JWT strategy
// https://next-auth.js.org/configuration/providers/credentials
// let's store the session token in the database
if (
credentialsSignIn &&
(nextAuthTokenCookie = cookies?.find(
({ name }) => name === sessionCookieName
({ name }) =>
name === sessionCookieName ||
name === `${secureCookiePrefix}${sessionCookieName}`
))
) {
const cookieExpires = new Date();
+7 -1
View File
@@ -1,5 +1,8 @@
import { join } from 'node:path';
import { DynamicModule, Type } from '@nestjs/common';
import { ScheduleModule } from '@nestjs/schedule';
import { ServeStaticModule } from '@nestjs/serve-static';
import { SERVER_FLAVOR } from '../config';
import { GqlModule } from '../graphql.module';
@@ -29,7 +32,10 @@ switch (SERVER_FLAVOR) {
UsersModule,
SyncModule,
DocModule,
StorageModule
StorageModule,
ServeStaticModule.forRoot({
rootPath: join('/app', 'static'),
})
);
break;
case 'graphql':