Skip to content

Instantly share code, notes, and snippets.

@cweilguny
Last active October 27, 2021 00:55
Show Gist options
  • Star 36 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save cweilguny/c1db2985b542f9916995139318e5a7ce to your computer and use it in GitHub Desktop.
Save cweilguny/c1db2985b542f9916995139318e5a7ce to your computer and use it in GitHub Desktop.
A docker-compose config in v3 format for nginx-proxy with separate containers for nginx, dockergen and letsencrypt-companion. Additional example on how to get GitLab docker container running with this nginx-proxy setup. You need to create the docker network before, just run 'docker network create nginx-proxy'. Docker will tell you so if you don'…
version: '3'
services:
web:
image: 'gitlab/gitlab-ce:latest'
restart: always
hostname: 'gitlab.example.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.example.com'
nginx['listen_port'] = 80
nginx['listen_https'] = false
nginx['proxy_set_headers'] = {
"X-Forwarded-Proto" => "https",
"X-Forwarded-Ssl" => "on"
}
VIRTUAL_HOST: gitlab.example.com
LETSENCRYPT_HOST: gitlab.example.com
LETSENCRYPT_EMAIL: email@example.com
volumes:
- '/srv/dockerdata/gitlab/config:/etc/gitlab'
- '/srv/dockerdata/gitlab/logs:/var/log/gitlab'
- '/srv/dockerdata/gitlab/data:/var/opt/gitlab'
networks:
default:
external:
name: nginx-proxy
version: '3'
services:
nginx:
image: nginx
container_name: nginx
ports:
- '80:80'
- '443:443'
volumes:
- 'nginx-config:/etc/nginx/conf.d'
- 'nginx-certs:/etc/nginx/certs'
- 'nginx-vhosts:/etc/nginx/vhost.d'
- 'nginx-webroot:/usr/share/nginx/html'
dockergen:
image: jwilder/docker-gen
container_name: nginx-docker-gen
command: -notify-sighup nginx -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
volumes:
- 'nginx-config:/etc/nginx/conf.d'
- 'nginx-certs:/etc/nginx/certs'
- 'nginx-vhosts:/etc/nginx/vhost.d'
- 'nginx-webroot:/usr/share/nginx/html'
- '/var/run/docker.sock:/tmp/docker.sock:ro'
- './nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl'
letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
environment:
NGINX_DOCKER_GEN_CONTAINER: nginx-docker-gen
volumes:
- 'nginx-config:/etc/nginx/conf.d'
- 'nginx-certs:/etc/nginx/certs'
- 'nginx-vhosts:/etc/nginx/vhost.d'
- 'nginx-webroot:/usr/share/nginx/html'
- '/var/run/docker.sock:/var/run/docker.sock:ro'
volumes:
nginx-config:
nginx-certs:
nginx-vhosts:
nginx-webroot:
networks:
default:
external:
name: nginx-proxy
@ibayer
Copy link

ibayer commented Mar 21, 2018

Hi, thanks for sharing this great gist!
I had to open the ssh port manually (and remap because port 22 is already use on my machine).
Does git clone ssh: work out of the box with your config?

This are the additions I had to make:

services:
  gitlab:
    image: 'gitlab/gitlab-ce:10.5.4-ce.0'
    container_name: gitlab
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        gitlab_rails['gitlab_shell_ssh_port']=34892

    ports:
      - '34892:22'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment