Skip to content

Commit 52ee577

Browse files
Add Kasm Docker build workflow
1 parent 59d99ff commit 52ee577

3 files changed

Lines changed: 183 additions & 0 deletions

File tree

.github/workflows/docker-build.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,53 @@ jobs:
6262
cache-from: type=gha
6363
cache-to: type=gha,mode=max
6464
target: runner
65+
66+
build-kasm:
67+
runs-on: ubuntu-latest
68+
needs: build
69+
steps:
70+
- name: Checkout
71+
uses: actions/checkout@v4
72+
73+
- name: Get latest tool versions
74+
id: versions
75+
run: |
76+
UV_VERSION=$(git ls-remote --tags --sort=-v:refname https://github.com/astral-sh/uv.git 'refs/tags/[0-9]*' | head -1 | sed 's/.*refs\/tags\///')
77+
OPENCODE_VERSION=$(curl -s https://api.github.com/repos/anomalyco/opencode/releases/latest | sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p')
78+
echo "uv=${UV_VERSION}" >> $GITHUB_OUTPUT
79+
echo "opencode=${OPENCODE_VERSION}" >> $GITHUB_OUTPUT
80+
81+
- name: Docker meta (Kasm)
82+
id: meta-kasm
83+
uses: docker/metadata-action@v5
84+
with:
85+
images: ghcr.io/${{ github.repository }}
86+
tags: |
87+
type=semver,pattern={{version}},suffix=-kasm
88+
type=semver,pattern={{major}}.{{minor}},suffix=-kasm
89+
type=raw,value=latest-kasm
90+
91+
- name: Set up Docker Buildx
92+
uses: docker/setup-buildx-action@v3
93+
94+
- name: Login to GHCR
95+
uses: docker/login-action@v3
96+
with:
97+
registry: ghcr.io
98+
username: ${{ github.actor }}
99+
password: ${{ secrets.GITHUB_TOKEN }}
100+
101+
- name: Build and push (Kasm)
102+
uses: docker/build-push-action@v5
103+
with:
104+
context: .
105+
file: Dockerfile.kasm
106+
platforms: linux/amd64
107+
push: true
108+
tags: ${{ steps.meta-kasm.outputs.tags }}
109+
labels: ${{ steps.meta-kasm.outputs.labels }}
110+
build-args: |
111+
UV_VERSION=${{ steps.versions.outputs.uv }}
112+
OPENCODE_VERSION=${{ steps.versions.outputs.opencode }}
113+
cache-from: type=gha
114+
cache-to: type=gha,mode=max

Dockerfile.kasm

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
FROM kasmweb/core-ubuntu-jammy:1.18.0
2+
USER root
3+
4+
ENV HOME /home/kasm-default-profile
5+
ENV STARTUPDIR /dockerstartup
6+
ENV INST_SCRIPTS $STARTUPDIR/install
7+
WORKDIR $HOME
8+
9+
######### Customize Container Here ###########
10+
11+
RUN apt-get update && apt-get install -y \
12+
git \
13+
curl \
14+
lsof \
15+
ripgrep \
16+
ca-certificates \
17+
grep \
18+
gawk \
19+
sed \
20+
findutils \
21+
coreutils \
22+
procps \
23+
jq \
24+
less \
25+
tree \
26+
file \
27+
python3 \
28+
python3-pip \
29+
python3-venv \
30+
chromium-browser \
31+
unzip \
32+
&& rm -rf /var/lib/apt/lists/*
33+
34+
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
35+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
36+
&& apt-get update && apt-get install -y gh \
37+
&& rm -rf /var/lib/apt/lists/*
38+
39+
RUN curl -fsSL https://deb.nodesource.com/setup_24.x | bash - \
40+
&& apt-get install -y nodejs \
41+
&& rm -rf /var/lib/apt/lists/*
42+
43+
RUN corepack enable && corepack prepare pnpm@latest --activate
44+
45+
RUN curl -fsSL https://bun.sh/install | bash && \
46+
mv $HOME/.bun /opt/bun && \
47+
chmod -R 755 /opt/bun && \
48+
ln -s /opt/bun/bin/bun /usr/local/bin/bun
49+
50+
ARG UV_VERSION=latest
51+
ARG OPENCODE_VERSION=latest
52+
53+
RUN curl -LsSf https://astral.sh/uv/install.sh | UV_NO_MODIFY_PATH=1 sh && \
54+
mv $HOME/.local/bin/uv /usr/local/bin/uv && \
55+
mv $HOME/.local/bin/uvx /usr/local/bin/uvx && \
56+
chmod +x /usr/local/bin/uv /usr/local/bin/uvx && \
57+
if [ "${OPENCODE_VERSION}" = "latest" ]; then \
58+
curl -fsSL https://opencode.ai/install | bash -s -- --no-modify-path; \
59+
else \
60+
curl -fsSL https://opencode.ai/install | bash -s -- --version ${OPENCODE_VERSION} --no-modify-path; \
61+
fi && \
62+
mv $HOME/.opencode /opt/opencode && \
63+
chmod -R 755 /opt/opencode && \
64+
ln -s /opt/opencode/bin/opencode /usr/local/bin/opencode
65+
66+
COPY --from=ghcr.io/chriswritescode-dev/opencode-manager:latest /app /opt/opencode-manager
67+
COPY --from=ghcr.io/chriswritescode-dev/opencode-manager:latest /opt/opencode-plugins /opt/opencode-plugins
68+
69+
RUN mkdir -p /workspace /opt/opencode-manager/data && \
70+
chown -R 1000:0 /workspace /opt/opencode-manager/data /opt/opencode-plugins
71+
72+
ENV NODE_ENV=production
73+
ENV HOST=0.0.0.0
74+
ENV PORT=5003
75+
ENV OPENCODE_SERVER_PORT=5551
76+
ENV DATABASE_PATH=/opt/opencode-manager/data/opencode.db
77+
ENV WORKSPACE_PATH=/workspace
78+
ENV NODE_PATH=/opt/opencode-plugins/node_modules
79+
80+
COPY scripts/kasm-startup.sh $STARTUPDIR/custom_startup.sh
81+
RUN chmod +x $STARTUPDIR/custom_startup.sh
82+
83+
######### End Customizations ###########
84+
85+
RUN chown 1000:0 $HOME
86+
RUN $STARTUPDIR/set_user_permission.sh $HOME
87+
88+
ENV HOME /home/kasm-user
89+
WORKDIR $HOME
90+
RUN mkdir -p $HOME && chown -R 1000:0 $HOME
91+
92+
USER 1000

scripts/kasm-startup.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
set -e
3+
4+
export PATH="/opt/bun/bin:/opt/opencode/bin:/usr/local/bin:$PATH"
5+
export BUN_INSTALL="/opt/bun"
6+
7+
START_COMMAND="bun backend/src/index.ts"
8+
WORK_DIR="/opt/opencode-manager"
9+
export MAXIMIZE="true"
10+
export MAXIMIZE_NAME="Chromium"
11+
MAXIMIZE_SCRIPT=$STARTUPDIR/maximize_window.sh
12+
13+
/usr/bin/desktop_ready
14+
15+
if [ -z "$AUTH_SECRET" ]; then
16+
export AUTH_SECRET=$(openssl rand -base64 32)
17+
fi
18+
19+
BROWSER=$(which chromium-browser || which chromium || which google-chrome || echo "")
20+
21+
set +e
22+
while true; do
23+
if ! pgrep -f "$START_COMMAND" > /dev/null; then
24+
cd "$WORK_DIR"
25+
$START_COMMAND > /tmp/opencode-manager.log 2>&1 &
26+
sleep 3
27+
if [ -n "$BROWSER" ]; then
28+
if ! pgrep -f "$BROWSER" > /dev/null; then
29+
bash ${MAXIMIZE_SCRIPT} 2>/dev/null &
30+
$BROWSER \
31+
--no-first-run \
32+
--no-default-browser-check \
33+
--disable-gpu \
34+
--start-maximized \
35+
--window-position=0,0 \
36+
"http://localhost:5003" &
37+
fi
38+
fi
39+
fi
40+
sleep 1
41+
done

0 commit comments

Comments
 (0)