mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: load create session by quest image
This commit is contained in:
1 parent
4d408333b7
commit
8bbd5da513
8 files changed
+39
-33
No files matched your search
@@ -4,7 +4,6 @@ import config from '../config.js'
|
||||
const engine = new Docker()
|
||||
|
||||
const containerOptions = {
|
||||
Image: 'lancatlin/linux-odyssey:helloworld',
|
||||
AttachStdin: true,
|
||||
AttachStdout: true,
|
||||
AttachStderr: true,
|
||||
@@ -13,23 +12,24 @@ const containerOptions = {
|
||||
StdinOnce: false,
|
||||
HostConfig: {
|
||||
NetworkMode: config.dockerNetwork,
|
||||
Binds:
|
||||
!config.isProduction && config.hostPwd
|
||||
? [
|
||||
`${config.hostPwd}/quests/helloworld/home:/home/commander`,
|
||||
`${config.hostPwd}/packages/container:/usr/local/lib/container`,
|
||||
]
|
||||
: [],
|
||||
},
|
||||
}
|
||||
|
||||
// const network = engine.getNetwork(config.dockerNetwork)
|
||||
|
||||
export function createContainer(name) {
|
||||
return engine.createContainer({
|
||||
export function createContainer(name, tag) {
|
||||
const option = {
|
||||
...containerOptions,
|
||||
name,
|
||||
})
|
||||
Image: `${config.dockerImage}:${tag}`,
|
||||
}
|
||||
if (!config.isProduction && config.hostPwd && config.mountQuest) {
|
||||
option.HostConfig.Bind = [
|
||||
`${config.hostPwd}/quests/${config.mountQuest}/home:/home/commander`,
|
||||
`${config.hostPwd}/packages/container:/usr/local/lib/container`,
|
||||
]
|
||||
}
|
||||
return engine.createContainer(option)
|
||||
}
|
||||
|
||||
export async function getAndStartContainer(id) {
|
||||
@@ -45,7 +45,6 @@ export async function getAndStartContainer(id) {
|
||||
}
|
||||
|
||||
export async function attachContainer(container, { token }) {
|
||||
// Create an exec instance with bash shell
|
||||
const exec = await container.exec({
|
||||
AttachStdin: true,
|
||||
AttachStdout: true,
|
||||
|
||||
Reference in new issue
Block a user