11#!/usr/bin/env node
22
33import { execSync , spawn } from 'child_process'
4+ import { randomBytes } from 'crypto'
45import { existsSync , mkdirSync } from 'fs'
56import { homedir } from 'os'
67import { join } from 'path'
@@ -15,6 +16,10 @@ const REALTIME_CONTAINER = 'simstudio-realtime'
1516const APP_CONTAINER = 'simstudio-app'
1617const DEFAULT_PORT = '3000'
1718
19+ function generateHexSecret ( bytes = 32 ) : string {
20+ return randomBytes ( bytes ) . toString ( 'hex' )
21+ }
22+
1823const program = new Command ( )
1924
2025program . name ( 'simstudio' ) . description ( 'Run Sim using Docker' ) . version ( '0.1.0' )
@@ -84,6 +89,10 @@ async function cleanupExistingContainers(): Promise<void> {
8489
8590async function main ( ) {
8691 const options = program . parse ( ) . opts ( )
92+ const betterAuthSecret = generateHexSecret ( )
93+ const encryptionKey = generateHexSecret ( )
94+ const internalApiSecret = generateHexSecret ( )
95+ const apiEncryptionKey = generateHexSecret ( )
8796
8897 console . log ( chalk . blue ( '🚀 Starting Sim...' ) )
8998
@@ -215,7 +224,9 @@ async function main() {
215224 '-e' ,
216225 `NEXT_PUBLIC_APP_URL=http://localhost:${ port } ` ,
217226 '-e' ,
218- 'BETTER_AUTH_SECRET=your_auth_secret_here' ,
227+ `BETTER_AUTH_SECRET=${ betterAuthSecret } ` ,
228+ '-e' ,
229+ `INTERNAL_API_SECRET=${ internalApiSecret } ` ,
219230 'ghcr.io/simstudioai/realtime:latest' ,
220231 ] )
221232
@@ -243,9 +254,13 @@ async function main() {
243254 '-e' ,
244255 `NEXT_PUBLIC_APP_URL=http://localhost:${ port } ` ,
245256 '-e' ,
246- 'BETTER_AUTH_SECRET=your_auth_secret_here' ,
257+ `BETTER_AUTH_SECRET=${ betterAuthSecret } ` ,
258+ '-e' ,
259+ `ENCRYPTION_KEY=${ encryptionKey } ` ,
260+ '-e' ,
261+ `INTERNAL_API_SECRET=${ internalApiSecret } ` ,
247262 '-e' ,
248- 'ENCRYPTION_KEY=your_encryption_key_here' ,
263+ `API_ENCRYPTION_KEY= ${ apiEncryptionKey } ` ,
249264 'ghcr.io/simstudioai/simstudio:latest' ,
250265 ] )
251266
0 commit comments