Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add script to install docker rootless. #10

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ create-teams:
python src/utils/github_topics_to_json_file.py && \
python src/scripts/create_teams.py teams.json

setup-self-hosted-runner-centos:
sudo yum install -y jq && \
chmod +x src/scripts/setup-self-hosted-runner-centos.sh && \
./src/scripts/setup-self-hosted-runner-centos.sh


help:
@echo "Usage: make [target]"
@echo ""
Expand Down
75 changes: 75 additions & 0 deletions src/scripts/self-hosted-runners/install-rootless-docker-centos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash

# Exit on error
set -e

# Check if script is run as root
if [ "$EUID" -eq 0 ]; then
echo "Please run this script as a non-root user."
exit 1
fi

# Install required packages only if they aren't already installed

# Check for shadow-utils
if ! rpm -q shadow-utils &> /dev/null; then
echo "Installing shadow-utils..."
sudo yum install -y shadow-utils
fi

# Check for curl or curl-minimal
if ! rpm -q curl &> /dev/null && ! rpm -q curl-minimal &> /dev/null; then
echo "Installing curl..."
sudo yum install -y curl
fi

# Check for iptables
if ! rpm -q iptables &> /dev/null; then
echo "Installing iptables..."
sudo yum install -y iptables
fi

# Download Docker installation script
echo "Installing Docker in rootless mode..."
curl -fsSL https://get.docker.com/rootless | sh

# Set environment variables
echo "Updating environment variables..."
USER_NAME=$(whoami)
USER_ID=$(id -u)

echo "export PATH=\$PATH:/home/$USER_NAME/bin" >> ~/.bashrc
echo "export DOCKER_HOST=unix:///run/user/$USER_ID/docker.sock" >> ~/.bashrc
source ~/.bashrc

# Set up Docker as a systemd user service

# Create the systemd service directory and file
mkdir -p ~/.config/systemd/user/
cat <<EOL > ~/.config/systemd/user/docker-rootless.service
[Unit]
Description=Docker Rootless
After=network-online.target

[Service]
Type=simple
Restart=always
RestartSec=5s
ExecStart=/home/%u/bin/dockerd-rootless.sh

[Install]
WantedBy=default.target
EOL

# Reload systemd user instance, enable and start the service
systemctl --user daemon-reload
systemctl --user enable docker-rootless
systemctl --user start docker-rootless

# Ensure user-level systemd services start at boot
sudo loginctl enable-linger $(whoami)

echo "Docker in rootless mode has been installed and set to start on boot."

sudo yum install libicu -y
echo "Installed libicu Dotnet for the github agent"
Loading