diff --git a/Containerfile b/Containerfile index ffdedcc..39c54f3 100644 --- a/Containerfile +++ b/Containerfile @@ -1,7 +1,11 @@ # Start from the Fedora Toolbox image FROM quay.io/toolbx-images/fedora-toolbox:38 -ENV HOMEBREW_NO_ENV_HINTS=true +ENV HOMEBREW_NO_ENV_HINTS=true +# Add user jim +RUN useradd -m -s /bin/bash jim + +# Import Microsoft GPG key and add Visual Studio Code repository RUN rpm --import https://packages.microsoft.com/keys/microsoft.asc RUN sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo' @@ -13,26 +17,28 @@ COPY packages.dnf /tmp/packages.dnf # Install packages from the list RUN dnf -y install $(cat /tmp/packages.dnf) -# RUN dnf groupinstall "Development Tools" -# Install Homebrew -# RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -RUN /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +# # Sym-link to host binaries +# RUN ln -fs /bin/sh /usr/bin/sh && \ +# ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/docker && \ +# ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/flatpak && \ +# ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/podman && \ +# ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/rpm-ostree && \ +# ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/transactional-update -# Add Homebrew to PATH -ENV PATH="/home/linuxbrew/.linuxbrew/bin:${PATH}" +# Copy the install script and packages file +COPY install_homebrew.sh /home/jim/ +COPY packages.brew /home/jim/tmp/ -# Copy the list of Homebrew applications into the container -# COPY packages.brew /tmp/packages.brew +# Change ownership to jim and make the script executable +RUN chown -R jim:jim /home/jim/install_homebrew.sh /home/jim/tmp/ && \ + chmod u+x /home/jim/install_homebrew.sh -# Install Homebrew applications from the list -# RUN while read app; do brew install "$app"; done < /tmp/packages.brew -# RUN brew install $(cat /tmp/packages.brew) +# Switch to user jim +USER jim + +# Add Homebrew to PATH +ENV PATH="/home/linuxbrew/.linuxbrew/bin:${PATH}" -# sym-link to host binaries -RUN ln -fs /bin/sh /usr/bin/sh && \ - ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/docker && \ - ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/flatpak && \ - ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/podman && \ - ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/rpm-ostree && \ - ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/transactional-update +# Set the script to run on login +RUN echo '[[ -f $HOME/install_homebrew.sh ]] && /bin/bash $HOME/install_homebrew.sh' >> /home/jim/.bashrc diff --git a/brew.install.sh b/brew.install.sh deleted file mode 100644 index 6af7aad..0000000 --- a/brew.install.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -# Loop through each line in /tmp/packages.brew and install the app using brew -while read app; do - brew install "$app" -done < /tmp/packages.brew \ No newline at end of file diff --git a/install_homebrew.sh b/install_homebrew.sh new file mode 100644 index 0000000..cc07278 --- /dev/null +++ b/install_homebrew.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Check if Homebrew is installed +if [ ! -d "/home/linuxbrew/.linuxbrew" ]; then + # Install Homebrew + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + + # Install Homebrew applications from the list + brew install $(cat /home/jim/tmp/packages.brew) +fi + +# Remove the script to prevent it from running again +rm -f $HOME/install_homebrew.sh