aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2024-08-15 00:08:43 +0800
committercrupest <crupest@outlook.com>2024-08-15 00:08:43 +0800
commit909c5e8aa53017eaffd4171835b3c66949c64f7f (patch)
tree09504e7755b7803e518baaa11d255f35ed6c9817
parent1bca7471d864bf859a6189a87adf92856729ec97 (diff)
parentd50545a36323e7a9775ab933021a94a9d98058f4 (diff)
downloadcrupest-909c5e8aa53017eaffd4171835b3c66949c64f7f.tar.gz
crupest-909c5e8aa53017eaffd4171835b3c66949c64f7f.tar.bz2
crupest-909c5e8aa53017eaffd4171835b3c66949c64f7f.zip
Merge branch 'debian-dev'
-rw-r--r--docker/code-server/Dockerfile11
-rwxr-xr-xdocker/code-server/install-code-server.bash24
-rwxr-xr-xdocker/code-server/install-dev-tools.bash14
-rw-r--r--docker/code-server/install-llvm.bash10
-rw-r--r--docker/crupest-debian-dev/Dockerfile21
-rwxr-xr-xdocker/crupest-debian-dev/bootstrap/apt-source/11/add-deb-src.bash14
-rwxr-xr-xdocker/crupest-debian-dev/bootstrap/apt-source/11/get-domain.bash (renamed from docker/debian-dev/bootstrap/apt-source/get-domain.bash)0
-rwxr-xr-xdocker/crupest-debian-dev/bootstrap/apt-source/11/replace-domain.bash (renamed from docker/debian-dev/bootstrap/apt-source/replace-domain.bash)0
-rwxr-xr-xdocker/crupest-debian-dev/bootstrap/apt-source/11/replace-http.bash (renamed from docker/debian-dev/bootstrap/apt-source/replace-http.bash)0
-rwxr-xr-xdocker/crupest-debian-dev/bootstrap/apt-source/12/add-deb-src.bash22
-rwxr-xr-xdocker/crupest-debian-dev/bootstrap/apt-source/12/get-domain.bash6
-rwxr-xr-xdocker/crupest-debian-dev/bootstrap/apt-source/12/replace-domain.bash7
-rwxr-xr-xdocker/crupest-debian-dev/bootstrap/apt-source/12/replace-http.bash7
-rw-r--r--docker/crupest-debian-dev/bootstrap/apt-source/china-source.txt1
-rwxr-xr-xdocker/crupest-debian-dev/bootstrap/apt-source/install-apt-https.bash (renamed from docker/debian-dev/bootstrap/apt-source/install-apt-https.bash)1
-rwxr-xr-xdocker/crupest-debian-dev/bootstrap/apt-source/setup.bash34
-rw-r--r--docker/crupest-debian-dev/bootstrap/bash-profile/bash-completion.bash (renamed from docker/debian-dev/bootstrap/bash-profile/bash-completion.bash)0
-rw-r--r--docker/crupest-debian-dev/bootstrap/bash-profile/code-server.bash15
-rw-r--r--docker/crupest-debian-dev/bootstrap/bash-profile/dquilt.bash (renamed from docker/debian-dev/bootstrap/bash-profile/dquilt.bash)0
-rwxr-xr-x[-rw-r--r--]docker/crupest-debian-dev/bootstrap/extra/setup-cmake.bash (renamed from docker/code-server/install-cmake.bash)4
-rwxr-xr-x[-rw-r--r--]docker/crupest-debian-dev/bootstrap/extra/setup-dotnet.bash (renamed from docker/code-server/install-dotnet.bash)4
-rwxr-xr-xdocker/crupest-debian-dev/bootstrap/extra/setup-llvm.bash26
-rw-r--r--docker/crupest-debian-dev/bootstrap/func.bash (renamed from docker/debian-dev/bootstrap/func.bash)4
-rwxr-xr-xdocker/crupest-debian-dev/bootstrap/get-debian-version.bash13
-rw-r--r--docker/crupest-debian-dev/bootstrap/home-dot/devscripts (renamed from docker/debian-dev/bootstrap/home-dot/devscripts)0
-rw-r--r--docker/crupest-debian-dev/bootstrap/home-dot/quiltrc-dpkg (renamed from docker/debian-dev/bootstrap/home-dot/quiltrc-dpkg)0
-rwxr-xr-xdocker/crupest-debian-dev/bootstrap/setup-base.bash25
-rwxr-xr-xdocker/crupest-debian-dev/bootstrap/setup-code-server.bash28
-rwxr-xr-xdocker/crupest-debian-dev/bootstrap/setup-dev.bash (renamed from docker/debian-dev/bootstrap/setup-dev.bash)11
-rwxr-xr-xdocker/crupest-debian-dev/bootstrap/setup-user.bash20
-rwxr-xr-xdocker/crupest-debian-dev/bootstrap/setup.bash30
-rwxr-xr-xdocker/crupest-debian-dev/bootstrap/wait.bash5
-rw-r--r--docker/debian-dev/Dockerfile18
-rw-r--r--docker/debian-dev/bootstrap/apt-source/china-source.txt1
-rwxr-xr-xdocker/debian-dev/bootstrap/apt-source/setup.bash12
-rw-r--r--docker/debian-dev/bootstrap/bash-profile/auto-start-apt-cacher.bash2
-rw-r--r--docker/debian-dev/bootstrap/bash-profile/dev.bash1
-rw-r--r--docker/debian-dev/bootstrap/home-dot/sbuildrc25
-rwxr-xr-xdocker/debian-dev/bootstrap/sbuild/setup-amd64.bash7
-rwxr-xr-xdocker/debian-dev/bootstrap/sbuild/setup.bash25
-rwxr-xr-xdocker/debian-dev/bootstrap/setup-base.bash10
-rwxr-xr-xdocker/debian-dev/bootstrap/setup-user.bash9
-rwxr-xr-xdocker/debian-dev/bootstrap/setup.bash20
-rw-r--r--template/docker-compose.yaml.template15
44 files changed, 307 insertions, 195 deletions
diff --git a/docker/code-server/Dockerfile b/docker/code-server/Dockerfile
deleted file mode 100644
index 9a43f5e..0000000
--- a/docker/code-server/Dockerfile
+++ /dev/null
@@ -1,11 +0,0 @@
-FROM debian:latest
-
-WORKDIR /scripts
-COPY *.bash /scripts/
-RUN /scripts/install-code-server.bash
-
-ENV LANG en_US.utf8
-ENV CODE_SERVER_CONFIG="/data/code-server-config.yaml"
-EXPOSE 8080
-VOLUME [ "/root", "/data" ]
-CMD [ "code-server", "--bind-addr", "0.0.0.0:8080" ]
diff --git a/docker/code-server/install-code-server.bash b/docker/code-server/install-code-server.bash
deleted file mode 100755
index b2c15ab..0000000
--- a/docker/code-server/install-code-server.bash
+++ /dev/null
@@ -1,24 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-apt-get update
-apt-get install -y locales curl
-
-localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
-
-VERSION=$(curl -s https://api.github.com/repos/coder/code-server/releases/latest | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
-
-echo "The latest version of code-server is ${VERSION}."
-
-url="https://github.com/coder/code-server/releases/download/v${VERSION}/code-server_${VERSION}_amd64.deb"
-
-echo "Download code-server from $url."
-
-curl -sSfOL "$url"
-dpkg -i "code-server_${VERSION}_amd64.deb"
-rm "code-server_${VERSION}_amd64.deb"
-
-echo "Code-server version: $(code-server --version)."
-
-rm -rf /var/lib/apt/lists/*
diff --git a/docker/code-server/install-dev-tools.bash b/docker/code-server/install-dev-tools.bash
deleted file mode 100755
index 3f64743..0000000
--- a/docker/code-server/install-dev-tools.bash
+++ /dev/null
@@ -1,14 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-apt-get update
-apt-get install -y vim lsb-release wget git software-properties-common gnupg
-apt-get install -y gcc g++ make gdb
-
-# git config --global user.email "$GIT_EMAIL"
-# git config --global user.name "$GIT_NAME"
-
-source ./install-llvm.bash
-source ./install-cmake.bash
-source ./install-dotnet.bash
diff --git a/docker/code-server/install-llvm.bash b/docker/code-server/install-llvm.bash
deleted file mode 100644
index 2ce798f..0000000
--- a/docker/code-server/install-llvm.bash
+++ /dev/null
@@ -1,10 +0,0 @@
-LLVM_VERSION=15
-wget https://apt.llvm.org/llvm.sh
-chmod +x llvm.sh
-./llvm.sh $LLVM_VERSION all
-rm llvm.sh
-update-alternatives --install /usr/bin/clang clang /usr/bin/clang-$LLVM_VERSION 100 \
- --slave /usr/bin/clang++ clang++ /usr/bin/clang++-$LLVM_VERSION \
- --slave /usr/bin/clangd clangd /usr/bin/clangd-$LLVM_VERSION \
- --slave /usr/bin/lldb lldb /usr/bin/lldb-$LLVM_VERSION \
- --slave /usr/bin/lld lld /usr/bin/lld-$LLVM_VERSION
diff --git a/docker/crupest-debian-dev/Dockerfile b/docker/crupest-debian-dev/Dockerfile
new file mode 100644
index 0000000..3293f03
--- /dev/null
+++ b/docker/crupest-debian-dev/Dockerfile
@@ -0,0 +1,21 @@
+FROM debian:latest
+
+ARG USER=crupest
+ARG IN_CHINA=
+ARG CODE_SERVER=true
+
+ENV CRUPEST_DEBIAN_DEV_USER=${USER}
+ENV CRUPEST_DEBIAN_DEV_IN_CHINA=${IN_CHINA}
+ENV CRUPEST_DEBIAN_DEV_SETUP_CODE_SERVER=${CODE_SERVER}
+
+ADD bootstrap /bootstrap
+
+RUN /bootstrap/setup.bash
+ENV LANG=en_US.utf8
+
+USER ${USER}
+WORKDIR /home/${USER}
+
+EXPOSE 8080
+VOLUME [ "/data", "/state" ]
+CMD [ "bash", "-l" ]
diff --git a/docker/crupest-debian-dev/bootstrap/apt-source/11/add-deb-src.bash b/docker/crupest-debian-dev/bootstrap/apt-source/11/add-deb-src.bash
new file mode 100755
index 0000000..e134a00
--- /dev/null
+++ b/docker/crupest-debian-dev/bootstrap/apt-source/11/add-deb-src.bash
@@ -0,0 +1,14 @@
+#! /usr/bin/env bash
+
+set -e
+
+dir=$(dirname "$0")
+domain=$("$dir/get-domain.bash")
+
+cat <<EOF >> /etc/apt/sources.list
+
+deb-src https://$domain/debian/ bullseye main
+deb-src https://$domain/debian-security/ bullseye-security main
+deb-src https://$domain/debian-updates/ bullseye-updates main
+
+EOF
diff --git a/docker/debian-dev/bootstrap/apt-source/get-domain.bash b/docker/crupest-debian-dev/bootstrap/apt-source/11/get-domain.bash
index d44ea65..d44ea65 100755
--- a/docker/debian-dev/bootstrap/apt-source/get-domain.bash
+++ b/docker/crupest-debian-dev/bootstrap/apt-source/11/get-domain.bash
diff --git a/docker/debian-dev/bootstrap/apt-source/replace-domain.bash b/docker/crupest-debian-dev/bootstrap/apt-source/11/replace-domain.bash
index 86e88dc..86e88dc 100755
--- a/docker/debian-dev/bootstrap/apt-source/replace-domain.bash
+++ b/docker/crupest-debian-dev/bootstrap/apt-source/11/replace-domain.bash
diff --git a/docker/debian-dev/bootstrap/apt-source/replace-http.bash b/docker/crupest-debian-dev/bootstrap/apt-source/11/replace-http.bash
index fae082a..fae082a 100755
--- a/docker/debian-dev/bootstrap/apt-source/replace-http.bash
+++ b/docker/crupest-debian-dev/bootstrap/apt-source/11/replace-http.bash
diff --git a/docker/crupest-debian-dev/bootstrap/apt-source/12/add-deb-src.bash b/docker/crupest-debian-dev/bootstrap/apt-source/12/add-deb-src.bash
new file mode 100755
index 0000000..cf741d6
--- /dev/null
+++ b/docker/crupest-debian-dev/bootstrap/apt-source/12/add-deb-src.bash
@@ -0,0 +1,22 @@
+#! /usr/bin/env bash
+
+set -e
+
+dir=$(dirname "$0")
+domain=$("$dir/get-domain.bash")
+
+cat <<EOF >> /etc/apt/sources.list.d/debian.sources
+
+Types: deb-src
+URIs: https://$domain/debian
+Suites: bookworm bookworm-updates
+Components: main
+Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
+
+Types: deb-src
+URIs: https://$domain/debian-security
+Suites: bookworm-security
+Components: main
+Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
+
+EOF \ No newline at end of file
diff --git a/docker/crupest-debian-dev/bootstrap/apt-source/12/get-domain.bash b/docker/crupest-debian-dev/bootstrap/apt-source/12/get-domain.bash
new file mode 100755
index 0000000..a24538c
--- /dev/null
+++ b/docker/crupest-debian-dev/bootstrap/apt-source/12/get-domain.bash
@@ -0,0 +1,6 @@
+#! /usr/bin/env bash
+
+set -e
+
+grep -e 'URIs:' /etc/apt/sources.list.d/debian.sources | \
+ sed -E 's|URIs:\s*https?://([-_.a-zA-Z0-9]+)/.*|\1|;q'
diff --git a/docker/crupest-debian-dev/bootstrap/apt-source/12/replace-domain.bash b/docker/crupest-debian-dev/bootstrap/apt-source/12/replace-domain.bash
new file mode 100755
index 0000000..d55307c
--- /dev/null
+++ b/docker/crupest-debian-dev/bootstrap/apt-source/12/replace-domain.bash
@@ -0,0 +1,7 @@
+#! /usr/bin/env bash
+
+set -e
+
+echo "Backup /etc/apt/sources.list.d/debian.sources to /etc/apt/sources.list.d/debian.sources.bak."
+echo "Replace source domain in /etc/apt/sources.list.d/debian.sources to $1."
+sed -i.bak -E "s|(URIs:\\s*https?://)[-_.a-zA-Z0-9]+(/.*)|\\1$1\\2|" /etc/apt/sources.list.d/debian.sources
diff --git a/docker/crupest-debian-dev/bootstrap/apt-source/12/replace-http.bash b/docker/crupest-debian-dev/bootstrap/apt-source/12/replace-http.bash
new file mode 100755
index 0000000..ed4391d
--- /dev/null
+++ b/docker/crupest-debian-dev/bootstrap/apt-source/12/replace-http.bash
@@ -0,0 +1,7 @@
+#! /usr/bin/env bash
+
+set -e
+
+echo "Backup /etc/apt/sources.list to /etc/apt/sources.list.d/debian.sources.bak."
+echo "Replace http to https in /etc/apt/sources.list.d/debian.sources."
+sed -i.bak -E "s|(URIs:\\s*)https?(://[-_.a-zA-Z0-9]+/.*)|\\1https\\2|" /etc/apt/sources.list.d/debian.sources
diff --git a/docker/crupest-debian-dev/bootstrap/apt-source/china-source.txt b/docker/crupest-debian-dev/bootstrap/apt-source/china-source.txt
new file mode 100644
index 0000000..4312686
--- /dev/null
+++ b/docker/crupest-debian-dev/bootstrap/apt-source/china-source.txt
@@ -0,0 +1 @@
+mirrors.tuna.tsinghua.edu.cn \ No newline at end of file
diff --git a/docker/debian-dev/bootstrap/apt-source/install-apt-https.bash b/docker/crupest-debian-dev/bootstrap/apt-source/install-apt-https.bash
index 05d372b..70fb371 100755
--- a/docker/debian-dev/bootstrap/apt-source/install-apt-https.bash
+++ b/docker/crupest-debian-dev/bootstrap/apt-source/install-apt-https.bash
@@ -4,4 +4,5 @@ set -e
echo "Install apt https transport."
apt-get update
+apt-get install -y apt-utils
apt-get install -y apt-transport-https ca-certificates
diff --git a/docker/crupest-debian-dev/bootstrap/apt-source/setup.bash b/docker/crupest-debian-dev/bootstrap/apt-source/setup.bash
new file mode 100755
index 0000000..cdf68af
--- /dev/null
+++ b/docker/crupest-debian-dev/bootstrap/apt-source/setup.bash
@@ -0,0 +1,34 @@
+#! /usr/bin/env bash
+
+set -e
+
+dir=/bootstrap/apt-source
+
+echo "Getting debian version..."
+debian_version=$("$dir/../get-debian-version.bash")
+
+if [[ -z $debian_version ]]; then
+ echo "Debian version not found."
+ exit 1
+else
+ echo "Debian version: $debian_version"
+fi
+
+if [[ $debian_version -ge 12 ]]; then
+ setup_dir=$dir/12
+else
+ setup_dir=$dir/11
+fi
+
+echo "Setting up apt source..."
+
+if [[ -n $CRUPEST_DEBIAN_DEV_IN_CHINA ]]; then
+ echo "In China, using China source..."
+ "$setup_dir/replace-domain.bash" "$(cat "$dir/china-source.txt")"
+fi
+
+"$dir/install-apt-https.bash"
+"$setup_dir/replace-http.bash"
+"$setup_dir/add-deb-src.bash"
+
+echo "Setting up apt source done."
diff --git a/docker/debian-dev/bootstrap/bash-profile/bash-completion.bash b/docker/crupest-debian-dev/bootstrap/bash-profile/bash-completion.bash
index 75f8333..75f8333 100644
--- a/docker/debian-dev/bootstrap/bash-profile/bash-completion.bash
+++ b/docker/crupest-debian-dev/bootstrap/bash-profile/bash-completion.bash
diff --git a/docker/crupest-debian-dev/bootstrap/bash-profile/code-server.bash b/docker/crupest-debian-dev/bootstrap/bash-profile/code-server.bash
new file mode 100644
index 0000000..fd88d15
--- /dev/null
+++ b/docker/crupest-debian-dev/bootstrap/bash-profile/code-server.bash
@@ -0,0 +1,15 @@
+export CODE_SERVER_CONFIG="/data/code-server-config.yaml"
+
+CODE_SERVER_PROGRAM=code-server
+CODE_SERVER_PORT=8080
+
+if which "$CODE_SERVER_PROGRAM" > /dev/null 2>&1; then
+ if ! pgrep -f "$CODE_SERVER_PROGRAM" > /dev/null 2>&1; then
+ echo "code-server is not running, starting..."
+ mkdir -p ~/.local/share/code-server
+ "$CODE_SERVER_PROGRAM" "--bind-addr" "0.0.0.0:$CODE_SERVER_PORT" \
+ > ~/.local/share/code-server/log 2> ~/.local/share/code-server/error &
+ fi
+else
+ echo "code-server not found, skipping code-server setup."
+fi
diff --git a/docker/debian-dev/bootstrap/bash-profile/dquilt.bash b/docker/crupest-debian-dev/bootstrap/bash-profile/dquilt.bash
index 96a4eb2..96a4eb2 100644
--- a/docker/debian-dev/bootstrap/bash-profile/dquilt.bash
+++ b/docker/crupest-debian-dev/bootstrap/bash-profile/dquilt.bash
diff --git a/docker/code-server/install-cmake.bash b/docker/crupest-debian-dev/bootstrap/extra/setup-cmake.bash
index 7b74ba8..76c1ae4 100644..100755
--- a/docker/code-server/install-cmake.bash
+++ b/docker/crupest-debian-dev/bootstrap/extra/setup-cmake.bash
@@ -1,3 +1,7 @@
+#! /usr/bin/env bash
+
+set -e
+
CMAKE_VERSION=$(curl -s https://api.github.com/repos/Kitware/CMake/releases/latest | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
wget -O cmake-installer.sh https://github.com/Kitware/CMake/releases/download/v"$CMAKE_VERSION"/cmake-"$CMAKE_VERSION"-linux-x86_64.sh
chmod +x cmake-installer.sh
diff --git a/docker/code-server/install-dotnet.bash b/docker/crupest-debian-dev/bootstrap/extra/setup-dotnet.bash
index 5e437ff..0ef7743 100644..100755
--- a/docker/code-server/install-dotnet.bash
+++ b/docker/crupest-debian-dev/bootstrap/extra/setup-dotnet.bash
@@ -1,3 +1,7 @@
+#! /usr/bin/env bash
+
+set -e
+
wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
diff --git a/docker/crupest-debian-dev/bootstrap/extra/setup-llvm.bash b/docker/crupest-debian-dev/bootstrap/extra/setup-llvm.bash
new file mode 100755
index 0000000..48dde86
--- /dev/null
+++ b/docker/crupest-debian-dev/bootstrap/extra/setup-llvm.bash
@@ -0,0 +1,26 @@
+#! /usr/bin/env bash
+
+set -e
+
+LLVM_VERSION=18
+
+. /bootstrap/func.bash
+
+if is_true "$CRUPEST_DEBIAN_DEV_IN_CHINA"; then
+ base_url=https://mirrors.tuna.tsinghua.edu.cn/llvm-apt
+else
+ base_url=https://apt.llvm.org
+fi
+
+wget "$base_url/llvm.sh"
+chmod +x llvm.sh
+./llvm.sh $LLVM_VERSION all -m "$base_url"
+rm llvm.sh
+
+update-alternatives --install /usr/bin/clang clang /usr/bin/clang-$LLVM_VERSION 100 \
+ --slave /usr/bin/clang++ clang++ /usr/bin/clang++-$LLVM_VERSION \
+ --slave /usr/bin/clangd clangd /usr/bin/clangd-$LLVM_VERSION \
+ --slave /usr/bin/clang-format clang-format /usr/bin/clang-format-$LLVM_VERSION \
+ --slave /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-$LLVM_VERSION \
+ --slave /usr/bin/lldb lldb /usr/bin/lldb-$LLVM_VERSION \
+ --slave /usr/bin/lld lld /usr/bin/lld-$LLVM_VERSION
diff --git a/docker/debian-dev/bootstrap/func.bash b/docker/crupest-debian-dev/bootstrap/func.bash
index fb2ee77..d17fa1b 100644
--- a/docker/debian-dev/bootstrap/func.bash
+++ b/docker/crupest-debian-dev/bootstrap/func.bash
@@ -7,9 +7,9 @@ is_true() {
}
append-bash-profile() {
- cat "/bootstrap/bash-profile/$1" >> /root/.bash_profile
+ cat "/bootstrap/bash-profile/$1" >> /home/$CRUPEST_DEBIAN_DEV_USER/.bash_profile
}
copy-home-dot-file() {
- cp "/bootstrap/home-dot/$1" "/root/.$1"
+ cp "/bootstrap/home-dot/$1" "/home/$CRUPEST_DEBIAN_DEV_USER/.$1"
}
diff --git a/docker/crupest-debian-dev/bootstrap/get-debian-version.bash b/docker/crupest-debian-dev/bootstrap/get-debian-version.bash
new file mode 100755
index 0000000..2cc10b9
--- /dev/null
+++ b/docker/crupest-debian-dev/bootstrap/get-debian-version.bash
@@ -0,0 +1,13 @@
+#! /usr/bin/env bash
+
+set -e
+
+if [ -f /etc/os-release ]; then
+ . /etc/os-release
+ if [ "$ID" = "debian" ]; then
+ echo "$VERSION_ID"
+ exit 0
+ fi
+fi
+
+exit 1
diff --git a/docker/debian-dev/bootstrap/home-dot/devscripts b/docker/crupest-debian-dev/bootstrap/home-dot/devscripts
index a15b041..a15b041 100644
--- a/docker/debian-dev/bootstrap/home-dot/devscripts
+++ b/docker/crupest-debian-dev/bootstrap/home-dot/devscripts
diff --git a/docker/debian-dev/bootstrap/home-dot/quiltrc-dpkg b/docker/crupest-debian-dev/bootstrap/home-dot/quiltrc-dpkg
index e8fc3c5..e8fc3c5 100644
--- a/docker/debian-dev/bootstrap/home-dot/quiltrc-dpkg
+++ b/docker/crupest-debian-dev/bootstrap/home-dot/quiltrc-dpkg
diff --git a/docker/crupest-debian-dev/bootstrap/setup-base.bash b/docker/crupest-debian-dev/bootstrap/setup-base.bash
new file mode 100755
index 0000000..ce3372f
--- /dev/null
+++ b/docker/crupest-debian-dev/bootstrap/setup-base.bash
@@ -0,0 +1,25 @@
+#! /usr/bin/env bash
+
+set -e
+
+. /bootstrap/func.bash
+
+echo "Setting up basic system function..."
+
+echo "Installing basic packages..."
+apt-get install -y apt-utils
+apt-get install -y locales procps vim less man bash-completion software-properties-common rsync curl wget
+echo "Installing basic packages done."
+
+echo "Setting up locale..."
+localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
+echo "Setting up locale done."
+
+echo "Creating data/state dir..."
+mkdir -p /data /state
+chown $CRUPEST_DEBIAN_DEV_USER:$CRUPEST_DEBIAN_DEV_USER /data /state
+echo "Creating data dir done."
+
+append-bash-profile bash-completion.bash
+
+echo "Setting up basic system function done."
diff --git a/docker/crupest-debian-dev/bootstrap/setup-code-server.bash b/docker/crupest-debian-dev/bootstrap/setup-code-server.bash
new file mode 100755
index 0000000..34c9697
--- /dev/null
+++ b/docker/crupest-debian-dev/bootstrap/setup-code-server.bash
@@ -0,0 +1,28 @@
+#! /usr/bin/env bash
+
+set -e
+
+. /bootstrap/func.bash
+
+echo "Setting up code server..."
+
+echo "Get latest version of code-server..."
+VERSION=$(curl -s https://api.github.com/repos/coder/code-server/releases/latest | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
+echo "Current latest version of code-server is $VERSION"
+
+echo "Downloading code-server..."
+url="https://github.com/coder/code-server/releases/download/v${VERSION}/code-server_${VERSION}_amd64.deb"
+curl -sSfOL "$url"
+echo "Downloading code-server done."
+
+echo "Installing code-server..."
+apt-get install -y "./code-server_${VERSION}_amd64.deb"
+echo "Installing code-server done."
+
+echo "Cleaning up deb..."
+rm "code-server_${VERSION}_amd64.deb"
+echo "Cleaning up deb done."
+
+append-bash-profile code-server.bash
+
+echo "Setting up code server done."
diff --git a/docker/debian-dev/bootstrap/setup-dev.bash b/docker/crupest-debian-dev/bootstrap/setup-dev.bash
index 2e69da7..1335afc 100755
--- a/docker/debian-dev/bootstrap/setup-dev.bash
+++ b/docker/crupest-debian-dev/bootstrap/setup-dev.bash
@@ -4,10 +4,15 @@ set -e
. /bootstrap/func.bash
-apt-get install -y build-essential git devscripts debhelper quilt \
- cpio kmod bc python bison flex rsync libelf-dev libssl-dev libncurses-dev dwarves
+echo "Setting up dev function..."
+
+echo "Installing dev packages..."
+apt-get install -y build-essential git devscripts debhelper quilt
+apt-get build-dep -y linux
+echo "Installing dev packages done."
-append-bash-profile dev.bash
append-bash-profile dquilt.bash
copy-home-dot-file devscripts
copy-home-dot-file quiltrc-dpkg
+
+echo "Setting up dev function done."
diff --git a/docker/crupest-debian-dev/bootstrap/setup-user.bash b/docker/crupest-debian-dev/bootstrap/setup-user.bash
new file mode 100755
index 0000000..f74dcdb
--- /dev/null
+++ b/docker/crupest-debian-dev/bootstrap/setup-user.bash
@@ -0,0 +1,20 @@
+#! /usr/bin/env bash
+
+set -e
+
+echo "Setting up user..."
+
+echo "Installing sudo..."
+apt-get install -y sudo
+echo "Installing sudo done."
+
+echo "Setting up sudo..."
+sed -i.bak 's|%sudo[[:space:]]\+ALL=(ALL:ALL)[[:space:]]\+ALL|%sudo ALL=(ALL:ALL) NOPASSWD: ALL|' /etc/sudoers
+echo "Setting up sudo done."
+
+echo "Adding user $CRUPEST_DEBIAN_DEV_USER ..."
+useradd -m -G sudo -s /usr/bin/bash "$CRUPEST_DEBIAN_DEV_USER"
+echo "Adding user done."
+
+echo "Setting up user done."
+
diff --git a/docker/crupest-debian-dev/bootstrap/setup.bash b/docker/crupest-debian-dev/bootstrap/setup.bash
new file mode 100755
index 0000000..09b8137
--- /dev/null
+++ b/docker/crupest-debian-dev/bootstrap/setup.bash
@@ -0,0 +1,30 @@
+#! /usr/bin/env bash
+
+set -e
+
+export DEBIAN_FRONTEND=noninteractive
+
+echo "Setting up crupest-debian-dev..."
+
+. /bootstrap/func.bash
+
+/bootstrap/apt-source/setup.bash
+
+echo "Updating apt source index..."
+apt-get update
+echo "Updating apt source index done."
+
+/bootstrap/setup-user.bash
+/bootstrap/setup-base.bash
+/bootstrap/setup-dev.bash
+
+if is_true "$CRUPEST_DEBIAN_DEV_SETUP_CODE_SERVER"; then
+ echo "CRUPEST_DEBIAN_DEV_SETUP_CODE_SERVER is true, setting up code-server..."
+ /bootstrap/setup-code-server.bash
+fi
+
+echo "Cleaning up apt source index..."
+rm -rf /var/lib/apt/lists/*
+echo "Cleaning up apt source index done."
+
+echo "Setting up crupest-debian-dev done."
diff --git a/docker/crupest-debian-dev/bootstrap/wait.bash b/docker/crupest-debian-dev/bootstrap/wait.bash
new file mode 100755
index 0000000..501c706
--- /dev/null
+++ b/docker/crupest-debian-dev/bootstrap/wait.bash
@@ -0,0 +1,5 @@
+#! /usr/bin/env bash
+
+set -e
+
+tail -f /dev/null
diff --git a/docker/debian-dev/Dockerfile b/docker/debian-dev/Dockerfile
deleted file mode 100644
index ce0b10c..0000000
--- a/docker/debian-dev/Dockerfile
+++ /dev/null
@@ -1,18 +0,0 @@
-FROM debian:11
-
-ARG USERNAME=
-ARG IN_CHINA=
-ARG SETUP_SBUILD=
-
-ENV USERNAME=${USERNAME}
-ENV IN_CHINA=${IN_CHINA}
-ENV SETUP_SBUILD=${SETUP_SBUILD}
-
-ADD bootstrap /bootstrap
-
-RUN /bootstrap/setup.bash
-
-USER ${USERNAME}
-
-VOLUME [ "/source", "/data", "/share" ]
-CMD [ "bash", "-l" ]
diff --git a/docker/debian-dev/bootstrap/apt-source/china-source.txt b/docker/debian-dev/bootstrap/apt-source/china-source.txt
deleted file mode 100644
index 3821ffc..0000000
--- a/docker/debian-dev/bootstrap/apt-source/china-source.txt
+++ /dev/null
@@ -1 +0,0 @@
-mirrors.ustc.edu.cn
diff --git a/docker/debian-dev/bootstrap/apt-source/setup.bash b/docker/debian-dev/bootstrap/apt-source/setup.bash
deleted file mode 100755
index 60e635b..0000000
--- a/docker/debian-dev/bootstrap/apt-source/setup.bash
+++ /dev/null
@@ -1,12 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-dir=$(dirname "$0")
-
-if [[ -n $IN_CHINA ]]; then
- "$dir/replace-domain.bash" "$(cat "$dir/china-source.txt")"
-fi
-
-"$dir/install-apt-https.bash"
-"$dir/replace-http.bash"
diff --git a/docker/debian-dev/bootstrap/bash-profile/auto-start-apt-cacher.bash b/docker/debian-dev/bootstrap/bash-profile/auto-start-apt-cacher.bash
deleted file mode 100644
index f230cb1..0000000
--- a/docker/debian-dev/bootstrap/bash-profile/auto-start-apt-cacher.bash
+++ /dev/null
@@ -1,2 +0,0 @@
-echo "Start apt-cacher-ng if it does not start..."
-pgrep apt-cacher-ng || apt-cacher-ng
diff --git a/docker/debian-dev/bootstrap/bash-profile/dev.bash b/docker/debian-dev/bootstrap/bash-profile/dev.bash
deleted file mode 100644
index c49dc35..0000000
--- a/docker/debian-dev/bootstrap/bash-profile/dev.bash
+++ /dev/null
@@ -1 +0,0 @@
-alias cp-no-git="rsync -a --exclude='**/.git'"
diff --git a/docker/debian-dev/bootstrap/home-dot/sbuildrc b/docker/debian-dev/bootstrap/home-dot/sbuildrc
deleted file mode 100644
index b04ff83..0000000
--- a/docker/debian-dev/bootstrap/home-dot/sbuildrc
+++ /dev/null
@@ -1,25 +0,0 @@
-##############################################################################
-# PACKAGE BUILD RELATED (additionally produce _source.changes)
-##############################################################################
-$distribution = 'bullseye';
-
-$build_source = 0;
-
-#$source_only_changes = 1;
-#$verbose = 1;
-#$ENV{'DEB_BUILD_OPTIONS'} = 'parallel=5';
-##############################################################################
-# POST-BUILD RELATED (turn off functionality by setting variables to 0)
-##############################################################################
-$run_lintian = 0;
-# $lintian_opts = ['-i', '-I'];
-$run_piuparts = 0;
-# $piuparts_opts = ['--schroot', '%r-%a-sbuild', '--no-eatmydata'];
-$run_autopkgtest = 0;
-# $autopkgtest_root_args = '';
-# $autopkgtest_opts = [ '--', 'schroot', '%r-%a-sbuild' ];
-
-##############################################################################
-# PERL MAGIC
-##############################################################################
-1;
diff --git a/docker/debian-dev/bootstrap/sbuild/setup-amd64.bash b/docker/debian-dev/bootstrap/sbuild/setup-amd64.bash
deleted file mode 100755
index 2c05e40..0000000
--- a/docker/debian-dev/bootstrap/sbuild/setup-amd64.bash
+++ /dev/null
@@ -1,7 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-SBUILD_ARCH="amd64"
-
-sbuild-createchroot --include=eatmydata --command-prefix=eatmydata --arch=${SBUILD_ARCH} ${SBUILD_DIST} /srv/chroot/${SBUILD_DIST}-${SBUILD_ARCH}-sbuild "${SBUILD_MIRROR}"
diff --git a/docker/debian-dev/bootstrap/sbuild/setup.bash b/docker/debian-dev/bootstrap/sbuild/setup.bash
deleted file mode 100755
index 5180db6..0000000
--- a/docker/debian-dev/bootstrap/sbuild/setup.bash
+++ /dev/null
@@ -1,25 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-dir=$(dirname $0)
-
-. /bootstrap/func.bash
-
-apt-get install -y sbuild schroot debootstrap
-
-copy-home-dot-file sbuildrc
-
-# setup apt-cacher-ng
-apt-get install -y apt-cacher-ng
-append-bash-profile auto-start-apt-cacher.bash
-apt-cacher-ng
-export SBUILD_MIRROR="http://127.0.0.1:3142/$(/bootstrap/apt-source/get-domain.bash)/debian"
-
-export SBUILD_DIST="bullseye"
-
-"$dir/setup-amd64.bash"
-
-if [[ "$BUILD_FOR_ARCH" == "arm64" ]]; then
- "$dir/setup-arm64.bash"
-fi
diff --git a/docker/debian-dev/bootstrap/setup-base.bash b/docker/debian-dev/bootstrap/setup-base.bash
deleted file mode 100755
index dda9e42..0000000
--- a/docker/debian-dev/bootstrap/setup-base.bash
+++ /dev/null
@@ -1,10 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-. /bootstrap/func.bash
-
-apt-get update
-apt-get install -y vim less man curl bash-completion rsync
-
-append-bash-profile bash-completion.bash
diff --git a/docker/debian-dev/bootstrap/setup-user.bash b/docker/debian-dev/bootstrap/setup-user.bash
deleted file mode 100755
index 0eccde4..0000000
--- a/docker/debian-dev/bootstrap/setup-user.bash
+++ /dev/null
@@ -1,9 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-apt-get install -y sudo
-
-sed -i.bak 's|%sudo[[:space:]]\+ALL=(ALL:ALL)[[:space:]]\+ALL|%sudo ALL=(ALL:ALL) NOPASSWD: ALL|' /etc/sudoers
-
-useradd -m -G sudo -s /usr/bin/bash "$USERNAME"
diff --git a/docker/debian-dev/bootstrap/setup.bash b/docker/debian-dev/bootstrap/setup.bash
deleted file mode 100755
index c72db87..0000000
--- a/docker/debian-dev/bootstrap/setup.bash
+++ /dev/null
@@ -1,20 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-export DEBIAN_FRONTEND=noninteractive
-
-/bootstrap/apt-source/setup.bash
-/bootstrap/setup-user.bash
-/bootstrap/setup-base.bash
-/bootstrap/setup-dev.bash
-
-. /bootstrap/func.bash
-
-if is_true "$SETUP_SBUILD"; then
- echo "Setup sbuild..."
- /bootstrap/sbuild/setup.bash
-else
- echo "Sbuild is disabled. Skipped."
-fi
-
diff --git a/template/docker-compose.yaml.template b/template/docker-compose.yaml.template
index 060a3c2..4f85036 100644
--- a/template/docker-compose.yaml.template
+++ b/template/docker-compose.yaml.template
@@ -145,7 +145,20 @@ services:
timeout: 3s
retries: 0
+ debian-dev:
+ pull_policy: build
+ build:
+ context: ./docker/code-server
+ dockerfile: Dockerfile
+ pull: true
+ tags:
+ - "crupest/debian-dev:latest"
+ container_name: debian-dev
+ restart: on-failure:3
+ volumes:
+ - ./data/debian-dev:/data
+ - debian-dev-state:/state
volumes:
blog-public:
-
+ debian-dev-state: