Skip to content

Commit

Permalink
feat: integrate code-server with the container image
Browse files Browse the repository at this point in the history
  • Loading branch information
nyannyacha committed Jan 16, 2024
1 parent a5fee1d commit ac547af
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
27 changes: 26 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,32 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry,id=${TARGETPLATFORM} --m


FROM debian:bookworm-slim
ARG TARGETARCH
ARG USE_CODE_SERVER_INTEGRATION
ENV USE_CODE_SERVER_INTEGRATION ${USE_CODE_SERVER_INTEGRATION}
ENV DENO_VERSION 1.37.2
ENV CODE_SERVER_VERSION 4.20.0
ENV CODE_SERVER_HOST 0.0.0.0
ENV CODE_SERVER_PORT 8999
ENV CODE_SERVER_EXTENSIONS denoland.vscode-deno
RUN apt-get update && apt-get install -y libssl-dev && rm -rf /var/lib/apt/lists/*
RUN apt-get remove -y perl && apt-get autoremove -y
COPY --from=builder /root/edge-runtime /usr/local/bin/edge-runtime
ENTRYPOINT ["edge-runtime"]
COPY ./bin/entrypoint.sh /usr/local/bin
RUN chmod u+x /usr/local/bin/entrypoint.sh

# vscode-server integration
RUN if [ -n "$USE_CODE_SERVER_INTEGRATION" ]; then \
apt-get update && apt-get install -y ca-certificates curl wget unzip dumb-init \
&& wget https://github.com/coder/code-server/releases/download/v${CODE_SERVER_VERSION}/code-server_${CODE_SERVER_VERSION}_${TARGETARCH}.deb -P /tmp \
&& dpkg -i /tmp/code-server_${CODE_SERVER_VERSION}_${TARGETARCH}.deb \
&& rm -f /tmp/code-server_${CODE_SERVER_VERSION}_${TARGETARCH}.deb; \
if [ "${TARGETARCH}" = "arm64" ]; then \
wget https://github.com/LukeChannings/deno-arm64/releases/download/v${DENO_VERSION}/deno-linux-arm64.zip -P /tmp \
&& unzip /tmp/deno-linux-arm64.zip -d /usr/local/bin; \
else \
curl -fsSL https://deno.land/install.sh | DENO_INSTALL=/usr/local sh; \
fi \
fi

ENTRYPOINT ["dumb-init", "--", "/usr/local/bin/entrypoint.sh"]
40 changes: 40 additions & 0 deletions bin/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
set -eu

export PS1='\w $ '

EXTENSIONS="${CODE_SERVER_EXTENSIONS:-none}"

if [ -z "$USE_CODE_SERVER_INTEGRATION" ]; then
edge-runtime $@ &
else
mkdir -p /root/.local/share/code-server/User
cat > /root/.local/share/code-server/User/settings.json << EOF
{
"workbench.colorTheme": "Visual Studio Dark",
"deno.enable": true
}
EOF

if [ ${EXTENSIONS} != "none" ]; then
echo "Installing Extensions"
for extension in $(echo ${EXTENSIONS} | tr "," "\n")
do
if [ "${extension}" != "" ]; then
/usr/bin/code-server \
--install-extension "${extension}" \
/home/deno/functions
fi
done
fi

(/usr/bin/code-server \
--bind-addr "${CODE_SERVER_HOST}":"${CODE_SERVER_PORT}" \
--auth none \
/home/deno/functions \
) &

edge-runtime $@ &
fi

wait -n

0 comments on commit ac547af

Please sign in to comment.