From def1dc4501c7188002133788ef6a1f0671c5045f Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Fri, 28 Apr 2023 15:49:01 +0200 Subject: [PATCH 1/6] WIP add mattermost and registry conf --- .env.dist | 16 +++++++++- README.md | 37 ++++++++++++++-------- compose.mattermost.yml | 9 ++++++ compose.registry.yml | 10 ++++++ compose.yml | 71 ++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 60 ----------------------------------- 6 files changed, 129 insertions(+), 74 deletions(-) create mode 100644 compose.mattermost.yml create mode 100644 compose.registry.yml create mode 100644 compose.yml delete mode 100644 docker-compose.yml diff --git a/.env.dist b/.env.dist index 0539c5d..b466d1f 100644 --- a/.env.dist +++ b/.env.dist @@ -1,2 +1,16 @@ -GITLAB_HOSTNAME=my.domain.tld +DOMAIN=domain.tld +GITLAB_SUBDOMAIN=gitlab GITLAB_SSH_PORT=22 +# To enable Mattermost set `true`. To disable Mattermost leave empty. +MATTERMOST_ENABLE= +MATTERMOST_SUBDOMAIN=mattermost +# To enable Registry set `true`. To disable Registry leave empty. +REGISTRY_ENABLE= +REGISTRY_STORAGE_ACCESS_KEY=s3-access-key +REGISTRY_STORAGE_BUCKET=your-s3-bucket +REGISTRY_STORAGE_REGION=your-s3-region +REGISTRY_STORAGE_REGION_ENDPOINT=your-s3-regionendpoint +REGISTRY_STORAGE_SECRET_KEY=s3-secret-key-for-access-key +REGISTRY_SUBDOMAIN=registry + +COMPOSE_FILE=compose.yml${MATTERMOST_ENABLE:+:compose.mattermost.yml}${REGISTRY_ENABLE:+:compose.registry.yml} diff --git a/README.md b/README.md index d8096a3..28c158b 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,15 @@ #### Table of Contents -1. [Description](#description) -2. [Setup](#setup) -3. [Usage](#usage) -4. [Reference](#reference) -5. [Development](#development) -6. [Contributors](#contributors) +- [GitLab with Docker Compose](#gitlab-with-docker-compose) + - [Table of Contents](#table-of-contents) + - [Description](#description) + - [Setup](#setup) + - [Usage](#usage) + - [Reference](#reference) + - [Environment variables](#environment-variables) + - [Development](#development) + - [Contributors](#contributors) ## Description @@ -36,13 +39,21 @@ docker compose up -d ### Environment variables -#### `GITLAB_HOSTNAME` - -The GitLab hostname. Default value: 'my.domain.tld' - -#### `GITLAB_SSH_PORT` - -The GitLab SSH port for git. Default value: '22' +| Name | Description | Default value | +| ---------------------------------- | ------------------------------------------------------------------- | ------------------------------ | +| `DOMAIN` | The GitLab domain | `domain.tld` | +| `GITLAB_SUBDOMAIN` | The GitLab subdomain | `gitlab` | +| `GITLAB_SSH_PORT` | The GitLab SSH port for git. | `22` | +| `MATTERMOST_ENABLE` | To enable Mattermost set `true`. To disable Mattermost leave empty. | | +| `MATTERMOST_SUBDOMAIN` | The Mattermost subdomain | `mattermost` | +| `REGISTRY_ENABLE` | To enable Registry set `true`. To disable Registry leave empty. | | +| `REGISTRY_SUBDOMAIN` | The Mattermost subdomain | `registry` | +| `REGISTRY_STORAGE_ACCESS_KEY` | The S3 access key | `s3-access-key` | +| `REGISTRY_STORAGE_BUCKET` | The S3 bucket | `your-s3-bucket` | +| `REGISTRY_STORAGE_REGION` | The S3 region | `your-s3-region` | +| `REGISTRY_STORAGE_REGION_ENDPOINT` | The S3 region endpoint | `your-s3-regionendpoint` | +| `REGISTRY_STORAGE_SECRET_KEY` | The S3 secret key | `s3-secret-key-for-access-key` | +| `REGISTRY_SUBDOMAIN` | The Registry subdomain | `registry` | ## Development diff --git a/compose.mattermost.yml b/compose.mattermost.yml new file mode 100644 index 0000000..21f6b20 --- /dev/null +++ b/compose.mattermost.yml @@ -0,0 +1,9 @@ +services: + web: + # Traefik labels are suggested as an example for people using Traefik, + # remove them if you are using another reverse proxy. + labels: + traefik.http.routers.gitlab-mattermost.entrypoints: websecure + traefik.http.routers.gitlab-mattermost.rule: "Host(`${MATTERMOST_SUBDOMAIN}.${DOMAIN}`)" + traefik.http.routers.gitlab-mattermost.service: gitlab-mattermost + traefik.http.routers.gitlab-mattermost.tls.certresolver: myresolver diff --git a/compose.registry.yml b/compose.registry.yml new file mode 100644 index 0000000..cbdfd3f --- /dev/null +++ b/compose.registry.yml @@ -0,0 +1,10 @@ +services: + web: + # Traefik labels are suggested as an example for people using Traefik, + # remove them if you are using another reverse proxy. + labels: + traefik.http.routers.gitlab-registry.entrypoints: websecure + traefik.http.routers.gitlab-registry.rule: "Host(`${REGISTRY_SUBDOMAIN}.${DOMAIN}`)" + traefik.http.routers.gitlab-registry.service: gitlab-registry + traefik.http.routers.gitlab-registry.tls.certresolver: myresolver + traefik.http.services.gitlab-registry.loadbalancer.server.port: 5000 diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..019c0c8 --- /dev/null +++ b/compose.yml @@ -0,0 +1,71 @@ +services: + web: + image: 'gitlab/gitlab-ce:latest' + restart: unless-stopped + hostname: "${GITLAB_SUBDOMAIN}.${DOMAIN}" + environment: + GITLAB_OMNIBUS_CONFIG: | + gitlab_rails['gitlab_shell_ssh_port'] = ${GITLAB_SSH_PORT} + external_url "https://${GITLAB_SUBDOMAIN}.${DOMAIN}" + mattermost['enable'] = ${MATTERMOST_ENABLE:-false} + mattermost['gitlab_auth_endpoint'] = "http://${GITLAB_SUBDOMAIN}.${DOMAIN}/oauth/authorize" + mattermost['gitlab_token_endpoint'] = "http://${GITLAB_SUBDOMAIN}.${DOMAIN}/oauth/token" + mattermost['gitlab_user_api_endpoint'] = "http://${GITLAB_SUBDOMAIN}.${DOMAIN}/api/v4/user" + mattermost['service_address'] = "0.0.0.0" + mattermost_external_url "https://${MATTERMOST_SUBDOMAIN}.${DOMAIN}" + mattermost_nginx['enable'] = false + nginx['listen_port'] = '80' + nginx['listen_https'] = false + registry['enable'] = ${REGISTRY_ENABLE:-false} + registry['registry_http_addr'] = "0.0.0.0:5000" + registry['storage'] = { + 's3' => { + 'accesskey' => '${REGISTRY_STORAGE_ACCESS_KEY}', + 'secretkey' => '${REGISTRY_STORAGE_SECRET_KEY}', + 'bucket' => '${REGISTRY_STORAGE_BUCKET}', + 'region' => '${REGISTRY_STORAGE_REGION}', + 'regionendpoint' => '${REGISTRY_STORAGE_REGION_ENDPOINT}' + } + } + registry_external_url "https://${REGISTRY_SUBDOMAIN}.${DOMAIN}" + registry_nginx['enable'] = false + # Traefik labels are suggested as an example for people using Traefik, + # remove them if you are using another reverse proxy. + labels: + traefik.enable: true + traefik.http.routers.gitlab.entrypoints: websecure + traefik.http.routers.gitlab.rule: "Host(`${GITLAB_SUBDOMAIN}.${DOMAIN}`)" + traefik.http.routers.gitlab.tls.certresolver: myresolver + traefik.http.services.gitlab.loadbalancer.server.port: 80 + # If you don't want to use a reverse proxy (not suitable for production!) + # ports: + # - "80:80" + networks: + - default + - web + ports: + - ${GITLAB_SSH_PORT}:22 + volumes: + - web_config:/etc/gitlab + - web_logs:/var/log/gitlab + - web_data:/var/opt/gitlab + + runner: + image: 'gitlab/gitlab-runner:latest' + networks: + - runner + restart: unless-stopped + volumes: + - runner_config:/etc/gitlab-runner + - /var/run/docker.sock:/var/run/docker.sock + +networks: + runner: + web: + external: true + +volumes: + runner_config: + web_config: + web_data: + web_logs: diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 59c28df..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,60 +0,0 @@ -version: '3.3' - -services: - web: - image: 'gitlab/gitlab-ce:latest' - restart: unless-stopped - hostname: ${GITLAB_HOSTNAME} - environment: - GITLAB_OMNIBUS_CONFIG: | - external_url "https://${GITLAB_HOSTNAME}" - nginx['listen_port'] = '80' - nginx['listen_https'] = false - gitlab_rails['gitlab_shell_ssh_port'] = ${GITLAB_SSH_PORT} - # If you want enable mattermost, remove this line and uncomment the following lines - # mattermost_external_url "http://mattermost.${GITLAB_HOSTNAME}" - # mattermost['gitlab_auth_endpoint'] = "http://${GITLAB_HOSTNAME}/oauth/authorize" - # mattermost['gitlab_token_endpoint'] = "http://${GITLAB_HOSTNAME}/oauth/token" - # mattermost['gitlab_user_api_endpoint'] = "http://${GITLAB_HOSTNAME}/api/v4/user" - # Traefik labels are suggested as an example for people using Traefik, - # remove them if you are using another reverse proxy. - labels: - traefik.enable: 'true' - traefik.http.routers.gitlab.entrypoints: websecure - traefik.http.routers.gitlab.rule: "Host(`${GITLAB_HOSTNAME}`)" - traefik.http.routers.gitlab.tls.certresolver: myresolver - # If you want enable mattermost, comment the previous line and uncomment the next line - # traefik.http.routers.gitlab.tls.certresolver: "Host(`${GITLAB_HOSTNAME}`,`mattermost.${GITLAB_HOSTNAME}`)" - traefik.http.services.gitlab.loadbalancer.server.port: 80 - # If you don't want to use a reverse proxy (not suitable for production!) - # ports: - # - "80:80" - networks: - - default - - web - ports: - - ${GITLAB_SSH_PORT}:22 - volumes: - - web_config:/etc/gitlab - - web_logs:/var/log/gitlab - - web_data:/var/opt/gitlab - - runner: - image: 'gitlab/gitlab-runner:latest' - networks: - - runner - restart: unless-stopped - volumes: - - runner_config:/etc/gitlab-runner - - /var/run/docker.sock:/var/run/docker.sock - -networks: - runner: - web: - external: true - -volumes: - runner_config: - web_config: - web_data: - web_logs: From 318aed79766abeb4e64234bd61fe963b16423d77 Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Tue, 10 Oct 2023 21:32:45 +0200 Subject: [PATCH 2/6] Add vscode settings --- .vscode/extensions.json | 12 ++++++++++++ .vscode/settings.json | 4 ++++ 2 files changed, 16 insertions(+) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..05eca24 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,12 @@ +{ + "recommendations": [ + "mikestead.dotenv", + "ymotongpoo.licenser", + "davidanson.vscode-markdownlint", + "ms-azuretools.vscode-docker", + "redhat.vscode-yaml" + ], + "unwantedRecommendations": [ + + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4d97916 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "licenser.projectName": "GitLab with Docker Compose", + "licenser.license": "GPLv3" +} \ No newline at end of file From 35242b97a717a6229e344111ff26e8fdf077e244 Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Tue, 10 Oct 2023 21:33:08 +0200 Subject: [PATCH 3/6] Add Licence header --- NOTICE | 16 ---------------- compose.mattermost.yml | 17 +++++++++++++++++ compose.registry.yml | 17 +++++++++++++++++ compose.yml | 17 +++++++++++++++++ 4 files changed, 51 insertions(+), 16 deletions(-) delete mode 100644 NOTICE diff --git a/NOTICE b/NOTICE deleted file mode 100644 index fd01deb..0000000 --- a/NOTICE +++ /dev/null @@ -1,16 +0,0 @@ -Docker GitLab - -Copyright 2018 Solution Libre SAS - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . diff --git a/compose.mattermost.yml b/compose.mattermost.yml index 21f6b20..db11cb1 100644 --- a/compose.mattermost.yml +++ b/compose.mattermost.yml @@ -1,3 +1,20 @@ +# Copyright (C) 2023 Solution Libre +# +# This file is part of GitLab with Docker Compose. +# +# GitLab with Docker Compose is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GitLab with Docker Compose is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GitLab with Docker Compose. If not, see . + services: web: # Traefik labels are suggested as an example for people using Traefik, diff --git a/compose.registry.yml b/compose.registry.yml index cbdfd3f..dbacd0c 100644 --- a/compose.registry.yml +++ b/compose.registry.yml @@ -1,3 +1,20 @@ +# Copyright (C) 2023 Solution Libre +# +# This file is part of GitLab with Docker Compose. +# +# GitLab with Docker Compose is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GitLab with Docker Compose is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GitLab with Docker Compose. If not, see . + services: web: # Traefik labels are suggested as an example for people using Traefik, diff --git a/compose.yml b/compose.yml index 019c0c8..24f6941 100644 --- a/compose.yml +++ b/compose.yml @@ -1,3 +1,20 @@ +# Copyright (C) 2018-2023 Solution Libre +# +# This file is part of GitLab with Docker Compose. +# +# GitLab with Docker Compose is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GitLab with Docker Compose is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GitLab with Docker Compose. If not, see . + services: web: image: 'gitlab/gitlab-ce:latest' From 468dd9b0b815b179845d24fea3a036335ec83f83 Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Tue, 10 Oct 2023 21:33:26 +0200 Subject: [PATCH 4/6] Rename docker-volumes to volumes --- {docker-volumes => volumes}/runner/config | 0 {docker-volumes => volumes}/web/config | 0 {docker-volumes => volumes}/web/data | 0 {docker-volumes => volumes}/web/logs | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {docker-volumes => volumes}/runner/config (100%) rename {docker-volumes => volumes}/web/config (100%) rename {docker-volumes => volumes}/web/data (100%) rename {docker-volumes => volumes}/web/logs (100%) diff --git a/docker-volumes/runner/config b/volumes/runner/config similarity index 100% rename from docker-volumes/runner/config rename to volumes/runner/config diff --git a/docker-volumes/web/config b/volumes/web/config similarity index 100% rename from docker-volumes/web/config rename to volumes/web/config diff --git a/docker-volumes/web/data b/volumes/web/data similarity index 100% rename from docker-volumes/web/data rename to volumes/web/data diff --git a/docker-volumes/web/logs b/volumes/web/logs similarity index 100% rename from docker-volumes/web/logs rename to volumes/web/logs From 2a9da2245427547c02dab7ff9c1638f56f13fb21 Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Tue, 10 Oct 2023 21:37:16 +0200 Subject: [PATCH 5/6] Change md linter --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b340f7..8795058 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,8 @@ jobs: container: image: docker:latest steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - name: Check Docker Compose file syntax run: docker compose --env-file .env.dist config -q check-markdown-syntax: @@ -17,6 +18,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - name: Lint Markdown - uses: articulate/actions-markdownlint@v1 + uses: DavidAnson/markdownlint-cli2-action@v13 with: - files: '**/*.md' + globs: '**/*.md' From 0b6369a470ec51ced68e64d04630349c7eeaafc7 Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Tue, 10 Oct 2023 22:18:33 +0200 Subject: [PATCH 6/6] Fix missing mattermost port service --- compose.mattermost.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/compose.mattermost.yml b/compose.mattermost.yml index db11cb1..bc3b0df 100644 --- a/compose.mattermost.yml +++ b/compose.mattermost.yml @@ -24,3 +24,4 @@ services: traefik.http.routers.gitlab-mattermost.rule: "Host(`${MATTERMOST_SUBDOMAIN}.${DOMAIN}`)" traefik.http.routers.gitlab-mattermost.service: gitlab-mattermost traefik.http.routers.gitlab-mattermost.tls.certresolver: myresolver + traefik.http.services.gitlab-mattermost.loadbalancer.server.port: 8065