Alex Dai Playground

[Docker] GitLab Install

| Comments

OS

Ubuntu 14.04

Install docker

cmd
sudo apt-get purge docker.io
curl -s https://get.docker.com/ | sudo sh
sudo apt-get update
sudo apt-get install lxc-docker

Pull gitlab images

cmd
docker pull sameersbn/gitlab:latest
docker pull sameersbn/mysql:latest 
docker pull sameersbn/redis:latest

Run redis

cmd
docker run \

  --name=gitlab_redis \

  -tid \

  sameersbn/redis:latest

Run mysql

cmd
mkdir -p /opt/gitlab/mysql
docker run \

  --name=gitlab_mysql \

  -tid \

  -e 'DB_NAME=gitlabhq_production' \

  -e 'DB_USER=gitlab' \

  -e 'DB_PASS=password' \

  -v /opt/gitlab/mysql:/var/lib/mysql \

  sameersbn/mysql:latest

Run gitlab

cmd
  mkdir -p /opt/gitlab/data /opt/gitlab/log
  docker run \

  --name='gitlab' \

  -itd \

  --link gitlab_mysql:mysql \

  --link gitlab_redis:redisio \

  -e 'GITLAB_PORT=80' \

  -e 'GITLAB_SSH_PORT=22' \

  -e 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \

  -p 10022:22 -p 10080:80 \

  -v /var/run/docker.sock:/run/docker.sock \

  -v $(which docker):/bin/docker \

  -v /opt/gitlab/data:/home/git/data \

  -v /opt/gitlab/log:/var/log/gitlab \

  sameersbn/gitlab:latest

P.S GITLAB_SECRETS_DB_KEY_BASE =>$ pwgen -Bsv1 64

http://www.aswifter.com/2015/06/14/gitlab-with-docker/

Run

http://localhost:10080/

Username: root
Password: 5iveL!fe


Via docker-compose run

install docker-compose (Docker Engine version 1.7.1 or greater)

cmd 以下指令請用 root 執行
$ curl -L https://github.com/docker/compose/releases/download/1.5.2/run.sh > /usr/local/bin/docker-compose
$ chmod +x /usr/local/bin/docker-compose
docker-compose.yml
postgresql:

  restart: always

  image: sameersbn/postgresql:9.4-9

  environment:

    - DB_USER=gitlab

    - DB_PASS=password

    - DB_NAME=gitlabhq_production

  volumes:

    - /srv/docker/gitlab/postgresql:/var/lib/postgresql

gitlab:

  restart: always

  image: sameersbn/gitlab:8.2.2

  links:

    - redis:redisio

    - postgresql:postgresql

  ports:

    - "10080:80"

    - "10022:22"

  environment:

    - DEBUG=false

    - TZ=Asia/Taipei

    - GITLAB_TIMEZONE=Taipei


    # use -> pwgen -Bsv1 64

    - GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alphanumeric-string


    - GITLAB_HOST=localhost

    - GITLAB_PORT=10080

    - GITLAB_SSH_PORT=10022

    - GITLAB_RELATIVE_URL_ROOT=


    - GITLAB_NOTIFY_ON_BROKEN_BUILDS=true

    - GITLAB_NOTIFY_PUSHER=false


    - GITLAB_EMAIL=notifications@example.com

    - GITLAB_EMAIL_REPLY_TO=noreply@example.com

    - GITLAB_INCOMING_EMAIL_ADDRESS=reply@example.com

    - GITLAB_EMAIL_DISPLAY_NAME=Alex.Dai-GitLab


    - GITLAB_BACKUPS=daily

    - GITLAB_BACKUP_TIME=01:00


    - SMTP_ENABLED=false

    - SMTP_DOMAIN=www.gmail.com

    - SMTP_HOST=smtp.gmail.com

    - SMTP_PORT=587

    - SMTP_USER=your_acc@gmail.com

    - SMTP_PASS=password

    - SMTP_STARTTLS=true

    - SMTP_AUTHENTICATION=login


    - IMAP_ENABLED=false

    - IMAP_HOST=imap.gmail.com

    - IMAP_PORT=993

    - IMAP_USER=mailer@example.com

    - IMAP_PASS=password

    - IMAP_SSL=true

    - IMAP_STARTTLS=false

    
    # Google OAuth

    #- OAUTH_GOOGLE_API_KEY=your_key

    #- OAUTH_GOOGLE_APP_SECRET=your_serect

  volumes:

    - /srv/docker/gitlab/gitlab:/home/git/data

redis:

  restart: always

  image: sameersbn/redis:latest

  volumes:

    - /srv/docker/gitlab/redis:/var/lib/redis

# gitlab-ci

gitlab-runner:

  restart: always

  image: gitlab/gitlab-runner:latest

  volumes:

    - /var/run/docker.sock:/var/run/docker.sock

    - /srv/gitlab-runner/config:/etc/gitlab-runner


Start

cmd
$ docker-compose up

References

Comments

comments powered by Disqus