Minimal container setup. Install docker (or podman), build container with scripts/build_container.sh, then start with scripts/start_container.sh. Exit with ^C for now. (#61)

This commit is contained in:
Olcan 2025-04-20 08:22:17 -07:00 committed by GitHub
parent 044ccc6dd7
commit 99f5ed9ecb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 80 additions and 1 deletions

39
Dockerfile Normal file
View File

@ -0,0 +1,39 @@
FROM node:20-slim
# install minimal set of packages, then clean up
RUN apt-get update && apt-get install -y --no-install-recommends \
man-db \
curl \
dnsutils \
less \
jq \
bc \
gh \
git \
unzip \
rsync \
ripgrep \
procps \
psmisc \
lsof \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# set up npm global package folder under /usr/local/share
# give it to non-root user node, already set up in base image
RUN mkdir -p /usr/local/share/npm-global \
&& chown -R node:node /usr/local/share/npm-global
ENV NPM_CONFIG_PREFIX=/usr/local/share/npm-global
ENV PATH=$PATH:/usr/local/share/npm-global/bin
# switch to non-root user node
USER node
# install gemini-code and clean up
COPY packages/cli/dist/gemini-code-cli-*.tgz /usr/local/share/npm-global/gemini-code-cli.tgz
COPY packages/server/dist/gemini-code-server-*.tgz /usr/local/share/npm-global/gemini-code-server.tgz
RUN npm install -g /usr/local/share/npm-global/gemini-code-cli.tgz /usr/local/share/npm-global/gemini-code-server.tgz \
&& npm cache clean --force \
&& rm -f /usr/local/share/npm-global/gemini-code-cli.tgz \
&& rm -f /usr/local/share/npm-global/gemini-code-server.tgz

View File

@ -266,7 +266,9 @@ Use this tool for running build steps (\`npm install\`, \`make\`), linters (\`es
`Persistent bash process exited unexpectedly (code: ${code}, signal: ${signal}). State is lost. Queued commands cancelled.`,
),
);
setTimeout(() => this.initializeShell(), 1000);
if (signal !== 'SIGINT') {
setTimeout(() => this.initializeShell(), 1000);
}
});
setTimeout(() => {
if (this.bashProcess && !this.bashProcess.killed) {

22
scripts/build_container.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
IMAGE=gemini-code-sandbox
# use docker if installed, otherwise try to use podman instead
if command -v docker &> /dev/null; then
CMD=docker
elif command -v podman &> /dev/null; then
CMD=podman
else
echo "ERROR: docker or podman must be installed"
exit 1
fi
npm install
npm run build
rm -f packages/cli/dist/gemini-code-cli-*.tgz
npm pack -w @gemini-code/cli --pack-destination ./packages/cli/dist
rm -f packages/server/dist/gemini-code-server-*.tgz
npm pack -w @gemini-code/server --pack-destination ./packages/server/dist
$CMD build -t "$IMAGE" .

16
scripts/start_container.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
IMAGE=gemini-code-sandbox
CLI_DIST=/usr/local/share/npm-global/lib/node_modules/\@gemini-code/cli/dist
# use docker if installed, otherwise try to use podman instead
if command -v docker &> /dev/null; then
CMD=docker
elif command -v podman &> /dev/null; then
CMD=podman
else
echo "ERROR: docker or podman must be installed"
exit 1
fi
$CMD run -it --rm -v"$PWD:/project" --workdir /project "$IMAGE" node "$CLI_DIST"