Skip to content

Gitlab CE + Docker Compose + Let's Encrypt (auto generate/renew)

Notifications You must be signed in to change notification settings

steevepay/gitlab-docker-letsencrypt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Gitlab CE + Docker Compose running with auto generate/renew Let's Encrypt Certificate

With this repo you will be able to set up self hosted Gitlab CE as a container over SSL auto generated and auto renewed by a web proxy.

PREREQUISITES

In order to use this compose file (docker-compose.yml) you must have:

HOW TO USE

  1. Close this repository
$ git clone https://github.com/steevepay/gitlab-docker-letsencrypt.git
  1. Make a copy of the .env.example and rename it to .env:

Update this file with your preferences.

#
# Container name for your Portainer
#
CONTAINER_NAME=my-gitlab-container

#
# Path where your Gitlab files will be located
#
GITLAB_DATA_PATH=/data/gitlab/

#
# Your domain (or domains)
#
VIRTUAL_HOST=gitlab.domain.com,www.gitlab.domain.com


#
# Your domain (or domains) for SSL certificate
#
LETSENCRYPT_HOST=gitlab.domain.com,www.gitlab.domain.com

#
# Your email for Let's Encrypt register
#
LETSENCRYPT_EMAIL=[email protected]

#
# Main domain for SSL certificate and gitlab
#
MAIN_DOMAIN=gitlab.domain.com

#
# Network name
# 
# Your container app must use a network conencted to your webproxy 
# https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion
#
NETWORK=webproxy
  1. Validate and view the docker-compose configuration before starting.
$ docker-compose config
  1. Start the container.

During the build time, the environment variables are injected into the image.

$ docker-compose up -d

Please keep in mind that when starting for the first time it may take a few moments (even a couple minutes) to get your Let's Encrypt certificates generated

Pre-configure Gitlab CE

You can pre-configure the GitLab Docker image by adding the environment variable GITLAB_OMNIBUS_CONFIG to the docker-compose file. This variable can contain any gitlab.rb setting and will be evaluated before loading the container’s gitlab.rb file. That way you can easily configure GitLab’s external URL, make any database configuration or any other option from the Omnibus GitLab template.

Here is an example of pre-configuring OVH STMP server for the gitlab:

version: "3.7"

services:
  gitlab-letsencrypt:
    image: 'gitlab/gitlab-ce:latest'
    container_name: ${CONTAINER_NAME}
    restart: always
    hostname: ${MAIN_DOMAIN}
    volumes:
      - '${GITLAB_DATA_PATH}config:/etc/gitlab'
      - '${GITLAB_DATA_PATH}logs:/var/log/gitlab'
      - '${GITLAB_DATA_PATH}data:/var/opt/gitlab'
    restart: unless-stopped
    env_file:
      - ./.env
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        gitlab_rails['smtp_enable'] = true
        gitlab_rails['smtp_address'] = 'ssl0.ovh.net'
        gitlab_rails['smtp_port'] = 465
        gitlab_rails['smtp_user_name'] = '[email protected]'
        gitlab_rails['smtp_password'] = ''
        gitlab_rails['smtp_domain'] = 'ssl0.ovh.net'
        gitlab_rails['smtp_authentication'] = 'login'
        gitlab_rails['smtp_enable_starttls_auto'] = true
        gitlab_rails['smtp_tls'] = true
        gitlab_rails['smtp_openssl_verify_mode'] = 'none'
    networks:
      - default

networks:
  default:
    external:
      name: ${NETWORK}

For more options about configuring GitLab please check the Omnibus GitLab documentation.

About

Gitlab CE + Docker Compose + Let's Encrypt (auto generate/renew)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published