Skip to content

Instantly share code, notes, and snippets.

@wojas
Created August 25, 2022 07:09
Show Gist options
  • Save wojas/736af29bcfb607bd6abebfb0faaf1fc2 to your computer and use it in GitHub Desktop.
Save wojas/736af29bcfb607bd6abebfb0faaf1fc2 to your computer and use it in GitHub Desktop.
Run the Gitlab runner locally in Docker (tested on macOS)
#!/bin/sh
# Based on https://stackoverflow.com/a/65920577/297793
# Manually start this first:
## docker run -d \
## --name gitlab-runner \
## --restart always \
## -v "$HOME:$HOME" \
## -v /var/run/docker.sock:/var/run/docker.sock \
## gitlab/gitlab-runner:latest
job="$1"
if [ -z "$job" ]; then
echo "USAGE: $0 <job-name>"
exit 2
fi
echo "* Checking if gitlab-runner is running.."
if ! docker inspect gitlab-runner > /dev/null ; then
echo
echo "ERROR: gitlab-runner NOT RUNNING, run this first:"
echo
grep '^##' "$0" | sed 's/^## //'
exit 10
fi
set -ex
docker exec -it -w "$PWD" gitlab-runner gitlab-runner exec docker "$job"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment