diff --git a/.forgejo/workflows/publish.yaml b/.forgejo/workflows/publish.yaml index 5782bae..e1eb45a 100644 --- a/.forgejo/workflows/publish.yaml +++ b/.forgejo/workflows/publish.yaml @@ -65,7 +65,7 @@ jobs: - name: Build and push uses: docker/build-push-action@v6 with: - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 push: true context: "{{defaultContext}}:${{ matrix.box.path }}" tags: | diff --git a/boxes/devbox/.justfile b/boxes/devbox/.justfile new file mode 100644 index 0000000..3d15b8b --- /dev/null +++ b/boxes/devbox/.justfile @@ -0,0 +1,21 @@ +clean := "false" +box_name := file_stem(invocation_directory()) + +unexport GOBIN +unexport GOPATH +unexport GOROOT + + +# Create a new box from current directory +[no-cd] +build box_name: + [[ "{{clean}}" == "true" ]] && sudo rm -rf ${HOME}/chroots/{{ box_name }} || true + + podman build -t {{box_name}}:latest . + + distrobox assemble create + +# Enter the box +enter box_name: + clear + @distrobox enter --clean-path --no-workdir {{box_name}} diff --git a/boxes/devbox/Dockerfile b/boxes/devbox/Dockerfile index b964e6d..aa7f5fb 100644 --- a/boxes/devbox/Dockerfile +++ b/boxes/devbox/Dockerfile @@ -1,22 +1,50 @@ -FROM quay.io/toolbx-images/alpine-toolbox:edge +FROM rust:latest AS rust-builder -# Update system and install packages -RUN apk update && apk upgrade && \ - apk add --no-cache \ - neovim \ - git \ - lazygit \ - zsh \ +# setup cargo packages, prefer to use apk packages +# to reduce build time and space +RUN --mount=type=cache,target=/app/target/ \ + --mount=type=cache,target=/usr/local/cargo/git/db \ + --mount=type=cache,target=/usr/local/cargo/registry/ \ + curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash \ + && cargo binstall --no-confirm \ + dotter + +FROM ghcr.io/void-linux/void-glibc-full:latest + +# Setup void packages +RUN --mount=type=cache,target=/var/cache/xbps/ \ + xbps-install -Syu \ + && xbps-install -Sy \ + bash \ + bat \ + cocogitto \ curl \ - wget \ - ripgrep \ + eza \ fd \ fzf \ - alpine-sdk \ - build-base \ - python3 \ - py3-pip \ - openssh + gcc \ + git \ + just \ + lazygit \ + neovim \ + nodejs \ + ripgrep \ + sd \ + starship \ + tealdeer \ + tmux \ + tree-sitter \ + void-repo-multilib \ + void-repo-multilib-nonfree \ + void-repo-nonfree \ + yazi \ + zoxide \ + zsh + +# Import cargo packages +COPY --from=rust-builder /usr/local/cargo/bin/* /usr/local/bin/ + +COPY ./scripts/* /usr/local/bin/ # Set environment variables ENV EDITOR=nvim \ @@ -24,18 +52,14 @@ ENV EDITOR=nvim \ TERM=xterm-256color \ LANG=en_US.UTF-8 \ LC_ALL=en_US.UTF-8 \ - SHELL=/bin/zsh + SHELL=/usr/bin/zsh -# Install and initialize chezmoi -RUN sh -c "$(curl -fsLS get.chezmoi.io)" -- -b /usr/local/bin && \ - mkdir -p ~/.local/share/chezmoi - -RUN chsh -s /bin/zsh - -RUN mkdir -p /workspace - -WORKDIR /workspace +# Basic setup +RUN \ + # chsh -s /usr/bin/nu \ + chsh -s /usr/bin/zsh \ + && chmod +x /usr/local/bin/* # Build commands: -# Docker: docker build -t dev-env . -# Podman: podman build -t dev-env . +# Docker: docker build -t devbox . +# Podman: podman build -t devbox . diff --git a/boxes/devbox/distrobox.ini b/boxes/devbox/distrobox.ini index 8e37068..e459b93 100644 --- a/boxes/devbox/distrobox.ini +++ b/boxes/devbox/distrobox.ini @@ -1,13 +1,16 @@ [devbox] -image=devbox:latest +image=git.alecodes.page/alecodes/devbox:latest replace=true pull=false init=true -unshare_all=true root=false start_now=true -additional_packages="git neovim" - home="${HOME}/chroots/devbox" +volume="${HOME}/.ssh:${HOME}/chroots/devbox/.ssh" + +additional_packages="" +additional_flags="--hostname devbox" + +init_hooks=if [ -e /usr/local/bin/fetch_dots ]; then sudo -u aleidk sh -c "/usr/local/bin/fetch_dots" && rm /usr/local/bin/fetch_dots; fi diff --git a/boxes/devbox/scripts/fetch_dots b/boxes/devbox/scripts/fetch_dots new file mode 100644 index 0000000..c802d5d --- /dev/null +++ b/boxes/devbox/scripts/fetch_dots @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +set -e pipefail + +base_dir="$HOME/Repos/Private/" + +mkdir -p "$base_dir" + +cd "$base_dir" || exit + +if [ -d dots ]; then + echo "Dots already exists, updating..." + cd dots || exit + git pull --rebase --autostash + +else + git clone ssh://git@git.alecodes.page:24062/alecodes/dots.git + + cd dots || exit + + git checkout dotter-migration +fi + +echo "Fixing permissions..." +chown -R 1000:1000 "$base_dir" + +echo "Deploying dots..." +dotter deploy diff --git a/boxes/devbox/scripts/setup_go b/boxes/devbox/scripts/setup_go new file mode 100644 index 0000000..c3ee02e --- /dev/null +++ b/boxes/devbox/scripts/setup_go @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -e pipefail + +sudo xbps-install -Sy go + +go install mvdan.cc/gofumpt@latest +go install -v github.com/incu6us/goimports-reviser/v3@latest +go install github.com/segmentio/golines@latest +go install golang.org/x/tools/gopls@latest