jorgebucaran / fisher

A plugin manager for Fish
https://git.io/fisher
MIT License
7.53k stars 257 forks source link

Fisher install in OCI container #750

Closed Andreas02-dev closed 1 year ago

Andreas02-dev commented 1 year ago

I'd like to use Fisher to install NVM in a container, however it fails silently.

When executing the following block in my Dockerfile:

# Install `Fish shell`
RUN apt-get update --quiet && \
    apt-get install --quiet --yes fish
RUN chsh -s /usr/bin/fish
SHELL ["fish", "--command"]
ENV SHELL /usr/bin/fish
ENV LANG=C.UTF-8 LANGUAGE=C.UTF-8 LC_ALL=C.UTF-8
RUN curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher
RUN fisher install jorgebucaran/nvm.fish

Fish will get installed and the shell is changed correctly.

Unfortunately, RUN curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher fails silently (the build will pass this step, however fisher will not be installed.)

This issue only affects running in the Dockerfile itself, when the container is built, running curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher works correctly.

The full Dockerfile until & including the first failing step is below, where it will complain about nvm not being installed:

# Dotnet DevContainer base image
FROM mcr.microsoft.com/devcontainers/dotnet:7.0-jammy

# Install `Fish shell` and `Fisher`
RUN apt-get update --quiet && \
    apt-get install --quiet --yes fish
RUN chsh -s /usr/bin/fish
SHELL ["fish", "--command"]
ENV SHELL /usr/bin/fish
ENV LANG=C.UTF-8 LANGUAGE=C.UTF-8 LC_ALL=C.UTF-8
RUN curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher
RUN fisher install jorgebucaran/nvm.fish

# Install `NPM`
RUN nvm install lts

Thanks for your help and with kind regards,

Andreas

jorgebucaran commented 1 year ago

Could you try and see if this works?

RUN curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher jorgebucaran/nvm.fish
Andreas02-dev commented 1 year ago

Could you try and see if this works?

RUN curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher jorgebucaran/nvm.fish

Changing it to the following will build the container correctly:

RUN chsh -s /usr/bin/fish
ENV SHELL=/usr/bin/fish LANG=C.UTF-8 LANGUAGE=C.UTF-8 LC_ALL=C.UTF-8
RUN fish --command "curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher jorgebucaran/nvm.fish"

RUN fish --command "fisher -v"

# Install `NPM` and `TailwindCSS`
RUN fish --command "nvm install lts && npm install -g tailwindcss"

However after creation, fisher, nvm and npm will not be available in the devcontainer.

I've managed to circumvent this by mounting the following config.fish:

  # Install the latest NPM and Yarn:
  set --universal nvm_default_version lts
  set --universal nvm_default_packages yarn

And by running this fish script in the devcontainer.json's postCreateCommand:

curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher
fisher install jorgebucaran/nvm.fish
nvm install lts
npm install -g tailwindcss

While of course the optimal situation would be to be able to install all dependencies in the Dockerfile, I am content with this solution, you can close the issue if you want.

Thanks again for your help!