Az

Setting Up Docker And GitLab

As part of a re-hash of my home servers and development environment, I’m focusing on containerised app/software installation in server environment. In particularly I’ll be focusing on Vagrant for the setup and configuration of quick dev environments and Docker for running software securely in it’s own containers.

Below you should find a short list of the steps required to set up a server with Docker, install Gitlab, PostgreSQL for storage, Redis for caching, and nginx as a reverse proxy to serve requests to your Gitlab instance. This installation makes use of mounted volumes on the host for storage of the database and git repositories, to prevent the data being lost if the containers are destroyed.

Development Server

  • Install Ubuntu 14.04 - DONE
  • Add nameserver 192.168.0.1 to /etc/resolvconf/resol/conf.d/base then run sudo resolvconf -u
    • sudo apt-get update && sudo apt-get upgrade && sudo apt-get install lookup
    • Open /etc/network/interfaces
      • Set up static IP
  • Install Docker
    • curl -sSL https://get.docker.io/ubuntu/ | sudo sh
  • Install Gitlab docker container
    • Install PostgreSQL docker container
      • sudo mkdir -p /opt/postgresql/data
      • sudo docker run --name=postgresql -d -e 'DB_NAME=gitlabhq_production' -e 'DB_USER=gitlab' -e 'DB_PASS=[PASSWORD]' -v /opt/postgresql/data:/var/lib/postgresql sameersbn/postgresql:latest
    • Install Redis docker container
      • docker run --name=redis -d -v /opt/redis:/var/lib/redis sameersbn/redis:latest
    • sudo mkdir -p /opt/gitlab/data
    • sudo docker run --name=gitlab -d --link postgresql:postgresql --link redis:redisio -e 'VIRTUAL_HOST=gitlab.dev.adamogrady.id.au' -e 'GITLAB_EMAIL=adam.ogrady@gmail.com' -e 'GITLAB_BACKUPS=daily' -e 'GITLAB_BACKUP_EXPIRY=604800' -e 'SMTP_ENABLED=true' -e 'SMTP_HOST=smtp.gmail.com' -e 'SMTP_USER=[USEREMAIL]' -e 'SMTP_PASS=[PASSWORD]' -v /opt/gitlab/data:/home/git/data sameersbn/gitlab:7.3.2-1
    • Transfer data over from backup on existing Gitlab installation (after upgrading it to the same 7.3.2-1 version to which I was moving)
  • Install Nginx (reverse proxy)
    • sudo docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy