Skip to content

Instantly share code, notes, and snippets.

@richardsonlima
Last active September 16, 2021 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richardsonlima/dc32788661bed1645a7c11b15ce252c2 to your computer and use it in GitHub Desktop.
Save richardsonlima/dc32788661bed1645a7c11b15ce252c2 to your computer and use it in GitHub Desktop.
Gitlab CE Docker Compose - Web 15 Sep 2021
version: '3'
# See https://docs.docker.com/compose/overview/ for more information.
# If you make changes to this file or any related files, apply them by
# navigating to the directory that holds this file and run this as root:
# docker-compose down; docker-compose up -d
# Create a network for our containers.
networks:
frontend:
# Create persistent Docker volumes to preserve important data.
# We don't want our data to be lost when restarting containers.
volumes:
# For storing GitLab's configuration files:
vol-gitlab-config:
# For storing GitLab's logs:
vol-gitlab-logs:
# For storing GitLab's application data:
vol-gitlab-data:
# Create our containers.
services:
# Watchtower detects if any linked containers have an new image
# available, automatically updating & restarting them if needed.
watchtower:
# https://hub.docker.com/r/centurylink/watchtower/
image: v2tec/watchtower:latest
# https://github.com/v2tec/watchtower#options
# This schedule applies updates (if available) at midnight.
command: --cleanup --schedule "0 0 0 * * *"
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
# The main front-end application.
gitlab:
# To stick to a specific version, replace "latest" with a tag from:
# https://hub.docker.com/r/gitlab/gitlab-ce/tags/
image: gitlab/gitlab-ce:14.1.5-ce.0
restart: always
hostname: "${GITLAB_DOMAIN}"
ports:
- "22:22" # Change to "2222:22" if the host needs port 22.
- "80:80"
- "443:443"
networks:
- frontend
volumes:
# Ensure GitLab content persist between restarts.
- vol-gitlab-config:/etc/gitlab
- vol-gitlab-logs:/var/log/gitlab
- vol-gitlab-data:/var/opt/gitlab
environment:
GITLAB_OMNIBUS_CONFIG: |
# Add gitlab.rb configuration here, each on its own line.
# See: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template
external_url 'http://${GITLAB_DOMAIN}'
letsencrypt['enable'] = false
# Configure headers for outgoing email.
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'no-reply@${GITLAB_DOMAIN}'
gitlab_rails['gitlab_email_display_name'] = 'GitLab'
gitlab_rails['gitlab_email_reply_to'] = 'no-reply@${GITLAB_DOMAIN}'
# Send outgoing email via the SMTP container:
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "mail"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_tls'] = false
# Limit backup lifetime to 7 days (604800 seconds):
gitlab_rails['backup_keep_time'] = 604800
# This allows GitLab to send email straight out of the box without
# having to rely on an external provider like SendGrid or MailGun.
# It makes an SMTP host available at the hostname "mail".
mail:
image: bytemark/smtp
restart: always
networks:
- frontend
version: '3'
services:
gitlab:
image: gitlab/gitlab-ce:14.1.5-ce.0
container_name: GitLab
restart: always
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.dev.internal.example.com:50443'
gitlab_rails['time_zone'] = 'America/Toronto'
gitlab_rails['gitlab_email_from'] = 'gitlab-no-reply@example.com'
gitlab_rails['gitlab_email_display_name'] = 'GitLab Administrator'
gitlab_rails['gitlab_email_reply_to'] = 'admin@hexample.com'
gitlab_rails['backup_keep_time'] = 14515200
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.example.com"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "no-reply@example.com"
gitlab_rails['smtp_password'] = "changeMeToSomethingGood"
gitlab_rails['smtp_domain'] = "example.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
unicorn['worker_timeout'] = 60
unicorn['worker_processes'] = 3
logging['logrotate_frequency'] = "weekly"
logging['logrotate_rotate'] = 52
logging['logrotate_compress'] = "compress"
logging['logrotate_method'] = "copytruncate"
logging['logrotate_delaycompress'] = "delaycompress"
nginx['listen_port'] = 443
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/ssl/certs/gitlab/server-cert.pem"
nginx['ssl_certificate_key'] = "/etc/ssl/certs/gitlab/server-key.pem"
nginx['ssl_protocols'] = "TLSv1.1 TLSv1.2"
nginx['logrotate_frequency'] = "weekly"
nginx['logrotate_rotate'] = 52
nginx['logrotate_compress'] = "compress"
nginx['logrotate_method'] = "copytruncate"
nginx['logrotate_delaycompress'] = "delaycompress"
# Add any other gitlab.rb configuration options if desired
ports:
- '50443:443'
- '50022:22'
volumes:
- ./volume_data/conf:/etc/gitlab
- ./volume_data/ssl:/etc/ssl/certs/gitlab
- ./volume_data/logs:/var/log/gitlab
- ./volume_data/main:/var/opt/gitlab
networks:
dev-net:
aliases:
- gitlab.dev.internal.example.com
networks:
dev-net:
external:
name: development
version: "3.0"
services:
gitlab:
image: 'gitlab/gitlab-ce:14.1.5-ce.0'
restart: always
hostname: 'gitlab.local.domain'
ports:
- '8180:80'
- '443:443'
- '2222:22'
volumes:
- './config:/etc/gitlab'
- './logs:/var/log/gitlab'
- './data:/var/opt/gitlab'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment