Spaces:
Paused
Paused
feat: Add the Dockerfile, entrypoint.sh and start.sh files
Browse files- Dockerfile +94 -0
- entrypoint.sh +27 -0
- start.sh +3 -0
Dockerfile
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# syntax=docker/dockerfile:experimental
|
| 2 |
+
|
| 3 |
+
ARG BASE=debian:12
|
| 4 |
+
FROM $BASE
|
| 5 |
+
|
| 6 |
+
RUN apt-get update \
|
| 7 |
+
&& apt-get install -y \
|
| 8 |
+
curl \
|
| 9 |
+
dumb-init \
|
| 10 |
+
git \
|
| 11 |
+
build-essential \
|
| 12 |
+
cmake \
|
| 13 |
+
pkg-config \
|
| 14 |
+
python3 \
|
| 15 |
+
python3-pip \
|
| 16 |
+
python3-venv \
|
| 17 |
+
nodejs \
|
| 18 |
+
npm \
|
| 19 |
+
unzip \
|
| 20 |
+
zip \
|
| 21 |
+
jq \
|
| 22 |
+
iputils-ping \
|
| 23 |
+
openjdk-17-jdk \
|
| 24 |
+
maven \
|
| 25 |
+
git-lfs \
|
| 26 |
+
locales \
|
| 27 |
+
lsb-release \
|
| 28 |
+
nano \
|
| 29 |
+
openssh-client \
|
| 30 |
+
procps \
|
| 31 |
+
sudo \
|
| 32 |
+
vim-tiny \
|
| 33 |
+
wget \
|
| 34 |
+
zsh \
|
| 35 |
+
&& git lfs install \
|
| 36 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 37 |
+
|
| 38 |
+
# https://wiki.debian.org/Locale#Manually
|
| 39 |
+
RUN sed -i "s/# en_US.UTF-8/en_US.UTF-8/" /etc/locale.gen \
|
| 40 |
+
&& locale-gen
|
| 41 |
+
ENV LANG=en_US.UTF-8
|
| 42 |
+
|
| 43 |
+
RUN if grep -q 1000 /etc/passwd; then \
|
| 44 |
+
userdel -r "$(id -un 1000)"; \
|
| 45 |
+
fi \
|
| 46 |
+
&& adduser --gecos '' --disabled-password coder \
|
| 47 |
+
&& echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd
|
| 48 |
+
|
| 49 |
+
# Install Oh My Zsh for coder user
|
| 50 |
+
RUN su - coder -c "curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | sh" \
|
| 51 |
+
&& su - coder -c "git clone https://github.com/zsh-users/zsh-autosuggestions /home/coder/.oh-my-zsh/custom/plugins/zsh-autosuggestions" \
|
| 52 |
+
&& su - coder -c "git clone https://github.com/zsh-users/zsh-syntax-highlighting.git /home/coder/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting" \
|
| 53 |
+
&& su - coder -c "sed -i 's/plugins=(git)/plugins=(git zsh-autosuggestions zsh-syntax-highlighting)/g' /home/coder/.zshrc" \
|
| 54 |
+
&& chown -R coder:coder /home/coder/.oh-my-zsh \
|
| 55 |
+
&& chown coder:coder /home/coder/.zshrc \
|
| 56 |
+
&& chsh -s /usr/bin/zsh coder
|
| 57 |
+
|
| 58 |
+
RUN ARCH="$(dpkg --print-architecture)" \
|
| 59 |
+
&& curl -fsSL "https://github.com/boxboat/fixuid/releases/download/v0.6.0/fixuid-0.6.0-linux-$ARCH.tar.gz" | tar -C /usr/local/bin -xzf - \
|
| 60 |
+
&& chown root:root /usr/local/bin/fixuid \
|
| 61 |
+
&& chmod 4755 /usr/local/bin/fixuid \
|
| 62 |
+
&& mkdir -p /etc/fixuid \
|
| 63 |
+
&& printf "user: coder\ngroup: coder\n" > /etc/fixuid/config.yml
|
| 64 |
+
|
| 65 |
+
COPY entrypoint.sh /usr/bin/entrypoint.sh
|
| 66 |
+
RUN chmod +x /usr/bin/entrypoint.sh
|
| 67 |
+
# Add new startup script
|
| 68 |
+
COPY start.sh /start.sh
|
| 69 |
+
RUN chmod +x /start.sh
|
| 70 |
+
|
| 71 |
+
# Install code-server using the installation script
|
| 72 |
+
RUN curl -fsSL https://code-server.dev/install.sh | sh
|
| 73 |
+
|
| 74 |
+
# Allow users to have scripts run on container startup to prepare workspace.
|
| 75 |
+
# https://github.com/coder/code-server/issues/5177
|
| 76 |
+
ENV ENTRYPOINTD=${HOME}/entrypoint.d
|
| 77 |
+
|
| 78 |
+
# Set default timezone to UTC, can be overridden by TZ environment variable
|
| 79 |
+
ENV TZ=UTC
|
| 80 |
+
RUN apt-get update && apt-get install -y tzdata \
|
| 81 |
+
&& ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime \
|
| 82 |
+
&& echo ${TZ} > /etc/timezone \
|
| 83 |
+
&& dpkg-reconfigure -f noninteractive tzdata \
|
| 84 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 85 |
+
|
| 86 |
+
EXPOSE 7860
|
| 87 |
+
# This way, if someone sets $DOCKER_USER, docker-exec will still work as
|
| 88 |
+
# the uid will remain the same. note: only relevant if -u isn't passed to
|
| 89 |
+
# docker-run.
|
| 90 |
+
USER 1000
|
| 91 |
+
ENV USER=coder
|
| 92 |
+
ENV SHELL=/usr/bin/zsh
|
| 93 |
+
WORKDIR /home/coder/workspace
|
| 94 |
+
ENTRYPOINT ["/start.sh"]
|
entrypoint.sh
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
|
| 4 |
+
# We do this first to ensure sudo works below when renaming the user.
|
| 5 |
+
# Otherwise the current container UID may not exist in the passwd database.
|
| 6 |
+
eval "$(fixuid -q)"
|
| 7 |
+
|
| 8 |
+
if [ "${DOCKER_USER-}" ]; then
|
| 9 |
+
USER="$DOCKER_USER"
|
| 10 |
+
if [ -z "$(id -u "$DOCKER_USER" 2>/dev/null)" ]; then
|
| 11 |
+
echo "$DOCKER_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd > /dev/null
|
| 12 |
+
# Unfortunately we cannot change $HOME as we cannot move any bind mounts
|
| 13 |
+
# nor can we bind mount $HOME into a new home as that requires a privileged container.
|
| 14 |
+
sudo usermod --login "$DOCKER_USER" coder
|
| 15 |
+
sudo groupmod -n "$DOCKER_USER" coder
|
| 16 |
+
|
| 17 |
+
sudo sed -i "/coder/d" /etc/sudoers.d/nopasswd
|
| 18 |
+
fi
|
| 19 |
+
fi
|
| 20 |
+
|
| 21 |
+
# Allow users to have scripts run on container startup to prepare workspace.
|
| 22 |
+
# https://github.com/coder/code-server/issues/5177
|
| 23 |
+
if [ -d "${ENTRYPOINTD}" ]; then
|
| 24 |
+
find "${ENTRYPOINTD}" -type f -executable -print -exec {} \;
|
| 25 |
+
fi
|
| 26 |
+
|
| 27 |
+
exec dumb-init /usr/bin/code-server "$@"
|
start.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Ensure code-server starts correctly and listens on the specified port
|
| 3 |
+
/usr/bin/entrypoint.sh --bind-addr 0.0.0.0:7860 /home/coder/workspace
|