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/.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' 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 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/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..bc3b0df --- /dev/null +++ b/compose.mattermost.yml @@ -0,0 +1,27 @@ +# 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, + # 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 + traefik.http.services.gitlab-mattermost.loadbalancer.server.port: 8065 diff --git a/compose.registry.yml b/compose.registry.yml new file mode 100644 index 0000000..dbacd0c --- /dev/null +++ b/compose.registry.yml @@ -0,0 +1,27 @@ +# 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, + # 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..24f6941 --- /dev/null +++ b/compose.yml @@ -0,0 +1,88 @@ +# 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' + 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: 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