Troubleshooting Installing 🍺 Homebrew in a Code Studio Image

adamnieto Neuron 2020, Neuron, Registered, Neuron 2021, Neuron 2022, Neuron 2023 Posts: 87 Neuron

Hi Community,

I was working to create a custom code studio that leverages Homebrew to enable experimentation for web app development and allow the end user of the code studio to install OS level packages in the container.

Warning: Since this would veer off from the OS packages on the DSS server end users should not leverage this code studio template for recipe development.

Below is what I added to a "Append to Dockerfile" block after I added the Visual Studio Code block.

# Install Basic Packages
RUN yum install -y wget
RUN yum install -y curl
RUN yum install -y screen
RUN yum install -y yum-utils
RUN yum upgrade git -y
RUN yum upgrade curl -y

# Install GitHub CLI
RUN type -p yum-config-manager >/dev/null || sudo yum install yum-utils
RUN yum-config-manager --add-repo
RUN yum install -y gh

USER dataiku
RUN mkdir /home/dataiku/setup_scripts
RUN touch /home/dataiku/.bashrc

# Install Oh My Bash
RUN bash -c "$(wget -O -)"

# Install NVM
# Installing Node Version Manager to allow end users to install their own node versions
RUN wget -qO- > /home/dataiku/setup_scripts/
RUN chmod +x /home/dataiku/setup_scripts/
RUN /home/dataiku/setup_scripts/
#RUN source /home/dataiku/.bashrc

# Installing Homebrew
USER root
RUN git clone /home/linuxbrew/.linuxbrew/Homebrew
RUN mkdir /home/linuxbrew/.linuxbrew/bin
RUN ln -s /home/linuxbrew/.linuxbrew/Homebrew/bin/brew /home/linuxbrew/.linuxbrew/bin
RUN chown -R dataiku /home/linuxbrew/
RUN echo "eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" >> /home/dataiku/.bashrc

I also added Oh My Bash, NVM, GitHub CLI as well to better enhance the shell experience.

Question: Right now I install homebrew in the standard location /home/linuxbrew/. However, when the code studio is stopped this gets deleted and we lose all of the packages that were once installed. Do you know of a way we can keep the installed packages when the code studio is stopped?

Note the homebrew directory can become big and I researched online that even using symbolic links to solve this problem can cause some homebrew packages when installed to fail.

Operating system used: RHEL 7

Setup Info
      Help me…