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