From d8b2b8c2331bd06ce614c04092a598b9a490b5ae Mon Sep 17 00:00:00 2001 From: ahkui <14049597+ahkui@users.noreply.github.com> Date: Wed, 18 Jul 2018 21:20:43 +0800 Subject: [PATCH] Add gitlab (#1683) * Add gitlab --- DOCUMENTATION/content/documentation/index.md | 19 ++++++++ DOCUMENTATION/content/introduction/index.md | 2 +- docker-compose.yml | 44 +++++++++++++++++++ env-example | 8 ++++ gitlab/Dockerfile | 3 ++ .../docker-entrypoint-initdb.d/.gitignore | 3 +- .../init_gitlab_db.sh | 41 +++++++++++++++++ 7 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 gitlab/Dockerfile create mode 100644 postgres/docker-entrypoint-initdb.d/init_gitlab_db.sh diff --git a/DOCUMENTATION/content/documentation/index.md b/DOCUMENTATION/content/documentation/index.md index 10ffefb..745cf23 100644 --- a/DOCUMENTATION/content/documentation/index.md +++ b/DOCUMENTATION/content/documentation/index.md @@ -739,6 +739,25 @@ docker-compose up -d mariadb phpmyadmin +
+ +## Use Gitlab + +1 - Run the Gitlab Container (`gitlab`) with the `docker-compose up` command. Example: + +```bash +docker-compose up -d gitlab +``` + +2 - Open your browser and visit the localhost on port **8989**: `http://localhost:8989` +
+*Note: You may change GITLAB_DOMAIN_NAME to your own domain name like `http://gitlab.example.com` default is `http://localhost`* + + + + + +
## Use Adminer diff --git a/DOCUMENTATION/content/introduction/index.md b/DOCUMENTATION/content/introduction/index.md index 7478f10..a8ccf26 100644 --- a/DOCUMENTATION/content/introduction/index.md +++ b/DOCUMENTATION/content/introduction/index.md @@ -97,7 +97,7 @@ Beanstalkd - RabbitMQ - PHP Worker - **Queueing Management:** Beanstalkd Console - RabbitMQ Console - **Random Tools:** -HAProxy - Certbot - Blackfire - Selenium - Jenkins - ElasticSearch - Kibana - Grafana - Mailhog - MailDev - Minio - Varnish - Swoole - NetData - Portainer - Laravel Echo... +HAProxy - Certbot - Blackfire - Selenium - Jenkins - ElasticSearch - Kibana - Grafana - Gitlab - Mailhog - MailDev - Minio - Varnish - Swoole - NetData - Portainer - Laravel Echo... Laradock introduces the **Workspace** Image, as a development environment. It contains a rich set of helpful tools, all pre-configured to work and integrate with almost any combination of Containers and tools you may choose. diff --git a/docker-compose.yml b/docker-compose.yml index 57329db..9ffde6b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -720,6 +720,50 @@ services: - "dockerhost:${DOCKER_HOST_IP}" ports: - 9010:9000 + networks: + - backend + +### Gitlab ################################################ + gitlab: + build: + context: ./gitlab + environment: + GITLAB_OMNIBUS_CONFIG: | + external_url '${GITLAB_DOMAIN_NAME}' + redis['enable'] = false + nginx['listen_https'] = false + nginx['listen_port'] = 80 + postgresql['enable'] = false + gitlab_rails['trusted_proxies'] = ['caddy','nginx','apache2'] + gitlab_rails['redis_host'] = 'redis' + gitlab_rails['redis_database'] = 8 + gitlab_rails['db_host'] = 'postgres' + gitlab_rails['db_username'] = 'laradock_gitlab' + gitlab_rails['db_password'] = 'laradock_gitlab' + gitlab_rails['db_database'] = 'laradock_gitlab' + gitlab_rails['initial_root_password'] = '${GITLAB_ROOT_PASSWORD}' + gitlab_rails['gitlab_shell_ssh_port'] = ${GITLAB_HOST_SSH_PORT} + volumes: + - ${DATA_PATH_HOST}/gitlab/config:/etc/gitlab + - ${DATA_PATH_HOST}/gitlab/data:/var/opt/gitlab + - ${GITLAB_HOST_LOG_PATH}:/var/log/gitlab + ports: + - "${GITLAB_HOST_HTTP_PORT}:80" + - "${GITLAB_HOST_HTTPS_PORT}:443" + - "${GITLAB_HOST_SSH_PORT}:22" + networks: + - backend + depends_on: + - redis + - postgres + gitlab-runner: + image: gitlab/gitlab-runner:latest + environment: + - CI_SERVER_URL=${GITLAB_DOMAIN_NAME} + volumes: + - ${DATA_PATH_HOST}/gitlab/runner:/etc/gitlab-runner + - /var/run/docker.sock:/var/run/docker.sock:rw + restart: always ### JupyterHub ######################################### jupyterhub: diff --git a/env-example b/env-example index ecd4c2e..536a9e9 100644 --- a/env-example +++ b/env-example @@ -361,6 +361,14 @@ SOLR_VERSION=5.5 SOLR_PORT=8983 SOLR_DATAIMPORTHANDLER_MYSQL=false +### GITLAB ############################################### +GITLAB_HOST_HTTP_PORT=8989 +GITLAB_HOST_HTTPS_PORT=9898 +GITLAB_HOST_SSH_PORT=2289 +GITLAB_DOMAIN_NAME=http://localhost +GITLAB_ROOT_PASSWORD=laradock +GITLAB_HOST_LOG_PATH=./logs/gitlab + ### JUPYTERHUB ############################################### JUPYTERHUB_POSTGRES_HOST=postgres JUPYTERHUB_POSTGRES_USER=laradock_jupyterhub diff --git a/gitlab/Dockerfile b/gitlab/Dockerfile new file mode 100644 index 0000000..d9929c9 --- /dev/null +++ b/gitlab/Dockerfile @@ -0,0 +1,3 @@ +FROM gitlab/gitlab-ce:latest + +LABEL maintainer="ahkui " diff --git a/postgres/docker-entrypoint-initdb.d/.gitignore b/postgres/docker-entrypoint-initdb.d/.gitignore index 0f14d17..c462039 100644 --- a/postgres/docker-entrypoint-initdb.d/.gitignore +++ b/postgres/docker-entrypoint-initdb.d/.gitignore @@ -1,2 +1,3 @@ *.sh -!init_jupyterhub_db.sh \ No newline at end of file +!init_gitlab_db.sh +!init_jupyterhub_db.sh diff --git a/postgres/docker-entrypoint-initdb.d/init_gitlab_db.sh b/postgres/docker-entrypoint-initdb.d/init_gitlab_db.sh new file mode 100644 index 0000000..d9d7738 --- /dev/null +++ b/postgres/docker-entrypoint-initdb.d/init_gitlab_db.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# +# Copy createdb.sh.example to createdb.sh +# then uncomment then set database name and username to create you need databases +# +# example: .env POSTGRES_USER=appuser and need db name is myshop_db +# +# psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL +# CREATE USER myuser WITH PASSWORD 'mypassword'; +# CREATE DATABASE myshop_db; +# GRANT ALL PRIVILEGES ON DATABASE myshop_db TO myuser; +# EOSQL +# +# this sh script will auto run when the postgres container starts and the $DATA_PATH_HOST/postgres not found. +# +# +# psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL +# CREATE USER db1 WITH PASSWORD 'db1'; +# CREATE DATABASE db1; +# GRANT ALL PRIVILEGES ON DATABASE db1 TO db1; +# EOSQL +# +# psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL +# CREATE USER db2 WITH PASSWORD 'db2'; +# CREATE DATABASE db2; +# GRANT ALL PRIVILEGES ON DATABASE db2 TO db2; +# EOSQL +# +# psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL +# CREATE USER db3 WITH PASSWORD 'db3'; +# CREATE DATABASE db3; +# GRANT ALL PRIVILEGES ON DATABASE db3 TO db3; +# EOSQL +# +### default database and user for gitlab ############################################## +psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL + CREATE USER laradock_gitlab WITH PASSWORD 'laradock_gitlab'; + CREATE DATABASE laradock_gitlab; + GRANT ALL PRIVILEGES ON DATABASE laradock_gitlab TO laradock_gitlab; + ALTER ROLE laradock_gitlab CREATEROLE SUPERUSER; +EOSQL