Skip to content

Instantly share code, notes, and snippets.

@fredericalix
Created April 1, 2023 08:28
Show Gist options
  • Save fredericalix/462adba70ee7f4476a3f3282f909069c to your computer and use it in GitHub Desktop.
Save fredericalix/462adba70ee7f4476a3f3282f909069c to your computer and use it in GitHub Desktop.
vscode-server Dockerfile
FROM buildpack-deps:22.04-curl
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
sudo \
ssh \
libatomic1 \
vim \
nano \
&& rm -rf /var/lib/apt/lists/*
RUN apt update && apt upgrade -y
WORKDIR /home/
ARG RELEASE_TAG="openvscode-server-v1.76.2"
ARG RELEASE_ORG="gitpod-io"
ARG OPENVSCODE_SERVER_ROOT="/home/.openvscode-server"
# Downloading the latest VSC Server release and extracting the release archive
# Rename `openvscode-server` cli tool to `code` for convenience
RUN if [ -z "${RELEASE_TAG}" ]; then \
echo "The RELEASE_TAG build arg must be set." >&2 && \
exit 1; \
fi && \
arch=$(uname -m) && \
if [ "${arch}" = "x86_64" ]; then \
arch="x64"; \
elif [ "${arch}" = "aarch64" ]; then \
arch="arm64"; \
elif [ "${arch}" = "armv7l" ]; then \
arch="armhf"; \
fi && \
wget https://github.com/${RELEASE_ORG}/openvscode-server/releases/download/${RELEASE_TAG}/${RELEASE_TAG}-linux-${arch}.tar.gz && \
tar -xzf ${RELEASE_TAG}-linux-${arch}.tar.gz && \
mv -f ${RELEASE_TAG}-linux-${arch} ${OPENVSCODE_SERVER_ROOT} && \
cp ${OPENVSCODE_SERVER_ROOT}/bin/remote-cli/openvscode-server ${OPENVSCODE_SERVER_ROOT}/bin/remote-cli/code && \
rm -f ${RELEASE_TAG}-linux-${arch}.tar.gz
ARG USERNAME=$LOGIN
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Creating the user and usergroup
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USERNAME -m -s /bin/bash $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
RUN chmod g+rw /home && \
mkdir -p /home/workspace && \
chown -R $USERNAME:$USERNAME /home/workspace && \
chown -R $USERNAME:$USERNAME ${OPENVSCODE_SERVER_ROOT}
WORKDIR /home/workspace/
USER $USERNAME
ENV LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8 \
HOME=/home/workspace \
EDITOR=code \
VISUAL=code \
GIT_EDITOR="code --wait" \
OPENVSCODE_SERVER_ROOT=${OPENVSCODE_SERVER_ROOT}
# Default exposed port if none is specified
EXPOSE 8080
ENTRYPOINT [ "/bin/sh", "-c", "exec ${OPENVSCODE_SERVER_ROOT}/bin/openvscode-server --host 0.0.0.0 --port 8080 --connection-token $VSCODE_TOKEN \"${@}\"", "--" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment