DEV Community

Theodor Heiselberg
Theodor Heiselberg

Posted on • Edited on

Run lunarvim in a devcontainer

Let's play with lunarvim

This is both fun and easy. Unfortunately the dockerfiles found in luarvim's own repos was not working for me. So here is a version which will run on apple silicon.

If you wan't the icons to be show all pretty in lvim then remember to have nerd-fonts installed on your host machine. The add this setting to your vs-code :

"terminal.integrated.fontFamily": "FiraCode Nerd Font",

{
    "name": "lunarvim-devcontainer",
    "dockerFile": "Dockerfile.lunarvim"
}
Enter fullscreen mode Exit fullscreen mode
# Use a stable version of Alpine as the base image
FROM alpine:3.18

# Set up the working directory
WORKDIR /tmp

# Set environment variables
ENV HOME_DIR="/home/lunaruser"
ENV LV_BRANCH="release-1.4/neovim-0.9"
ENV PATH="$PATH:$HOME_DIR/.local/bin"

# Install dependencies
RUN apk update && \
apk add --no-cache \
yarn \
git \
python3 \
cargo \
neovim \
ripgrep \
alpine-sdk \
bash \
curl


# Add a non-root user and group
RUN addgroup -S lunaruser && \
    adduser -S lunaruser -G lunaruser --shell /bin/sh

# Switch to the non-root user
USER lunaruser

# Run LunarVim installation as the non-root user
RUN curl -s https://raw.githubusercontent.com/lunarvim/lunarvim/$LV_BRANCH/utils/installer/install.sh | \
    bash -s -- --no-install-dependencies

# Set default command to open LunarVim - when running directly in a docker container
# CMD ["/home/lunaruser/.local/bin/lvim"]
Enter fullscreen mode Exit fullscreen mode

>> lvim [enter]

Image description

Bonus

You could just run the container interactively:

>> cd /your-path/.devcontainer/

>> docker build -t my-lunarvim-image -f Dockerfile.lunarvim . 

>> docker run -it --rm -v .:/home/lunaruser/project -w /home/lunaruser/project my-lunarvim-image /bin/bash
Enter fullscreen mode Exit fullscreen mode

Top comments (0)