mirror of
https://github.com/randyjc/Rahoot.git
synced 2026-03-14 04:25:35 +01:00
fix(docker): fix config files reading & add compose file
This commit is contained in:
@@ -3,10 +3,12 @@ import { z } from "zod/v4"
|
||||
|
||||
const env = createEnv({
|
||||
server: {
|
||||
WEB_ORIGIN: z.string().optional().default("http://localhost:3000"),
|
||||
SOCKER_PORT: z.string().optional().default("3001"),
|
||||
},
|
||||
|
||||
runtimeEnv: {
|
||||
WEB_ORIGIN: process.env.WEB_ORIGIN,
|
||||
SOCKER_PORT: process.env.SOCKER_PORT,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -7,11 +7,15 @@ import Registry from "@rahoot/socket/services/registry"
|
||||
import { withGame } from "@rahoot/socket/utils/game"
|
||||
import { Server as ServerIO } from "socket.io"
|
||||
|
||||
const io: Server = new ServerIO()
|
||||
const io: Server = new ServerIO({
|
||||
cors: {
|
||||
origin: [env.WEB_ORIGIN],
|
||||
},
|
||||
})
|
||||
Config.init()
|
||||
|
||||
const registry = Registry.getInstance()
|
||||
const port = env.SOCKER_PORT || 3001
|
||||
const port = 3001
|
||||
|
||||
console.log(`Socket server running on port ${port}`)
|
||||
io.listen(Number(port))
|
||||
|
||||
@@ -2,8 +2,12 @@ import { QuizzWithId } from "@rahoot/common/types/game"
|
||||
import fs from "fs"
|
||||
import { resolve } from "path"
|
||||
|
||||
const inContainerPath = process.env.CONFIG_PATH
|
||||
|
||||
const getPath = (path: string = "") =>
|
||||
resolve(process.cwd(), "../../config", path)
|
||||
inContainerPath
|
||||
? resolve(inContainerPath, path)
|
||||
: resolve(process.cwd(), "../../config", path)
|
||||
|
||||
class Config {
|
||||
static init() {
|
||||
|
||||
Reference in New Issue
Block a user