feat: overhaul container initialization and entrypoint
- Replace apt-get with apt in Dockerfile - Add tini as init system and set ENTRYPOINT/CMD - Simplify init.fish by removing first-run logic and tmux session management - Add landing.fish and SIGTERM signal handling - Improve container lifecycle management
This commit is contained in:
+6
-3
@@ -5,14 +5,17 @@ RUN git clone https://github.com/iceBear67/bubble .
|
||||
FROM debian:13
|
||||
COPY --from=0 --chmod=0755 /src/bubble.sh /bin/bubble
|
||||
RUN <<EOF
|
||||
apt-get update && apt-get upgrade
|
||||
apt update
|
||||
apt upgrade
|
||||
chmod +x /bin/bubble
|
||||
apt-get install -y curl jq neovim htop fish tmux sudo git iproute2 iputils-ping dnsutils openssh-sftp-server build-essential htop
|
||||
apt install curl jq neovim htop fish tmux sudo git iproute2 iputils-ping dnsutils openssh-sftp-server build-essential htop tini
|
||||
useradd -m -s /usr/bin/fish user
|
||||
echo "user ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
|
||||
sudo -u user mkdir -p /home/user/.config/fish/
|
||||
ln -s /usr/lib/openssh/sftp-server /usr/sbin/bubble-sftp
|
||||
EOF
|
||||
COPY ./init.fish /init.fish
|
||||
COPY ./landing.fish /landing.fish
|
||||
COPY --chown=user ./user.fish /home/user/.config/fish/config.fish
|
||||
|
||||
ENTRYPOINT ["/usr/bin/tini", "--"]
|
||||
CMD ["/usr/bin/fish", "/init.fish"]
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
function init
|
||||
if test -f /tmp/bubble_container_started
|
||||
return
|
||||
end
|
||||
echo "First login detected, initializing container environment..."
|
||||
if ! touch /tmp/bubble_container_started
|
||||
echo "FAILED to mark status. The initialization was cancelled."
|
||||
echo "Certain services (like Tailscale) won't work."
|
||||
end
|
||||
if test -f /usr/sbin/tailscaled
|
||||
echo "Starting tailscaled"
|
||||
chmod +x /usr/sbin/tailscaled
|
||||
@@ -24,37 +16,10 @@ function init
|
||||
end
|
||||
|
||||
init
|
||||
function on_term --on-signal SIGTERM
|
||||
echo "SIGTERM received, exiting"
|
||||
exit
|
||||
end
|
||||
fish
|
||||
|
||||
if ! cat /etc/passwd | grep -E "^user"
|
||||
echo "User was not created correctly. Creating user..."
|
||||
useradd -m -s /usr/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 test (sudo -u user tmux list-windows | wc -l) -eq 0
|
||||
cd /home/user
|
||||
sudo -u user tmux
|
||||
return
|
||||
end
|
||||
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 /usr/bin/fish
|
||||
# else
|
||||
# sudo -u user tmux attach -t 0
|
||||
# end
|
||||
sudo -u user tmux attach -t 0
|
||||
else
|
||||
cd /home/user
|
||||
sudo -u user tmux new-session -c /usr/bin/fish
|
||||
end
|
||||
end
|
||||
|
||||
resume
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
if ! cat /etc/passwd | grep -E "^user"
|
||||
echo "User was not created correctly. Creating user..."
|
||||
useradd -m -s /usr/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 test (sudo -u user tmux list-windows | wc -l) -eq 0
|
||||
cd /home/user
|
||||
sudo -u user tmux
|
||||
return
|
||||
end
|
||||
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 /usr/bin/fish
|
||||
# else
|
||||
# sudo -u user tmux attach -t 0
|
||||
# end
|
||||
sudo -u user tmux attach -t 0
|
||||
else
|
||||
cd /home/user
|
||||
sudo -u user tmux new-session -c /usr/bin/fish
|
||||
end
|
||||
end
|
||||
|
||||
resume
|
||||
Reference in New Issue
Block a user