Skip to content

Commit

Permalink
Make it run in docker (#3)
Browse files Browse the repository at this point in the history
* Setup Dockerfile for repeatable dev-envs

* adds action to push image

* adds openssh-client

* fetch github.com rsa key

* fix

* init submodules first

* use --ssh to pass creds to clone submodules

* update GH actions

* Setup submodules outside

* remove zprezto from modules

* fix: do not run submodules if not necessary

* adds ability to fix nushell path for vim

* registry config

* revert workflow

* call it dev-env

* multiarch builds

* test multiarch setup

* bump vimrc

* use gh actions

* adds build platform arm64/v8

* adds ability to install many at once
  • Loading branch information
flovilmart authored Nov 4, 2024
1 parent a2f2a95 commit 0192869
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 84 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vimrc/temp_dirs
# Ingore the TS parsers as they're compiled against the target
vimrc/plugged
51 changes: 42 additions & 9 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,46 @@
on: push
env:
IMAGE_NAME: flovilmart/dev-env
jobs:
build:
runs-on: macos-11
docker:
name: Docker build
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v2
- name: Install
- uses: actions/checkout@v4
- name: Set up SSH
uses: MrSquaare/ssh-setup-action@2d028b70b5e397cf8314c6eaea229a6c3e34977a # v3.1.0
with:
host: github.com
private-key: ${{ secrets.SSH_GITHUB_PPK }}
private-key-name: github-ppk
- name: Submodules
run: sh ./install.sh submodules
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: 'arm64,arm'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Setup vars
run: |
rm /usr/local/bin/aws
rm /usr/local/bin/aws*
rm /usr/local/bin/go
rm /usr/local/bin/go*
./install.sh all
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "main" ] && VERSION=latest
echo VERSION=$VERSION >> "$GITHUB_ENV"
- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64,linux/arm64/v8
push: true
ssh: default
tags: |
ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@
[submodule "tpm"]
path = tpm
url = https://github.com/tmux-plugins/tpm
[submodule "prezto"]
path = .zprezto
url = https://github.com/flovilmart/prezto
1 change: 0 additions & 1 deletion .zprezto
Submodule .zprezto deleted from 3f2145
56 changes: 0 additions & 56 deletions .zpreztorc

This file was deleted.

16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM alpine:edge

RUN apk add tmux git neovim nushell starship curl bash openssh-client

RUN mkdir -p ~/.ssh && ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
RUN ln -sf /usr/bin/nvim /usr/bin/vi

WORKDIR /root/src/flovilmart/dotfiles

COPY . .

RUN ./install.sh dotfiles nushell fix_nu_path tmux_plugins starship
# Adds SSH keys to make sure we can clone submodules
RUN --mount=type=ssh ./install.sh vim

CMD nu

Check warning on line 16 in Dockerfile

View workflow job for this annotation

GitHub Actions / Docker build

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
49 changes: 35 additions & 14 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

set -ex
all() {
brew
Expand All @@ -7,7 +9,6 @@ all() {
dotfiles
vim
tmux_plugins
prezto
}

dotfiles() {
Expand All @@ -20,10 +21,27 @@ dotfiles() {
ln -sfn $(pwd)/kitty.conf ${HOME}/.config/kitty
}

fix_nu_path() {
NU_INSTALL_PATH=$(which nu)
if [ -z "${NU_INSTALL_PATH}" ]; then
echo "Nu not found in path. Please install Nu and try again"
exit 1
fi
if [ "${NU_INSTALL_PATH}" == "/opt/homebrew/bin/nu" ]; then
echo "nothing to do..."
else
sed -i "s#/opt/homebrew/bin/nu#${NU_INSTALL_PATH}#" ./.tmux.conf
sed -i "s#/opt/homebrew/bin/nu#${NU_INSTALL_PATH}#" ./vimrc/plugin/after/styling.lua
fi
}


submodules() {
git submodule update --init --recursive
if [ -d .git ]; then
git submodule update --init --recursive
else
echo "Not a git repo... skipping submodules"
fi
}

brew() {
Expand Down Expand Up @@ -53,27 +71,20 @@ ruby() {
}

node() {
brew_bundle_lang
curl https://get.volta.sh | bash
~/.volta/bin/volta install node
~/.volta/bin/npm install -g typescript eslint prettier;
}

vim() {
submodules
cd $(pwd)/vimrc && ./install.sh all
cd $(pwd)/vimrc && sh ./install.sh all
}

tmux_plugins() {
submodules
mkdir -p ${HOME}/.tmux/plugins
ln -sfn $(pwd)/tpm ${HOME}/.tmux/plugins
}

prezto() {
ln -sfn $(pwd)/.zprezto ${HOME}
}

jira() {
ln -sfn $(pwd)/.jira.d ${HOME}
}
Expand All @@ -82,21 +93,31 @@ nushell() {
NU_CONFIG_DIR=$(nu -c '$nu.default-config-dir')
NU_CONFIG=${NU_CONFIG_DIR}/config.nu
NU_ENV=${NU_CONFIG_DIR}/env.nu
mkdir -p ${NU_CONFIG_DIR}
mkdir -p ${HOME}/.config
touch ${HOME}/.config/nu.env.toml
ln -sfn $(pwd)/nushell/env.nu "${NU_ENV}"
ln -sfn $(pwd)/nushell/config.nu "${NU_CONFIG}"
ln -sfn $(pwd)/nushell/scripts "${NU_CONFIG_DIR}/scripts"
}

starship() {
ln -sfn $(pwd)/starship.toml ${HOME}/.config/starship.toml
}

alanuship() {
brew install alacritty nushell starship
which brew && brew install alacritty nushell starship
mkdir -p ${HOME}/.config
mkdir -p ${HOME}/.config/alacritty
ln -sfn $(pwd)/starship.toml ${HOME}/.config/starship.toml
ln -sfn $(pwd)/alacritty.yml ${HOME}/.config/alacritty/

starship
# Copy the nushell config
nushell
}

# Run the command passed in
$1
while (("$#")) ; do
echo "Running $1"
$1
shift
done

0 comments on commit 0192869

Please sign in to comment.