Skip to content

Commit c36b241

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 fc3cde5 commit c36b241

File tree

2 files changed

+75
-3
lines changed

2 files changed

+75
-3
lines changed

Dockerfile

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# syntax=docker/dockerfile:1.4
22
FROM rust:1.74.1-bookworm as builder
3+
34
ARG TARGETPLATFORM
45
ARG GIT_V_VERSION
56
ARG ONNXRUNTIME_VERSION=1.17.0
7+
68
RUN apt-get update && apt-get install -y llvm-dev libclang-dev clang cmake
79
WORKDIR /usr/src/edge-runtime
810
RUN --mount=type=cache,target=/usr/local/cargo/registry,id=${TARGETPLATFORM} \
@@ -16,11 +18,41 @@ RUN ./scripts/install_onnx.sh $ONNXRUNTIME_VERSION $TARGETPLATFORM /root/libonnx
1618

1719

1820
FROM debian:bookworm-slim
21+
22+
ARG TARGETARCH
23+
ARG USE_CODE_SERVER_INTEGRATION
24+
25+
ENV USE_CODE_SERVER_INTEGRATION ${USE_CODE_SERVER_INTEGRATION}
26+
ENV DENO_VERSION 1.40.3
27+
ENV CODE_SERVER_VERSION 4.20.0
28+
ENV CODE_SERVER_HOST 0.0.0.0
29+
ENV CODE_SERVER_PORT 8999
30+
ENV CODE_SERVER_EXTENSIONS denoland.vscode-deno
31+
ENV ORT_DYLIB_PATH=/usr/local/bin/libonnxruntime.so
32+
ENV SB_AI_MODELS_DIR=/etc/sb_ai/models
33+
1934
RUN apt-get update && apt-get install -y libssl-dev && rm -rf /var/lib/apt/lists/*
2035
RUN apt-get remove -y perl && apt-get autoremove -y
36+
2137
COPY --from=builder /root/edge-runtime /usr/local/bin/edge-runtime
2238
COPY --from=builder /root/libonnxruntime.so /usr/local/bin/libonnxruntime.so
2339
COPY ./models /etc/sb_ai/models
24-
ENV ORT_DYLIB_PATH=/usr/local/bin/libonnxruntime.so
25-
ENV SB_AI_MODELS_DIR=/etc/sb_ai/models
26-
ENTRYPOINT ["edge-runtime"]
40+
COPY ./bin/entrypoint.sh /usr/local/bin
41+
42+
RUN chmod u+x /usr/local/bin/entrypoint.sh
43+
44+
# vscode-server integration
45+
RUN if [ -n "$USE_CODE_SERVER_INTEGRATION" ]; then \
46+
apt-get update && apt-get install -y ca-certificates curl wget unzip dumb-init \
47+
&& wget https://github.com/coder/code-server/releases/download/v${CODE_SERVER_VERSION}/code-server_${CODE_SERVER_VERSION}_${TARGETARCH}.deb -P /tmp \
48+
&& dpkg -i /tmp/code-server_${CODE_SERVER_VERSION}_${TARGETARCH}.deb \
49+
&& rm -f /tmp/code-server_${CODE_SERVER_VERSION}_${TARGETARCH}.deb; \
50+
if [ "${TARGETARCH}" = "arm64" ]; then \
51+
wget https://github.com/LukeChannings/deno-arm64/releases/download/v${DENO_VERSION}/deno-linux-arm64.zip -P /tmp \
52+
&& unzip /tmp/deno-linux-arm64.zip -d /usr/local/bin; \
53+
else \
54+
curl -fsSL https://deno.land/install.sh | DENO_INSTALL=/usr/local sh; \
55+
fi \
56+
fi
57+
58+
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)