Skip to content

Commit bee98d5

Browse files
committed
feat: integrate code-server with the container image
(cherry picked from commit ac547af) (cherry picked from commit 4754203) (cherry picked from commit 0c24ba1)
1 parent 705db6e commit bee98d5

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

Dockerfile

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,32 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry,id=${TARGETPLATFORM} --m
1414

1515

1616
FROM debian:bookworm-slim
17+
ARG TARGETARCH
18+
ARG USE_CODE_SERVER_INTEGRATION
19+
ENV USE_CODE_SERVER_INTEGRATION ${USE_CODE_SERVER_INTEGRATION}
20+
ENV DENO_VERSION 1.40.3
21+
ENV CODE_SERVER_VERSION 4.20.0
22+
ENV CODE_SERVER_HOST 0.0.0.0
23+
ENV CODE_SERVER_PORT 8999
24+
ENV CODE_SERVER_EXTENSIONS denoland.vscode-deno
1725
RUN apt-get update && apt-get install -y libssl-dev && rm -rf /var/lib/apt/lists/*
1826
RUN apt-get remove -y perl && apt-get autoremove -y
1927
COPY --from=builder /root/edge-runtime /usr/local/bin/edge-runtime
20-
ENTRYPOINT ["edge-runtime"]
28+
COPY ./bin/entrypoint.sh /usr/local/bin
29+
RUN chmod u+x /usr/local/bin/entrypoint.sh
30+
31+
# vscode-server integration
32+
RUN if [ -n "$USE_CODE_SERVER_INTEGRATION" ]; then \
33+
apt-get update && apt-get install -y ca-certificates curl wget unzip dumb-init \
34+
&& wget https://github.com/coder/code-server/releases/download/v${CODE_SERVER_VERSION}/code-server_${CODE_SERVER_VERSION}_${TARGETARCH}.deb -P /tmp \
35+
&& dpkg -i /tmp/code-server_${CODE_SERVER_VERSION}_${TARGETARCH}.deb \
36+
&& rm -f /tmp/code-server_${CODE_SERVER_VERSION}_${TARGETARCH}.deb; \
37+
if [ "${TARGETARCH}" = "arm64" ]; then \
38+
wget https://github.com/LukeChannings/deno-arm64/releases/download/v${DENO_VERSION}/deno-linux-arm64.zip -P /tmp \
39+
&& unzip /tmp/deno-linux-arm64.zip -d /usr/local/bin; \
40+
else \
41+
curl -fsSL https://deno.land/install.sh | DENO_INSTALL=/usr/local sh; \
42+
fi \
43+
fi
44+
45+
ENTRYPOINT ["dumb-init", "--", "/usr/local/bin/entrypoint.sh"]

bin/entrypoint.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
set -eu
3+
4+
export PS1='\w $ '
5+
6+
EXTENSIONS="${CODE_SERVER_EXTENSIONS:-none}"
7+
8+
if [ -z "$USE_CODE_SERVER_INTEGRATION" ]; then
9+
edge-runtime $@ &
10+
else
11+
mkdir -p /root/.local/share/code-server/User
12+
cat > /root/.local/share/code-server/User/settings.json << EOF
13+
{
14+
"workbench.colorTheme": "Visual Studio Dark",
15+
"deno.enable": true
16+
}
17+
EOF
18+
19+
if [ ${EXTENSIONS} != "none" ]; then
20+
echo "Installing Extensions"
21+
for extension in $(echo ${EXTENSIONS} | tr "," "\n")
22+
do
23+
if [ "${extension}" != "" ]; then
24+
/usr/bin/code-server \
25+
--install-extension "${extension}" \
26+
/home/deno/functions
27+
fi
28+
done
29+
fi
30+
31+
(/usr/bin/code-server \
32+
--bind-addr "${CODE_SERVER_HOST}":"${CODE_SERVER_PORT}" \
33+
--auth none \
34+
/home/deno/functions \
35+
) &
36+
37+
edge-runtime $@ &
38+
fi
39+
40+
wait -n

0 commit comments

Comments
 (0)