Run GitLab with Docker

/etc/systemd/system/gitlab.service
[Unit]
Description=GitLab
After=docker.service
Requires=docker.service
BindsTo=docker.service
 
[Service]
SyslogIdentifier=gitlab.service
ExecStart=/usr/bin/systemd-docker run \
  --rm \
  --name %n \
  --hostname git.EXAMPLE.com \
  --net orznet --ip 100.64.64.2 \
  --volume /srv/gitlab/config:/etc/gitlab \
  --volume /srv/gitlab/logs:/var/log/gitlab \
  --volume /srv/gitlab/data:/var/opt/gitlab \
  --env GITLAB_OMNIBUS_CONFIG="\
    gitlab_rails['smtp_enable'] = true; \
    gitlab_rails['smtp_address'] = 'smtp.mailgun.org'; \
    gitlab_rails['smtp_port'] = 587; \
    gitlab_rails['smtp_authentication'] = 'plain'; \
    gitlab_rails['smtp_enable_starttls_auto'] = true; \
    gitlab_rails['smtp_user_name'] = 'postmaster@EXAMPLE.com'; \
    gitlab_rails['smtp_password'] = 'EXAMPLE'; \
    gitlab_rails['smtp_domain'] = 'EXAMPLE.com'; \
    gitlab_rails['gitlab_email_from'] = 'git@EXAMPLE.com'; \
    gitlab_rails['gitlab_email_reply_to'] = 'git@EXAMPLE.com'; \
    external_url 'https://git.EXAMPLE.com/'; \
    nginx['redirect_http_to_https'] = true; \
    gitlab_rails['lfs_enabled'] = true; \
    nginx['ssl_certificate'] = '/etc/gitlab/ssl/ssl.crt'; \
    nginx['ssl_certificate_key'] = '/etc/gitlab/ssl/ssl.key'; \
    gitlab_rails['omniauth_enabled'] = true; \
    gitlab_rails['omniauth_providers'] = [ \
      { \
        'name' => 'github', \
        'app_id' => 'EXAMPLE', \
        'app_secret' => 'EXAMPLE', \
        'url' => 'https://github.com/', \
        'args' => { 'scope' => 'user:email' } \
      } \
    ]; \
    registry['enable'] = false; \
    pages_external_url 'https://EXAMPLE.com'; \
    gitlab_pages['enable'] = false; \
    pages_nginx['enable'] = false; \
    gitlab_rails['pages_enabled'] = false; \
    gitlab_rails['pages_host'] = 'EXAMPLE.com'; \
    gitlab_rails['pages_port'] = 443; \
    gitlab_rails['pages_https'] = true; \
    gitlab_pages['external_http'] = 'EXAMPLE:80'; \
    gitlab_pages['external_https'] = 'EXAMPLE:443'; \
  " \
  gitlab/gitlab-ce:9.0.4-ce.0
Restart=always
RestartSec=30s
Type=notify
NotifyAccess=all
TimeoutStartSec=120
TimeoutStopSec=30
 
[Install]
WantedBy=multi-user.target
  • Put SSL certification at /srv/gitlab/config/ssl.{crt,key}

See Alsos