Skip to content

Commit

Permalink
feat!: Update Dockerfile to use new base-image
Browse files Browse the repository at this point in the history
  • Loading branch information
Allaman committed Jan 3, 2024
1 parent c1674ec commit 028ad91
Showing 1 changed file with 11 additions and 73 deletions.
84 changes: 11 additions & 73 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,80 +1,18 @@
ARG ARCH
FROM ${ARCH}debian:stable-slim
ARG BASE_IMAGE
FROM ${ARCH}allaman/nvim-full:latest

Check failure on line 3 in Dockerfile

View workflow job for this annotation

GitHub Actions / checks

DL3007 warning: Using latest is prone to errors if the image will ever update. Pin the version explicitly to a release tag

# TODO: optimize image size
# TODO: maybe build a dedicated base image with all dependencies included
# TODO: allow a specific version of Neovim to be installed
RUN mkdir -p .config/nvim \

Check failure on line 5 in Dockerfile

View workflow job for this annotation

GitHub Actions / checks

SC2086 info: Double quote to prevent globbing and word splitting.
&& mkdir -p .local/share/nvim/mason/packages \
## Create empty user config file
&& echo "return {}" > $HOME/.nvim_config.lua \
## Add mason tools dir to path
&& echo "PATH=$PATH:$HOME/.local/share/nvim/mason/bin" >> $HOME/.bashrc

ARG TARGETOS
ARG TARGETARCH

ENV LANGUAGE=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8

# Update system and install core packages/dependencies
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
apt-transport-https \
autoconf \
automake \
ca-certificates \
cmake \
coreutils \
curl \
doxygen \
fd-find \
fzf \
g++ \
gettext \
git \
gnupg \
libtool \
libtool-bin \
locales \
make \
npm \
pkg-config \
python3-pip \
ripgrep \
sudo \
tar \
unzip \
wget \
zip \
&& rm -rf /var/lib/apt/lists/* \
&& ln -s "$(which fdfind)" /usr/bin/fd \
&& ln -s "$(which python3)" /usr/bin/python \
&& sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && dpkg-reconfigure --frontend=noninteractive locales

# Download and build Neovim from latest source
RUN git clone https://github.com/neovim/neovim /tmp/neovim
WORKDIR /tmp/neovim
RUN make CMAKE_BUILD_TYPE=RelWithDebInfo && make install && rm -fr /tmp/neovim

RUN curl -sLo go.tar.gz "https://go.dev/dl/go1.20.linux-${TARGETARCH}.tar.gz" \
&& tar -C /usr/local/bin -xzf go.tar.gz \
&& rm go.tar.gz

# Add user 'nvim' and allow passwordless sudo
RUN adduser --disabled-password --gecos '' nvim \
&& adduser nvim sudo \
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

USER nvim
WORKDIR /home/nvim

ENV PATH=$PATH:/usr/local/bin/go/bin/:/home/nvim/.local/bin:/home/nvim/.local/bin/bin:/home/nvim/go/bin:/home/nvim/.cargo/bin
ENV GOPATH=/home/nvim/.local/share/go
ENV PATH=$PATH:$GOPATH/bin

# Copy Neovim config into the image
RUN mkdir -p .config/nvim && mkdir -p .local/share/nvim/mason/packages
COPY --chown=nvim:nvim . .config/nvim

Check failure on line 12 in Dockerfile

View workflow job for this annotation

GitHub Actions / checks

DL3045 warning: `COPY` to a relative destination without `WORKDIR` set.
# Install plugins and tools with Mason and go.nvim
# TODO: Use of sleep is not cool but commands are not blocking (! is not working either)
RUN nvim --headless "+Lazy! sync" +"sleep 15" +qa \
&& nvim --headless "+MasonToolsInstall" +"sleep 20" +qa \
&& nvim --headless "+set filetype=go" +"GoInstallBinaries" +"sleep 120" +qa
# HACK: Use of sleep is not cool but commands are not blocking (! is not working either)
RUN nvim --headless "+Lazy! sync" +qa
# && nvim --headless "+Lazy! load mason.nvim +MasonInstall +sleep 45" +qa

ENTRYPOINT ["/bin/bash", "-c", "nvim"]

0 comments on commit 028ad91

Please sign in to comment.