mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 08:47:44 +00:00
14
Dockerfile
14
Dockerfile
@@ -1,6 +1,6 @@
|
|||||||
FROM docker.io/library/node:20-slim
|
FROM docker.io/library/node:20-slim
|
||||||
|
|
||||||
ARG SANDBOX_NAME="gemini-cli-sandbox"
|
ARG SANDBOX_NAME="qwen-code-sandbox"
|
||||||
ARG CLI_VERSION_ARG
|
ARG CLI_VERSION_ARG
|
||||||
ENV SANDBOX="$SANDBOX_NAME"
|
ENV SANDBOX="$SANDBOX_NAME"
|
||||||
ENV CLI_VERSION=$CLI_VERSION_ARG
|
ENV CLI_VERSION=$CLI_VERSION_ARG
|
||||||
@@ -39,12 +39,12 @@ ENV PATH=$PATH:/usr/local/share/npm-global/bin
|
|||||||
# switch to non-root user node
|
# switch to non-root user node
|
||||||
USER node
|
USER node
|
||||||
|
|
||||||
# install gemini-cli and clean up
|
# install qwen-code and clean up
|
||||||
COPY packages/cli/dist/google-gemini-cli-*.tgz /usr/local/share/npm-global/gemini-cli.tgz
|
COPY packages/cli/dist/qwen-code-*.tgz /usr/local/share/npm-global/qwen-code.tgz
|
||||||
COPY packages/core/dist/google-gemini-cli-core-*.tgz /usr/local/share/npm-global/gemini-core.tgz
|
COPY packages/core/dist/qwen-code-qwen-code-core-*.tgz /usr/local/share/npm-global/qwen-code-core.tgz
|
||||||
RUN npm install -g /usr/local/share/npm-global/gemini-cli.tgz /usr/local/share/npm-global/gemini-core.tgz \
|
RUN npm install -g /usr/local/share/npm-global/qwen-code.tgz /usr/local/share/npm-global/qwen-code-core.tgz \
|
||||||
&& npm cache clean --force \
|
&& npm cache clean --force \
|
||||||
&& rm -f /usr/local/share/npm-global/gemini-{cli,core}.tgz
|
&& rm -f /usr/local/share/npm-global/qwen-{code,code-core}.tgz
|
||||||
|
|
||||||
# default entrypoint when none specified
|
# default entrypoint when none specified
|
||||||
CMD ["gemini"]
|
CMD ["qwen"]
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
"url": "git+http://gitlab.alibaba-inc.com/Qwen-Coder/qwen-code.git"
|
"url": "git+http://gitlab.alibaba-inc.com/Qwen-Coder/qwen-code.git"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"sandboxImageUri": "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.0.1-alpha.8"
|
"sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.0.1-alpha.8"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node scripts/start.js",
|
"start": "node scripts/start.js",
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
"dist"
|
"dist"
|
||||||
],
|
],
|
||||||
"config": {
|
"config": {
|
||||||
"sandboxImageUri": "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.0.1-alpha.8"
|
"sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.0.1-alpha.8"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@qwen-code/qwen-code-core": "file:../core",
|
"@qwen-code/qwen-code-core": "file:../core",
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ function getContainerPath(hostPath: string): string {
|
|||||||
return hostPath;
|
return hostPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
const LOCAL_DEV_SANDBOX_IMAGE_NAME = 'gemini-cli-sandbox';
|
const LOCAL_DEV_SANDBOX_IMAGE_NAME = 'qwen-code-sandbox';
|
||||||
const SANDBOX_NETWORK_NAME = 'gemini-cli-sandbox';
|
const SANDBOX_NETWORK_NAME = 'qwen-code-sandbox';
|
||||||
const SANDBOX_PROXY_NAME = 'gemini-cli-sandbox-proxy';
|
const SANDBOX_PROXY_NAME = 'qwen-code-sandbox-proxy';
|
||||||
const BUILTIN_SEATBELT_PROFILES = [
|
const BUILTIN_SEATBELT_PROFILES = [
|
||||||
'permissive-open',
|
'permissive-open',
|
||||||
'permissive-closed',
|
'permissive-closed',
|
||||||
@@ -172,8 +172,8 @@ function entrypoint(workdir: string): string[] {
|
|||||||
? 'npm run debug --'
|
? 'npm run debug --'
|
||||||
: 'npm rebuild && npm run start --'
|
: 'npm rebuild && npm run start --'
|
||||||
: process.env.DEBUG
|
: process.env.DEBUG
|
||||||
? `node --inspect-brk=0.0.0.0:${process.env.DEBUG_PORT || '9229'} $(which gemini)`
|
? `node --inspect-brk=0.0.0.0:${process.env.DEBUG_PORT || '9229'} $(which qwen)`
|
||||||
: 'gemini';
|
: 'qwen';
|
||||||
|
|
||||||
const args = [...shellCmds, cliCmd, ...cliArgs];
|
const args = [...shellCmds, cliCmd, ...cliArgs];
|
||||||
|
|
||||||
@@ -517,6 +517,17 @@ export async function start_sandbox(
|
|||||||
args.push('--env', `GOOGLE_API_KEY=${process.env.GOOGLE_API_KEY}`);
|
args.push('--env', `GOOGLE_API_KEY=${process.env.GOOGLE_API_KEY}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// copy OPENAI_API_KEY and related env vars for Qwen
|
||||||
|
if (process.env.OPENAI_API_KEY) {
|
||||||
|
args.push('--env', `OPENAI_API_KEY=${process.env.OPENAI_API_KEY}`);
|
||||||
|
}
|
||||||
|
if (process.env.OPENAI_BASE_URL) {
|
||||||
|
args.push('--env', `OPENAI_BASE_URL=${process.env.OPENAI_BASE_URL}`);
|
||||||
|
}
|
||||||
|
if (process.env.OPENAI_MODEL) {
|
||||||
|
args.push('--env', `OPENAI_MODEL=${process.env.OPENAI_MODEL}`);
|
||||||
|
}
|
||||||
|
|
||||||
// copy GOOGLE_GENAI_USE_VERTEXAI
|
// copy GOOGLE_GENAI_USE_VERTEXAI
|
||||||
if (process.env.GOOGLE_GENAI_USE_VERTEXAI) {
|
if (process.env.GOOGLE_GENAI_USE_VERTEXAI) {
|
||||||
args.push(
|
args.push(
|
||||||
|
|||||||
@@ -77,23 +77,23 @@ if (!argv.s) {
|
|||||||
execSync('npm run build --workspaces', { stdio: 'inherit' });
|
execSync('npm run build --workspaces', { stdio: 'inherit' });
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('packing @google/gemini-cli ...');
|
console.log('packing @qwen-code/qwen-code ...');
|
||||||
const cliPackageDir = join('packages', 'cli');
|
const cliPackageDir = join('packages', 'cli');
|
||||||
rmSync(join(cliPackageDir, 'dist', 'google-gemini-cli-*.tgz'), { force: true });
|
rmSync(join(cliPackageDir, 'dist', 'qwen-code-*.tgz'), { force: true });
|
||||||
execSync(
|
execSync(
|
||||||
`npm pack -w @google/gemini-cli --pack-destination ./packages/cli/dist`,
|
`npm pack -w @qwen-code/qwen-code --pack-destination ./packages/cli/dist`,
|
||||||
{
|
{
|
||||||
stdio: 'ignore',
|
stdio: 'ignore',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log('packing @google/gemini-cli-core ...');
|
console.log('packing @qwen-code/qwen-code-core ...');
|
||||||
const corePackageDir = join('packages', 'core');
|
const corePackageDir = join('packages', 'core');
|
||||||
rmSync(join(corePackageDir, 'dist', 'google-gemini-cli-core-*.tgz'), {
|
rmSync(join(corePackageDir, 'dist', 'qwen-code-core-*.tgz'), {
|
||||||
force: true,
|
force: true,
|
||||||
});
|
});
|
||||||
execSync(
|
execSync(
|
||||||
`npm pack -w @google/gemini-cli-core --pack-destination ./packages/core/dist`,
|
`npm pack -w @qwen-code/qwen-code-core --pack-destination ./packages/core/dist`,
|
||||||
{ stdio: 'ignore' },
|
{ stdio: 'ignore' },
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -102,11 +102,15 @@ const packageVersion = JSON.parse(
|
|||||||
).version;
|
).version;
|
||||||
|
|
||||||
chmodSync(
|
chmodSync(
|
||||||
join(cliPackageDir, 'dist', `google-gemini-cli-${packageVersion}.tgz`),
|
join(cliPackageDir, 'dist', `qwen-code-qwen-code-${packageVersion}.tgz`),
|
||||||
0o755,
|
0o755,
|
||||||
);
|
);
|
||||||
chmodSync(
|
chmodSync(
|
||||||
join(corePackageDir, 'dist', `google-gemini-cli-core-${packageVersion}.tgz`),
|
join(
|
||||||
|
corePackageDir,
|
||||||
|
'dist',
|
||||||
|
`qwen-code-qwen-code-core-${packageVersion}.tgz`,
|
||||||
|
),
|
||||||
0o755,
|
0o755,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -134,14 +138,21 @@ function buildImage(imageName, dockerfile) {
|
|||||||
{ stdio: buildStdout, shell: '/bin/bash' },
|
{ stdio: buildStdout, shell: '/bin/bash' },
|
||||||
);
|
);
|
||||||
console.log(`built ${finalImageName}`);
|
console.log(`built ${finalImageName}`);
|
||||||
if (existsSync('/workspace/final_image_uri.txt')) {
|
|
||||||
|
// If an output file path was provided via command-line, write the final image URI to it.
|
||||||
|
if (argv.outputFile) {
|
||||||
|
console.log(
|
||||||
|
`Writing final image URI for CI artifact to: ${argv.outputFile}`,
|
||||||
|
);
|
||||||
// The publish step only supports one image. If we build multiple, only the last one
|
// The publish step only supports one image. If we build multiple, only the last one
|
||||||
// will be published. Throw an error to make this failure explicit.
|
// will be published. Throw an error to make this failure explicit if the file already exists.
|
||||||
|
if (existsSync(argv.outputFile)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'CI artifact file /workspace/final_image_uri.txt already exists. Refusing to overwrite.',
|
`CI artifact file ${argv.outputFile} already exists. Refusing to overwrite.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
writeFileSync('/workspace/final_image_uri.txt', finalImageName);
|
writeFileSync(argv.outputFile, finalImageName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baseImage && baseDockerfile) {
|
if (baseImage && baseDockerfile) {
|
||||||
|
|||||||
Reference in New Issue
Block a user