Allaman / nvim

Straightforward and pure Lua based Neovim configuration for my work as DevOps/Cloud Engineer with batteries included for Python, Golang, and, of course, YAML
MIT License
627 stars 69 forks source link

Error when building the docker file #5

Closed scorbin closed 2 years ago

scorbin commented 2 years ago

Step 14/24 : RUN curl -sLo go.tar.gz "https://go.dev/dl/go1.18.linux-${TARGETARCH}.tar.gz" && tar -C /usr/local/bin -xzf go.tar.gz && rm go.tar.gz ---> Running in e05f16447c3b

gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now The command '/bin/sh -c curl -sLo go.tar.gz "https://go.dev/dl/go1.18.linux-${TARGETARCH}.tar.gz" && tar -C /usr/local/bin -xzf go.tar.gz && rm go.tar.gz' returned a non-zero code: 2

Allaman commented 2 years ago

Can you build this minimal Dockerfile?

ARG ARCH
FROM ${ARCH}debian:stable-slim

ARG TARGETOS
ARG TARGETARCH

RUN apt-get update \
&& apt-get install --no-install-recommends -y \
ca-certificates \
curl \
tar

RUN echo TARGETARCH is: ${TARGETARCH}
RUN ls -l /usr/local/bin
RUN ls -l .
RUN curl -Lo go.tar.gz "https://go.dev/dl/go1.18.linux-${TARGETARCH}.tar.gz"
RUN ls -l go.tar.gz
RUN tar -C /usr/local/bin -xzf go.tar.gz
RUN rm go.tar.gz

with --progress plain if your backend is buildx

bulfonjf commented 2 years ago

Hi! Can you please give an example of what I have to put for those arguments? (ARCH, TARGETARCH and TARGETOS). My neofetch says:

I tried to build the Dockerfile with podman, doing: sudo podman build -t nvim .

Allaman commented 2 years ago

Hello, Ahhh

I tried to build the Dockerfile with podman, doing:

Now we're getting closer. Unfortunately, I don't think that Podman is able to produce an image out of this Dockerfile. But I also have to admit that I've never worked with Podman. That being said those Arguments are "builtin" variables (see this post) of Dockers buildx

Pls try the following Dockerfile. I replaced all occurences of TARGETARCH with "amd64" and of TARGETOS with "linux"

FROM debian:stable-slim

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 upgrade -y \
&& apt-get install --no-install-recommends -y \
  apt-transport-https \
  autoconf \
  automake \
  ca-certificates \
  cmake \
  coreutils \
  curl \
  locales \
  doxygen \
  g++ \
  gettext \
  git \
  gnupg \
  libtool \
  libtool-bin \
  make \
  pkg-config \
  sudo \
  tar \
  unzip \
  wget \
  zip \
&& rm -rf /var/lib/apt/lists/*

# 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 -r /tmp/neovim

# Set correct locale
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && dpkg-reconfigure --frontend=noninteractive locales

# Install (global) dependencies (tools, formatters and LSPs)
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
fzf \
fd-find \
ripgrep \
python3-pip \
npm \
&& npm i -g \
prettier \
eslint \
bash-language-server \
dockerfile-language-server-nodejs \
yaml-language-server \
typescript \
typescript-language-server \
vscode-langservers-extracted \
&& rm -rf /var/lib/apt/lists/* \
&& ln -s "$(which fdfind)" /usr/bin/fd

RUN curl -sLo go.tar.gz "https://go.dev/dl/go1.18.linux-amd64.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

# Install (user only) dependencies (formatters and LSPs)
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
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN pip3 install --no-cache-dir --user pyright black pynvim yamllint \
&& go install golang.org/x/tools/cmd/goimports@latest \
&& go install mvdan.cc/gofumpt@latest \
&& go install golang.org/x/tools/gopls@latest \
&& curl -sLo tf-ls.zip "https://releases.hashicorp.com/terraform-ls/0.27.0/terraform-ls_0.27.0_linux_amd64.zip" \
&& unzip -d ~/.local/bin tf-ls.zip \
&& rm tf-ls.zip \
&& curl -sLo tf.zip "https://releases.hashicorp.com/terraform/1.2.1/terraform_1.2.1_linux_amd64.zip" \
&& unzip -d ~/.local/bin tf.zip \
# workaround for naming amd64 as x64
&& curl -sLo lua-lsp.tar.gz "https://github.com/sumneko/lua-language-server/releases/download/3.2.4/lua-language-server-3.2.4-linux-x64.tar.gz" \
#FIX: extracted very much stuff besides the executable
&& tar -C ~/.local/bin/ -xzf lua-lsp.tar.gz \
&& rm lua-lsp.tar.gz \
&& rm tf.zip \
&& curl -sLo stylua.zip "https://github.com/JohnnyMorganz/StyLua/releases/download/v0.13.1/stylua-linux.zip"; unzip -d ~/.local/bin stylua.zip; rm stylua.zip; fi

# Copy Neovim config into the image
RUN mkdir -p .config/nvim
COPY --chown=nvim:nvim . .config/nvim
# Bootstrap Packer
RUN git clone --depth 1 https://github.com/wbthomason/packer.nvim \
 ~/.local/share/nvim/site/pack/packer/start/packer.nvim \
# Install plugins via Packer
&& nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync' \
# we need to wait for parsers to be installed as this is apparently not blocking
&& nvim --headless -c 'TSInstall' +"sleep 15" +qa || true

ENTRYPOINT ["/bin/bash", "-c", "nvim"]
Allaman commented 2 years ago

closed due to inactivity