Skip to content

Commit 96370cc

Browse files
committed
fix(cli): generate valid secrets for docker bootstrap
1 parent 4c12914 commit 96370cc

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

packages/cli/src/index.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env node
22

33
import { execSync, spawn } from 'child_process'
4+
import { randomBytes } from 'crypto'
45
import { existsSync, mkdirSync } from 'fs'
56
import { homedir } from 'os'
67
import { join } from 'path'
@@ -15,6 +16,10 @@ const REALTIME_CONTAINER = 'simstudio-realtime'
1516
const APP_CONTAINER = 'simstudio-app'
1617
const DEFAULT_PORT = '3000'
1718

19+
function generateHexSecret(bytes = 32): string {
20+
return randomBytes(bytes).toString('hex')
21+
}
22+
1823
const program = new Command()
1924

2025
program.name('simstudio').description('Run Sim using Docker').version('0.1.0')
@@ -84,6 +89,10 @@ async function cleanupExistingContainers(): Promise<void> {
8489

8590
async 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

Comments
 (0)