From 8e5fd3a52526af7ec9745585a5a1ef6d8612cf3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= Date: Sun, 7 Aug 2022 15:25:48 +0000 Subject: [PATCH 1/9] chore(dockerfile): update archlinux packages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://hub.docker.com/_/archlinux/?tab=description says: "Arch Linux is a rolling release distribution, so a full update is recommended when installing new packages. In other words, we suggest to either execute RUN pacman -Syu immediately after your FROM statement or as soon as you docker run into a container." Without this there are some errors about LIBC_2.36 when installing new packages brings in packages depending on it, but the installed libc is still 2.35. Signed-off-by: Edwin Török --- tools/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Dockerfile b/tools/Dockerfile index cb311e5cf..81d4fd0cb 100644 --- a/tools/Dockerfile +++ b/tools/Dockerfile @@ -16,7 +16,7 @@ ENV \ PATH="/home/doom/.local/bin:${PATH}" # Update repositories -RUN pacman -Syy +RUN pacman -Syu --noconfirm # Install neovim RUN pacman -Sy neovim --noconfirm From dc25a1ca5cddae74155d0479c9ac5bc7ff628772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= Date: Sun, 22 May 2022 21:05:09 +0100 Subject: [PATCH 2/9] chore(dockerfile): make contribute/start_docker work on Fedora MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The docker-podman wrapper created volume mounts are owned by the root user inside the container, and the doom user wouldn't have write access. Need to specify --user-ns=keep-id flag to map $UID from the host to $UID from the container without using subuids: that way user inside container can modify. SELinux is on by default on Fedora36, thus volume mounts need to specify the 'Z' flag to relabel the directory being mounted. podman needs '--userns=keep-id' for permissions of mounted volumes to work inside the container. However docker doesn't recognize that flag (and doesn't need it, since it is running as root). Detect which of `docker` or `podman` is installed, and if it is podman add the extra flag. We need to check for podman first, because 'docker' might just be a wrapper that calls podman. Signed-off-by: Edwin Török --- tools/start_docker.sh | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/tools/start_docker.sh b/tools/start_docker.sh index 4e77d4d6c..22a849094 100755 --- a/tools/start_docker.sh +++ b/tools/start_docker.sh @@ -1,10 +1,16 @@ #!/usr/bin/env bash - -if ! docker info > /dev/null 2>&1; then +DOCKER=$(command -v podman docker | head -n 1) +if ! "${DOCKER}" info > /dev/null 2>&1; then echo "This script uses docker, and it isn't running - please start docker and try again!" exit 1 fi +if [ $(basename "${DOCKER}") = "podman" ]; then + DOCKER_RUN_FLAGS="--userns=keep-id" +else + DOCKER_RUN_FLAGS= +fi + ############################################################ # Help # ############################################################ @@ -40,6 +46,7 @@ while getopts "b:h" option; do exit;; esac done +shift $((OPTIND-1)) cd "$SCRIPT_DIR" || exit @@ -87,30 +94,30 @@ echo "" echo "2. Setting up docker environment" # Ensure docker image exists -if [[ ! "$(docker images -q doom-nvim-contrib)" ]]; then +if [[ ! "$("${DOCKER}" images -q doom-nvim-contrib)" ]]; then echo " - Docker image does not exist. Building docker image..." - docker build -t doom-nvim-contrib . + "${DOCKER}" build -t doom-nvim-contrib . fi -if [ "$(docker ps -aq -f status=exited -f name=doom-nvim-contrib-container)" ]; then +if [ "$("${DOCKER}" ps -aq -f status=exited -f name=doom-nvim-contrib-container)" ]; then echo " - Cleaning up old container..." # cleanup - docker rm doom-nvim-contrib-container >> /dev/null + "${DOCKER}" rm doom-nvim-contrib-container >> /dev/null fi # Create docker container if haven't already echo " - Success! Running docker container doom-nvim-contrib-container..." mkdir -p "${SCRIPT_DIR}/local-share-nvim" "${SCRIPT_DIR}/workspace" echo "" -docker run \ +${DOCKER} run \ + ${DOCKER_RUN_FLAGS} \ -it \ -e UID="1000" \ -e GID="1000" \ - -v "$SCRIPT_DIR"/doom-nvim-contrib:/home/doom/.config/nvim \ - -v "$SCRIPT_DIR"/local-share-nvim:/home/doom/.local/share/nvim \ - -v "$SCRIPT_DIR"/workspace:/home/doom/workspace \ + -v "$SCRIPT_DIR"/doom-nvim-contrib:/home/doom/.config/nvim:Z \ + -v "$SCRIPT_DIR"/local-share-nvim:/home/doom/.local/share/nvim:Z \ + -v "$SCRIPT_DIR"/workspace:/home/doom/workspace:Z \ --name doom-nvim-contrib-container \ --user doom \ - doom-nvim-contrib - - + "$@" \ + doom-nvim-contrib \ From 6e1159414c3f4041f4ff82742b048d1ce3677fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= Date: Sun, 13 Nov 2022 17:56:37 +0000 Subject: [PATCH 3/9] chore(dockerfile): store state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Edwin Török --- .gitignore | 1 + tools/start_docker.sh | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f7305f88d..e79ce3435 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ tags # Doom Nvim Contrib files tools/doom-nvim-contrib tools/local-share-nvim +tools/local-state tools/workspace # User modules diff --git a/tools/start_docker.sh b/tools/start_docker.sh index 22a849094..b8395287b 100755 --- a/tools/start_docker.sh +++ b/tools/start_docker.sh @@ -107,7 +107,7 @@ fi # Create docker container if haven't already echo " - Success! Running docker container doom-nvim-contrib-container..." -mkdir -p "${SCRIPT_DIR}/local-share-nvim" "${SCRIPT_DIR}/workspace" +mkdir -p "${SCRIPT_DIR}/local-share-nvim" "${SCRIPT_DIR}/local-state" "${SCRIPT_DIR}/workspace" echo "" ${DOCKER} run \ ${DOCKER_RUN_FLAGS} \ @@ -115,6 +115,7 @@ ${DOCKER} run \ -e UID="1000" \ -e GID="1000" \ -v "$SCRIPT_DIR"/doom-nvim-contrib:/home/doom/.config/nvim:Z \ + -v "$SCRIPT_DIR"/local-state:/home/doom/.local/state:Z \ -v "$SCRIPT_DIR"/local-share-nvim:/home/doom/.local/share/nvim:Z \ -v "$SCRIPT_DIR"/workspace:/home/doom/workspace:Z \ --name doom-nvim-contrib-container \ From 2982c745eb0dfd634a99594355fa7f170bfebb41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= Date: Sat, 31 Dec 2022 13:37:51 +0000 Subject: [PATCH 4/9] chore(dockerfile): add hyperfine for startup time profiling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Edwin Török --- tools/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/Dockerfile b/tools/Dockerfile index 81d4fd0cb..ca52ea4d3 100644 --- a/tools/Dockerfile +++ b/tools/Dockerfile @@ -36,6 +36,9 @@ RUN npm i -g chokidar-cli # Required for OCaml language # RUN pacman -Sy opam diffutils patch ocaml --noconfirm +# For startup time profiling +RUN pacman -Sy hyperfine --noconfirm + # Create the doom user and group RUN groupadd doom RUN useradd -m -g doom doom From 8e4bfb6357f0e7f748ef27bb26fbb1a31fe9b101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= Date: Sun, 7 Aug 2022 22:52:50 +0100 Subject: [PATCH 5/9] chore(dockerfile): add lua-language-server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Edwin Török --- tools/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Dockerfile b/tools/Dockerfile index ca52ea4d3..49e375686 100644 --- a/tools/Dockerfile +++ b/tools/Dockerfile @@ -25,7 +25,7 @@ RUN pacman -Sy neovim --noconfirm RUN pacman -Sy ripgrep nodejs-lts-fermium npm git bash gcc jq --noconfirm # Lua -RUN pacman -Sy luacheck stylua --noconfirm +RUN pacman -Sy luacheck stylua lua-language-server --noconfirm # Required for nvim-lsp-installer RUN pacman -Sy wget unzip make --noconfirm From 46940e6472f79a3d659a9beda281bdc574fe26b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= Date: Sun, 31 Jul 2022 23:14:54 +0100 Subject: [PATCH 6/9] chore(dockerfile): add opam/ocaml/ocaml-lsp-server --- tools/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/Dockerfile b/tools/Dockerfile index 49e375686..93a9a88a1 100644 --- a/tools/Dockerfile +++ b/tools/Dockerfile @@ -39,6 +39,9 @@ RUN npm i -g chokidar-cli # For startup time profiling RUN pacman -Sy hyperfine --noconfirm +# OCaml +RUN pacman -Sy opam diffutils patch ocaml --noconfirm + # Create the doom user and group RUN groupadd doom RUN useradd -m -g doom doom From 321df849d02924377d3ae05092e9ac91b0b379a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= Date: Sun, 7 Aug 2022 19:47:23 +0100 Subject: [PATCH 7/9] chore(init.lua): do not invoke DoomStarted while PackerSync is running MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When running doom for the first time (or after ~/.local/share/nvim/site is cleaned) doom will bootstrap itself by calling packer.sync(). However that happens asynchronously, so do not call DoomStarted in this case: doom is not ready yet. This will allow to safely run the following command to synchronize doom config with packages: ``` nvim --headless --cmd "autocmd User PackerComplete quitall" --cmd "autocmd User DoomStarted PackerSync" ``` Previously such a command wouldn't have been safe on initial run due to the implicit packer.sync: 2 packer syncs running at the same time would show a lot of lua module errors about modules not found, it is best avoided. On subsequent runs it would've been safe but it is useful to have a single command to run that is always safe. This should also make it possible to use a similar command in a CI to wait for the installation of packages and then test that the doom config works. Signed-off-by: Edwin Török --- lua/doom/core/init.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/doom/core/init.lua b/lua/doom/core/init.lua index 34d8b002b..cb46a4615 100644 --- a/lua/doom/core/init.lua +++ b/lua/doom/core/init.lua @@ -71,8 +71,10 @@ modules.try_sync() profiler.stop("framework|doom.core.modules") -- Execute autocommand for user to hook custom config into -vim.api.nvim_exec_autocmds("User", { - pattern = "DoomStarted", -}) +if not modules._needs_sync then + vim.api.nvim_exec_autocmds("User", { + pattern = "DoomStarted", + }) +end -- vim: fdm=marker From 65ea4552d72ba1db3f40ef5ea2386a584d554549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= Date: Sat, 31 Dec 2022 15:21:02 +0000 Subject: [PATCH 8/9] chore(dockerfile): exit script if build fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise you get a prompt to pick a registry to pull the image from (since it failed to build locally). Signed-off-by: Edwin Török --- tools/start_docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/start_docker.sh b/tools/start_docker.sh index b8395287b..23f7e4a9c 100755 --- a/tools/start_docker.sh +++ b/tools/start_docker.sh @@ -96,7 +96,7 @@ echo "2. Setting up docker environment" # Ensure docker image exists if [[ ! "$("${DOCKER}" images -q doom-nvim-contrib)" ]]; then echo " - Docker image does not exist. Building docker image..." - "${DOCKER}" build -t doom-nvim-contrib . + "${DOCKER}" build -t doom-nvim-contrib . || exit fi if [ "$("${DOCKER}" ps -aq -f status=exited -f name=doom-nvim-contrib-container)" ]; then From e275d0a9fe40a640694fee3f186b1db119fdf645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= Date: Sun, 7 Aug 2022 16:55:01 +0100 Subject: [PATCH 9/9] chore(tools): add bootstrap script for Docker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Edwin Török --- tools/docker_bootstrap.sh | 9 +++++++++ tools/docker_clean_bootstrap.sh | 7 +++++++ 2 files changed, 16 insertions(+) create mode 100755 tools/docker_bootstrap.sh create mode 100755 tools/docker_clean_bootstrap.sh diff --git a/tools/docker_bootstrap.sh b/tools/docker_bootstrap.sh new file mode 100755 index 000000000..7f1255d0b --- /dev/null +++ b/tools/docker_bootstrap.sh @@ -0,0 +1,9 @@ +#!/bin/sh +echo "Executing initial bootstrap/sync" +rm -f local-share-nvim/plugin/packer_compiled.lua +rm -f doom-nvim-contrib/plugin/packer_compiled.lua +rm -rf local-share-nvim/ local-state-nvim/ +./start_docker.sh -- --rm --entrypoint='["/usr/bin/nvim","--headless","--cmd","autocmd User PackerComplete quitall","--cmd","autocmd User DoomStarted PackerSync"]' +./start_docker.sh -- --rm --entrypoint='["/usr/bin/nvim","--headless","--cmd","autocmd User PackerComplete quitall","--cmd","autocmd User DoomStarted PackerSync"]' +echo "Testing config" +exec ./start_docker.sh -- --rm --entrypoint='["/usr/bin/nvim","--headless","+qa"]' diff --git a/tools/docker_clean_bootstrap.sh b/tools/docker_clean_bootstrap.sh new file mode 100755 index 000000000..7b12da412 --- /dev/null +++ b/tools/docker_clean_bootstrap.sh @@ -0,0 +1,7 @@ +#!/bin/bash +rm local-share-nvim/ local-state-nvim/ -rf +rm -f doom-nvim-contrib/plugin/packer_compiled.lua +echo +echo "Bootstrapping packages" +echo +exec ./start_docker.sh -- --entrypoint='["/usr/bin/nvim","--headless","--cmd","autocmd User PackerComplete quitall"]'