Skip to content

Instantly share code, notes, and snippets.

@tenken
Created January 17, 2016 18:27
Show Gist options
  • Save tenken/2469c4d760f80c61cfa5 to your computer and use it in GitHub Desktop.
Save tenken/2469c4d760f80c61cfa5 to your computer and use it in GitHub Desktop.
Setting up GitLab with Docker
# If you already have a webserver running you most likely won't be able to get GitLab
# woring on ports 80 and 443. Port 22 should work because we change the default SSH
# port on the host during server provisioning.
HTTP_PORT=8080
HTTPS_PORT=8443
SSH_PORT=22
# Install Docker (don't use Ubuntu's repositories, they're out of date).
wget -qO- https://get.docker.com/ | sudo sh
# Spin up a GitLab container.
sudo docker run --detach \
--name gitlab \
--restart always \
--publish "$HTTP_PORT:80" \
--publish "$SSH_PORT:22" \
--publish "$HTTPS_PORT:443" \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest
# Edit the GitLab configuration and restart the container afterwards for the changes to
# take effect.
sudo nano /srv/gitlab/config/gitlab.rb
sudo docker restart gitlab
# Create a data container for housing the runner configuration.
sudo docker run --detach \
--name gitlab-runner-config \
--volume /etc/gitlab-runner \
zanderbaldwin/ubuntu-base:15.04
# Create a data container for housing the cache volumes.
sudo docker run --detach \
--name gitlab-runner-cache \
--restart always \
# Add as many files/directories to cache here as you want.
--volume /root/.composer \
--volume /root/.npm \
--volume /usr/local/bin/composer \
zanderbaldwin/ubuntu-base:15.04
# Create a build runner for the CI.
RUNNER_ID=`sudo docker run --detach \
--restart always \
--volumes-from gitlab-runner-config \
--volume /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:latest`
sudo docker exec -it $RUNNER_ID gitlab-runner register \
--executor docker \
--docker-image zanderbaldwin/ci-runner-env:15.04 \
--volumes-from gitlab-runner-cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment