seems to work a lot better
This commit is contained in:
parent
acaa1eda21
commit
489a3814fd
5 changed files with 70 additions and 43 deletions
53
README.md
53
README.md
|
@ -1,41 +1,36 @@
|
|||
A simple method of utilizing Docker for your dev environment. Specifically
|
||||
designed for use on X11 systems.
|
||||
# OKAY NERDS LISTEN UP
|
||||
|
||||
# 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
|
||||
forwarding with SSH I supposed, except you pass through all the sockets and
|
||||
shit.
|
||||
## What this Repo is For?
|
||||
|
||||
This means that you can define dev environments for specific purposes and then
|
||||
run them when they are needed.
|
||||
`base` defines a developer environment. It packages up Git and Neovim into a quick-and-easy docker image.
|
||||
|
||||
If that involves opening an IDE or testing a Flutter app then it seems to all
|
||||
happen as if it's on your machine.
|
||||
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.
|
||||
|
||||
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
|
||||
maintain it on my machine. I keep this repo on my home machine but also my work
|
||||
machine, so that when I keep configurations in sync easily.
|
||||
- Base now only installs ssh/git/yay/nvim and configures nvim
|
||||
- I expect that you're adhering to XDG shit for ssh socks. IE /run/user/some/shit
|
||||
- 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,
|
||||
simple method of achieving what Snap and Flatpak sort-of tried to achieve in
|
||||
some ways.
|
||||
It does seem to kind-of "just work".
|
||||
|
||||
# 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.
|
||||
|
||||
Populate configuration files in base for git, nvim and tmux.
|
||||
|
||||
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.
|
||||
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
|
||||
COLORTERM variables. I try to set sane variables but I think mapping ~/.bashrc breaks
|
||||
that.
|
||||
|
|
|
@ -16,8 +16,9 @@ WORKDIR /home/x
|
|||
|
||||
## Install Yay incase we need it
|
||||
RUN sudo pacman -S --noconfirm git base-devel
|
||||
RUN git clone https://aur.archlinux.org/yay.git \
|
||||
&& cd yay \
|
||||
COPY ./yay yay
|
||||
RUN sudo chown -R x:x yay
|
||||
RUN cd yay \
|
||||
&& makepkg -si --noconfirm \
|
||||
&& cd .. && rm -rf yay \
|
||||
&& 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.
|
||||
RUN nvim --headless "+Lazy! update" +qa
|
||||
|
||||
## Install OpenSSH
|
||||
RUN sudo pacman -Sy --noconfirm openssh
|
||||
|
||||
# Install Tmux
|
||||
RUN sudo pacman -S --noconfirm tmux
|
||||
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
|
||||
RUN sudo pacman -S --noconfirm git
|
||||
RUN mkdir -p /home/x/.config/git
|
||||
#COPY ~/.gitconfig /home/x/.gitconfig
|
||||
COPY git/confs/ /home/x/.config/git/
|
||||
|
||||
## Tofu
|
||||
# Might run into version issues because AUR isn't a versioned repo.
|
||||
RUN yay -Syu --noconfirm opentofu
|
||||
|
||||
## AWS CLI
|
||||
RUN yay -Syu --noconfirm aws-cli-v2
|
||||
## Entrypoint
|
||||
# This entrypoint allows us to avoid jank ssh agent jazz
|
||||
USER root
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chown x:x /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
USER x
|
||||
|
||||
## Quick drop password at end of build output
|
||||
RUN echo "Your password: $PASS"
|
||||
|
||||
ENTRYPOINT ["/bin/bash"]
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
|
16
base/entrypoint.sh
Normal file
16
base/entrypoint.sh
Normal 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
1
base/yay
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 59714d8ae3dc1e5790228c1faeef8283b0c0101f
|
18
run.sh
18
run.sh
|
@ -1,12 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
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
|
||||
|
||||
# Run the devenv
|
||||
docker run -it --rm \
|
||||
-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 /tmp/.X11-unix:/tmp/.X11-unix \
|
||||
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
||||
-e DISPLAY=${DISPLAY} \
|
||||
--device /dev/dri \
|
||||
--group-add video \
|
||||
|
@ -16,7 +27,8 @@ docker_run() {
|
|||
}
|
||||
|
||||
docker_build() {
|
||||
docker build ./${1} -t d:${1}
|
||||
# --network=host prevent stupid docker shit breaking yay
|
||||
docker build --network=host ./${1} -t d:${1}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue