From f9c128e879ea4105627899279fa7d266dbe21dd2 Mon Sep 17 00:00:00 2001 From: Cian Hughes Date: Mon, 13 Jul 2026 11:35:09 +0100 Subject: [PATCH] Configure container build workflow via GHCR --- .dockerignore | 7 ++++ .github/workflows/build_container.yaml | 56 ++++++++++++++++++++++++++ .github/workflows/trigger_rebuild.yaml | 23 ----------- Dockerfile | 46 +++++++++++++++++++++ init.lua | 3 +- 5 files changed, 111 insertions(+), 24 deletions(-) create mode 100644 .dockerignore create mode 100644 .github/workflows/build_container.yaml delete mode 100644 .github/workflows/trigger_rebuild.yaml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9604af3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.git +.devenv +.direnv +devenv.lock +devenv.nix +devenv.yaml +.envrc diff --git a/.github/workflows/build_container.yaml b/.github/workflows/build_container.yaml new file mode 100644 index 0000000..0b6ffb4 --- /dev/null +++ b/.github/workflows/build_container.yaml @@ -0,0 +1,56 @@ +name: Build and Push Neovim Container + +on: + push: + branches: + - main + paths-ignore: + - 'README.md' + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest + type=sha,format=short + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/trigger_rebuild.yaml b/.github/workflows/trigger_rebuild.yaml deleted file mode 100644 index dc84d0b..0000000 --- a/.github/workflows/trigger_rebuild.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: Trigger Container Rebuild - -on: - push: - branches: - - main - paths-ignore: - - "README.md" - -jobs: - trigger: - runs-on: ubuntu-latest - steps: - - name: Trigger rebuild - env: - GH_TOKEN: ${{ secrets.PUBLIC_ACTION_TRIGGER_TOKEN }} - run: | - gh api \ - --method POST \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - /repos/Cian-H/my_nvim/dispatches \ - -f "event_type=rebuild-container" -F "client_payload[unit]=false" -F "client_payload[integration]=true" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fe032f4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,46 @@ +FROM ubuntu:24.04 + +# Prevent interactive prompts during package installation +ENV DEBIAN_FRONTEND=noninteractive + +# Install essential dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + git \ + curl \ + ca-certificates \ + build-essential \ + unzip \ + tar \ + ripgrep \ + fd-find \ + python3 \ + python3-pip \ + python3-venv \ + nodejs \ + npm \ + && rm -rf /var/lib/apt/lists/* + +# Install Neovim (stable/latest precompiled binary) +RUN curl -LO https://github.com/neovim/neovim/releases/download/stable/nvim-linux-x86_64.tar.gz \ + && tar -C /opt -xzf nvim-linux-x86_64.tar.gz \ + && rm nvim-linux-x86_64.tar.gz \ + && ln -s /opt/nvim-linux-x86_64/bin/nvim /usr/local/bin/nvim + +# Create a non-root user and setup home directory +RUN useradd -m -s /bin/bash nvimuser +USER nvimuser +ENV HOME=/home/nvimuser +WORKDIR /workspace + +# Copy the Neovim configuration files +RUN mkdir -p $HOME/.config/nvim +COPY --chown=nvimuser:nvimuser . $HOME/.config/nvim + +# Pre-install plugins using Lazy.nvim sync +RUN nvim --headless "+Lazy! sync" +qa + +# Run neovim headlessly for a short period to allow tree-sitter-manager and mason to install tools +RUN nvim --headless -c "sleep 15" -c "qa" + +# Set up entrypoint +ENTRYPOINT ["nvim"] diff --git a/init.lua b/init.lua index 1c561a8..a788f90 100644 --- a/init.lua +++ b/init.lua @@ -31,9 +31,10 @@ if not vim.loop.fs_stat(hotpotpath) then }) end ----@diagnostic disable-next-line: undefined-field +---@diagnostic disable: undefined-field vim.opt.rtp:prepend(hotpotpath) vim.opt.rtp:prepend(lazypath) +---@diagnostic enable: undefined-field require("hotpot")