seems to work a lot better

This commit is contained in:
j 2025-08-16 02:10:04 +00:00
parent acaa1eda21
commit 489a3814fd
5 changed files with 70 additions and 43 deletions

View file

@ -1,41 +1,36 @@
A simple method of utilizing Docker for your dev environment. Specifically # OKAY NERDS LISTEN UP
designed for use on X11 systems.
# Why X11? I had to make some fucking compromises okay?
X11 runs a server which allows you to pass through windows. Kind of like x ## What this Repo is For?
forwarding with SSH I supposed, except you pass through all the sockets and
shit.
This means that you can define dev environments for specific purposes and then `base` defines a developer environment. It packages up Git and Neovim into a quick-and-easy docker image.
run them when they are needed.
If that involves opening an IDE or testing a Flutter app then it seems to all Then you extend upon it to create environments for different purposes. The `flutter` example provided shows how you can maintain the same cozy environment while also being able to test GUI application. This is thanks to two things; x application forwarding and xwayland.
happen as if it's on your machine.
No Qemu, just running binaries in Docker. ## What are the compromises
# Fast & Loose I can't make it a one-stop-shop thing. You have to mount a few cheeky locations, and it all depends on your configuration, because all of us fucking Linux users have more opinions on sysconf than windows users have spyware.
I'm not using Docker the way that I preech in this. I had to draw some bloody boundaries, okay?
I use Dockerfiles to define each dev env so that I don't have to actively - Base now only installs ssh/git/yay/nvim and configures nvim
maintain it on my machine. I keep this repo on my home machine but also my work - I expect that you're adhering to XDG shit for ssh socks. IE /run/user/some/shit
machine, so that when I keep configurations in sync easily. - I expect that you have xhost installed.
- I expect that if this throws errors that you figure your own shit out
- I expect that you have ~/.gitconfig configured on your host
- I expect that your ~/.gitconfig just looks at ~/.config/git like it should from fucking factory
- You're welcome to map ~/.config/nvim I dont care.
- Other shit. Read run.sh.
I may keep multiple binaries running in each container. ## What's nice?
None of this is really how you're meant to use Docker however it's a nice, It does seem to kind-of "just work".
simple method of achieving what Snap and Flatpak sort-of tried to achieve in
some ways.
# Installation If you're using SSH agent properly on your host then the docker container just kinda
shares that love. Adding keys in container also adds in host because of volume maps
Clone repo. So this whole thing is kinda chill. The only annoying thing is that sometimes
the text in container is blue, sometimes it's white. Depends on your TERM and
Populate configuration files in base for git, nvim and tmux. COLORTERM variables. I try to set sane variables but I think mapping ~/.bashrc breaks
that.
Build and run base.
You can map your configuraitons or whatever. I like to build them into the
images, because my vim confs get pretty weighty.

View file

@ -16,8 +16,9 @@ WORKDIR /home/x
## Install Yay incase we need it ## Install Yay incase we need it
RUN sudo pacman -S --noconfirm git base-devel RUN sudo pacman -S --noconfirm git base-devel
RUN git clone https://aur.archlinux.org/yay.git \ COPY ./yay yay
&& cd yay \ RUN sudo chown -R x:x yay
RUN cd yay \
&& makepkg -si --noconfirm \ && makepkg -si --noconfirm \
&& cd .. && rm -rf yay \ && cd .. && rm -rf yay \
&& yay -Syu && yay -Syu
@ -41,6 +42,9 @@ COPY ./nvim /home/x/.config/nvim
# Just to avoid lengthy startups but we'll see how this approach goes. # Just to avoid lengthy startups but we'll see how this approach goes.
RUN nvim --headless "+Lazy! update" +qa RUN nvim --headless "+Lazy! update" +qa
## Install OpenSSH
RUN sudo pacman -Sy --noconfirm openssh
# Install Tmux # Install Tmux
RUN sudo pacman -S --noconfirm tmux RUN sudo pacman -S --noconfirm tmux
COPY tmux/tmux.conf /home/x/.tmux.conf COPY tmux/tmux.conf /home/x/.tmux.conf
@ -49,17 +53,16 @@ COPY tmux/tmux.conf /home/x/.tmux.conf
# Should already be installed for Yay but repeating stuff to keep everything in blocks # Should already be installed for Yay but repeating stuff to keep everything in blocks
RUN sudo pacman -S --noconfirm git RUN sudo pacman -S --noconfirm git
RUN mkdir -p /home/x/.config/git RUN mkdir -p /home/x/.config/git
#COPY ~/.gitconfig /home/x/.gitconfig
COPY git/confs/ /home/x/.config/git/
## Tofu ## Entrypoint
# Might run into version issues because AUR isn't a versioned repo. # This entrypoint allows us to avoid jank ssh agent jazz
RUN yay -Syu --noconfirm opentofu USER root
COPY entrypoint.sh /entrypoint.sh
## AWS CLI RUN chown x:x /entrypoint.sh
RUN yay -Syu --noconfirm aws-cli-v2 RUN chmod +x /entrypoint.sh
USER x
## Quick drop password at end of build output ## Quick drop password at end of build output
RUN echo "Your password: $PASS" RUN echo "Your password: $PASS"
ENTRYPOINT ["/bin/bash"] ENTRYPOINT ["/entrypoint.sh"]

16
base/entrypoint.sh Normal file
View file

@ -0,0 +1,16 @@
#!/bin/bash
# Start the ssh-agent if it's not already running
if [ ! -S /tmp/ssh-agent.sock ]; then
eval $(ssh-agent -a /tmp/ssh-agent.sock)
fi
# Export environment variables globally
export SSH_AUTH_SOCK=/tmp/ssh-agent.sock
echo "export SSH_AUTH_SOCK=/tmp/ssh-agent.sock" >> /etc/profile.d/ssh-agent.sh
# Optionally preload keys
# ssh-add /path/to/id_rsa
# Start tmux
SSH_AUTH_SOCK=/tmp/ssh-agent.sock tmux

1
base/yay Submodule

@ -0,0 +1 @@
Subproject commit 59714d8ae3dc1e5790228c1faeef8283b0c0101f

18
run.sh
View file

@ -1,12 +1,23 @@
#!/bin/bash #!/bin/bash
docker_run() { docker_run() {
# If the auth sock is empty just mount random shit I dont fucking care.
[ -z "$SSH_AUTH_SOCK" ] && SSH_AUTH_SOCK=$(mktemp)
# Allow docker to forward some x shit.
xhost +local:docker xhost +local:docker
# Run the devenv
docker run -it --rm \ docker run -it --rm \
-u "${UID}:${GID}" \ -u "${UID}:${GID}" \
-v $HOME/Projects:/home/x/Projects \ -v ~/.bashrc:/home/x/.bashrc \
-v ~/.ssh:/home/x/.ssh \
-v ${SSH_AUTH_SOCK}:/run/user/${UID}/ssh-agent.socket \
-v ~/.gitconfig:/home/x/.gitconfig \
-v ~/.config/git:/home/x/.config/git \
-v $HOME/Projects:/home/x/Projects \
-v ${HOME}/.Xauthority:/home/x/.Xauthority \ -v ${HOME}/.Xauthority:/home/x/.Xauthority \
-v /tmp/.X11-unix:/tmp/.X11-unix \ -v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=${DISPLAY} \ -e DISPLAY=${DISPLAY} \
--device /dev/dri \ --device /dev/dri \
--group-add video \ --group-add video \
@ -16,7 +27,8 @@ docker_run() {
} }
docker_build() { docker_build() {
docker build ./${1} -t d:${1} # --network=host prevent stupid docker shit breaking yay
docker build --network=host ./${1} -t d:${1}
} }