mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
fix: mounting quest home into production container
This commit is contained in:
1 parent
1888781a47
commit
44ecd3b87a
3 files changed
+6
-7
No files matched your search
@@ -30,6 +30,7 @@ services:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- ./logs:/app/logs
|
||||
- ./config:/app/config
|
||||
- ./quests:/app/quests:ro
|
||||
env_file:
|
||||
- .env
|
||||
- .env.prod
|
||||
@@ -40,6 +41,7 @@ services:
|
||||
- TRUSTED_PROXIES=${TRUSTED_PROXIES}
|
||||
- BACKEND_URL=http://backend:3000
|
||||
- BASE_URL=${BASE_URL}
|
||||
- HOST_PROJECT_ROOT=${PWD}
|
||||
- GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}
|
||||
- GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET}
|
||||
- GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID}
|
||||
|
||||
@@ -76,6 +76,7 @@ function createConfig() {
|
||||
defaultImage: get('QUEST_IMAGE', 'linuxodyssey/quest-base'),
|
||||
imagePrefix: get('DOCKER_PREFIX', 'linuxodyssey/quest-'),
|
||||
mountQuest: process.env.MOUNT_QUEST === 'true',
|
||||
hostProjectRoot: get('HOST_PROJECT_ROOT', projectRoot),
|
||||
keypairPath,
|
||||
keypair,
|
||||
},
|
||||
@@ -94,6 +95,7 @@ function createConfig() {
|
||||
function getProjectRoot(): string {
|
||||
const filename = fileURLToPath(import.meta.url)
|
||||
const root = path.join(path.dirname(filename), '..', '..')
|
||||
console.log('Project root:', root)
|
||||
return root
|
||||
}
|
||||
|
||||
|
||||
@@ -32,9 +32,7 @@ export async function createContainer(
|
||||
questId: string,
|
||||
imageId: string
|
||||
): Promise<Docker.Container> {
|
||||
let binds: string[] = [
|
||||
// `${config.docker.hostProjectRoot}/config/ssh_key.pub:/ssh_key.pub:ro`,
|
||||
]
|
||||
let binds: string[] = []
|
||||
if (await questHomeExists(questId)) {
|
||||
logger.info('Mounting quest home', questId)
|
||||
binds.push(
|
||||
@@ -49,7 +47,6 @@ export async function createContainer(
|
||||
]
|
||||
}
|
||||
const option = newContainerOptions(name, imageId, { binds })
|
||||
console.log('Creating container', option)
|
||||
await createNetworkIfNotExists(config.docker.network)
|
||||
return engine.createContainer(option)
|
||||
}
|
||||
@@ -68,9 +65,7 @@ async function createNetworkIfNotExists(network: string) {
|
||||
|
||||
async function questHomeExists(imageId: string) {
|
||||
try {
|
||||
const stat = await fs.stat(
|
||||
`${config.docker.hostProjectRoot}/quests/${imageId}/home`
|
||||
)
|
||||
const stat = await fs.stat(`${config.projectRoot}/quests/${imageId}/home`)
|
||||
return stat.isDirectory()
|
||||
} catch {
|
||||
return false
|
||||
|
||||
Reference in new issue
Block a user