How to install GitLab in Ubuntu 18 with Nginx, letsencrypt, private docker register

install gitlab on ubuntu

Step 1

assuming that you have already secured your Ubuntu VPS, then SSH login to the VPS , install docker, docker-compose and docker-compose-letsencrypt-nginx-proxy-companion, see my previous posts( post 1, post 2) for more details.

Step 2

create the following shell script and execute it the same directory of docker-compose-letsencrypt-nginx-proxy-companion.

#!/bin/bash

# Read your .env file
source .env

DOMAIN=yourGitlabDomainName
EMAIL=yourEmail
REGISTRY=https://yourRegisteryDomainName


if [ -z ${SERVICE_NETWORK+X} ]; then
docker run -d \
--restart=always \
--network=$NETWORK \
--name gitlab \
--hostname $DOMAIN \
--env GITLAB_OMNIBUS_CONFIG="registry_external_url '$REGISTRY';" \
-v ${NGINX_FILES_PATH:-./data}/certs:/etc/gitlab/ssl \
-v ${NGINX_FILES_PATH:-./data}/gitlab/logs:/var/log/gitlab \
-v ${NGINX_FILES_PATH:-./data}/gitlab/data:/var/opt/gitlab \
-e VIRTUAL_HOST=$DOMAIN \
-e LETSENCRYPT_HOST=$DOMAIN \
-e LETSENCRYPT_EMAIL=$EMAIL \
gitlab/gitlab-ce:latest
else
docker run -d \
--restart=always \
--network=$SERVICE_NETWORK \
--name gitlab \
--env GITLAB_OMNIBUS_CONFIG="registry_external_url '$REGISTRY';" \
-v ${NGINX_FILES_PATH:-./data}/certs:/etc/gitlab/ssl \
-v ${NGINX_FILES_PATH:-./data}/gitlab/logs:/var/log/gitlab \
-v ${NGINX_FILES_PATH:-./data}/gitlab/data:/var/opt/gitlab \
-e VIRTUAL_HOST=$DOMAIN \
-e LETSENCRYPT_HOST=$DOMAIN \
-e LETSENCRYPT_EMAIL=$EMAIL\
gitlab/gitlab-ce:latest
fi

exit 0

Step 3

create a project your own gitlab site, and you will see registry in the project page.

registry

All done! how easy it is!