Skip to content

Commit

Permalink
Integrate Neovim into development workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrus21337 committed Aug 14, 2024
1 parent e07ff9d commit 172e024
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 31 deletions.
57 changes: 51 additions & 6 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,56 @@
FROM mcr.microsoft.com/devcontainers/javascript-node:22 AS base
ENV DEBIAN_FRONTEND=noninteractive
FROM node:22-bookworm AS system
USER root
ENV HOME="/home/node"
ENV DEBIAN_FRONTEND="noninteractive"
WORKDIR /workspace

RUN ["apt", "update"]
RUN ["apt", "install", "-y", "curl", "unzip"]
RUN ["apt-get", "update"]
RUN ["apt-get", "dist-upgrade", "-y"]
RUN ["apt-get", "install", "-y", "ripgrep", "sudo", "unzip", "zsh"]

FROM base AS bun
FROM system AS user
USER root

RUN usermod -s /usr/bin/zsh node \
&& echo "%sudo ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers;

FROM user AS cargo
USER node

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y \
&& . $HOME/.cargo/env \
&& rustup default stable;

FROM user AS stylua
USER root
WORKDIR /usr/bin

RUN curl -L https://github.com/JohnnyMorganz/StyLua/releases/download/v0.20.0/stylua-linux-x86_64.zip -o stylua.zip \
&& unzip stylua.zip;

# TODO: See if you can steal the Neovim executable from an existing Neovim image
# running Debian Bookworm to improve performance by avoiding archive extraction
FROM user AS neovim
USER root
WORKDIR /neovim

RUN curl -L https://github.com/neovim/neovim/releases/download/v0.10.1/nvim-linux64.tar.gz -o neovim.zip \
&& tar -xzf neovim.zip --strip-components=1 \
&& rm neovim.zip;

FROM user AS bun
USER node
ENV BUN_INSTALL="$HOME/.bun"

RUN curl -fsSL https://bun.sh/install | bash;

FROM user AS final
USER root

COPY --from=cargo $HOME/.cargo/ $HOME/.cargo/
COPY --from=stylua /usr/bin/stylua /usr/bin/stylua
COPY --from=neovim /neovim/ /usr/
COPY --from=bun /home/node/.bun/ /home/node/.bun/

RUN curl -fsSL https://bun.sh/install | bash
RUN ["apt-get", "clean"]
RUN ["apt-get", "autoremove", "-y"]
27 changes: 2 additions & 25 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,11 @@
{
"name": "Astro App Boilerplate",
"dockerFile": "Dockerfile",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
"workspaceFolder": "/workspace",
"remoteUser": "node",
"postCreateUser": "node",
"postCreateCommand": "bun install && (bun pm trust --all || true) && bun run prepare",
"customizations": {
"vscode": {
"extensions": [
"Gruntfuggly.todo-tree",
"YoavBls.pretty-ts-errors",
"astro-build.astro-vscode",
"better-ts-errors.better-ts-errors",
"bradlc.vscode-tailwindcss",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"henriiik.vscode-sort",
"mikestead.dotenv",
"neotan.vscode-auto-restart-typescript-eslint-servers",
"streetsidesoftware.code-spell-checker",
"wayou.vscode-todo-highlight",
"wix.vscode-import-cost"
],
"settings": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
},
"postCreateCommand": ".devcontainer/setup.sh",
"features": {
"ghcr.io/devcontainers/features/git": {},
"ghcr.io/devcontainers/features/github-cli": {}
}
}
12 changes: 12 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -e

export BUN_INSTALL="/home/node/.bun"
export PATH="$PATH:$BUN_INSTALL/bin"

bun install
bun pm trust --all || true

if [ ! -d .husky/_ ]; then
bun run prepare
fi

0 comments on commit 172e024

Please sign in to comment.