commit 96fcb9529a29eca6eb92bcf22f0cb5edb802fefa Author: iceBear67 Date: Sat Mar 22 14:26:53 2025 +0800 init diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5f0790f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM golang:1.24 +RUN git clone https://github.com/iceBear67/bubble && cd bubble/ && bash ./build.sh + +FROM debian:11 +COPY --from=0 /bubble/src/target/client /bin/bubble +RUN < /etc/sudoers.d/user.conf +EOF +COPY ./init.fish /home/user/.init.fish + diff --git a/init.fish b/init.fish new file mode 100644 index 0000000..bc77a6f --- /dev/null +++ b/init.fish @@ -0,0 +1,26 @@ +if ! cat /etc/passwd | grep -E "^user" + echo "User was not created correctly. Creating user..." + useradd -m -s /bin/fish user + if test ! -e /etc/sudoers.d/user.conf + echo "Setting sudo permissions" + mkdir -p /etc/sudoers.d/ + echo "user ALL=(ALL) NOPASSWD: ALL" >/etc/sudoers.d/user.conf + end + echo "Due to abnormal user creation, auto configuration guide is not available in this setup." + echo "Try 'bubble destroy' for a new container if needed." +end + +function resume + if sudo -u user tmux has-session -t 0 + if sudo -u user tmux ls | grep -E "^0.*attached)" + echo "The default tmux session has been attached, dropping you to a normal shell." + cd /home/user && sudo -u user /bin/fish + else + sudo -u user tmux attach -t 0 + end + else + sudo -u user tmux new-session -c /home/user /bin/fish + end +end + +resume diff --git a/user.fish b/user.fish new file mode 100644 index 0000000..7d28a7a --- /dev/null +++ b/user.fish @@ -0,0 +1,28 @@ +function install-docker + if test -e /bin/docker + echo "Docker is already present at /bin/docker." + return + end + echo "Installing docker in 3s." + sleep 3s + echo "[DOCKER] Updating software registry." + sudo apt-get update + sudo apt-get install ca-certificates + echo "[DOCKER] Updating package manager keyrings" + sudo install -m 0755 -d /etc/apt/keyrings + echo "[DOCKER] Adding trust for docker repository" + sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc + sudo chmod a+r /etc/apt/keyrings/docker.asc + echo "[DOCKER] Adding docker repository" + bash -c 'echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \ + $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null' + sudo apt-get update + echo "[DOCKER] Installing docker" + if sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + echo "[DOCKER] Docker should be installed successfully" + else + echo "Unexpected error." + end +end