diff --git a/README.md b/README.md index c7ffbe0..49d816f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,41 @@ -# devenv +A simple method of utilizing Docker for your dev environment. Specifically +designed for use on X11 systems. -Docker based dev environments. \ No newline at end of file +# Why X11? + +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. + +This means that you can define dev environments for specific purposes and then +run them when they are needed. + +If that involves opening an IDE or testing a Flutter app then it seems to all +happen as if it's on your machine. + +No Qemu, just running binaries in Docker. + +# Fast & Loose + +I'm not using Docker the way that I preech in this. + +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. + +I may keep multiple binaries running in each container. + +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. + +# Installation + +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. diff --git a/base/Dockerfile b/base/Dockerfile new file mode 100644 index 0000000..8881333 --- /dev/null +++ b/base/Dockerfile @@ -0,0 +1,62 @@ +FROM archlinux:latest + +# Update +RUN pacman -Syu --noconfirm + +## Configure non-root user +RUN pacman -S --noconfirm sudo +RUN useradd -m -s /bin/bash -G wheel x +RUN PASS=$(openssl rand -base64 14) && echo "x:$PASS" | chpasswd && echo "Pass $PASS" +RUN echo 'x ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers +USER x +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 \ + && makepkg -si --noconfirm \ + && cd .. && rm -rf yay \ + && yay -Syu + +## Install Neovim +RUN sudo pacman -S --needed --noconfirm \ + neovim git curl unzip tar wget \ + nodejs npm \ + python python-pip \ + lua \ + go \ + ripgrep \ + fd \ + gcc make base-devel \ + xclip xsel wl-clipboard \ + lazygit +RUN yay -S --noconfirm terraform-ls +RUN mkdir -p /home/x/.config/ +COPY ./nvim /home/x/.config/nvim +# Should run Lazy update and keep the base image reasonably up to date +# Just to avoid lengthy startups but we'll see how this approach goes. +RUN nvim --headless "+Lazy! update" +qa + +# Install Tmux +RUN sudo pacman -S --noconfirm tmux +COPY tmux/tmux.conf /home/x/.tmux.conf + +## Git +# 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 git/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 -S --noconfirm opentofu + +## AWS CLI +RUN yay -S --noconfirm aws-cli-v2 + +## Quick drop password at end of build output +RUN echo "Your password: $PASS" + +ENTRYPOINT ["/bin/bash"] diff --git a/base/git/gitconfig b/base/git/gitconfig new file mode 100644 index 0000000..15c2eeb --- /dev/null +++ b/base/git/gitconfig @@ -0,0 +1,11 @@ +[includeIf "gitdir:/home/x/Projects/xestro/"] + path = ~/.config/git/xestro.conf + +[includeIf "gitdir:/home/x/Projects/repobase/"] + path = ~/.config/git/repobase.conf + +[includeIf "gitdir:/home/x/Projects/gitlab/"] + path = ~/.config/git/gitlab.conf + +[includeIf "gitdir:/home/x/Projects/github/"] + path = ~/.config/git/github.conf diff --git a/flutter/Dockerfile b/flutter/Dockerfile new file mode 100644 index 0000000..b52245b --- /dev/null +++ b/flutter/Dockerfile @@ -0,0 +1,15 @@ +FROM d:base + +USER root + +RUN pacman -Syu --noconfirm base-devel cmake ninja clang pkgconf gtk3 libxcb + +RUN git clone https://github.com/flutter/flutter.git /opt/flutter \ + && chown -R x:x /opt/flutter + +USER x + +ENV PATH="/opt/flutter/bin:${PATH}" +RUN flutter doctor + +WORKDIR /home/x/Projects diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..fceb6e7 --- /dev/null +++ b/run.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +docker_run() { + xhost +local:docker + docker run -it --rm \ + -u "${UID}:${GID}" \ + -v $HOME/Projects:/home/x/Projects \ + -v ${HOME}/.Xauthority:/home/x/.Xauthority \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e DISPLAY=${DISPLAY} \ + --device /dev/dri \ + --group-add video \ + -v /var/run/docker.sock:/var/run/docker.sock \ + --entrypoint /usr/bin/tmux \ + d:${1} +} + +docker_build() { + docker build ./${1} -t d:${1} +} + + +case "$1" in + *) + docker_build $1 && docker_run $1 + ;; +esac