晴天的Vlog

晴天的Vlog

Docker部署Gitlab

36
2024-11-09
Docker部署Gitlab

1. 创建docker-compose.yaml文件

touch docker-compose.yaml

2. 配置GItlab

打开docker-compose.yaml文件把内容复制进去按需改动,如不需要第三方登录可以去掉

services:
  gitlab:
    container_name: gitlab
    restart: always
    image: gitlab/gitlab-ee
    hostname: gitlab.weqtian.com
    environment:
      GITLAB_OMNIBUS_CONFIG: | 
        external_url 'https://gitlab.weqtian.com'
        registry_external_url 'https://registry.weqtian.com'
        gitlab_rails['gravatar_ssl_url'] = "https://gravatar.weqtian.io/avatar/%{hash}?s=%{size}&d=identicon"
        gitlab_rails['smtp_enable'] = true
        gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
        gitlab_rails['smtp_port'] = 465
        gitlab_rails['smtp_user_name'] = "noreply@weqtian.com"
        gitlab_rails['smtp_password'] = "xxxx"
        gitlab_rails['smtp_authentication'] = "login"
        gitlab_rails['smtp_enable_starttls_auto'] = false
        gitlab_rails['smtp_tls'] = true
        gitlab_rails['gitlab_email_from'] = 'noreply@weqtian.com'
        gitlab_rails['smtp_domain'] = "exmail.qq.com"
        gitlab_rails['omniauth_providers'] = [
          {
              name: "github",
              # label: "Provider name", # optional label for login button, defaults to "GitHub"
              app_id: "xxx",
              app_secret: "xxx",
              args: { scope: "user:email" }
          },
          {
              name: "google_oauth2",
              # label: "Provider name", # optional label for login button, defaults to "Google"
              app_id: "xxx",
              app_secret: "xxx",
              args: { access_type: "offline", approval_prompt: "" }
          }
        ]
    ports:
      - "443:443"
      - "80:80"
      - "22:22"
    volumes:
      - ./config:/etc/gitlab
      - ./logs:/var/log/gitlab
      - ./data:/var/opt/gitlab

3. 启动GItlab

启动

docker compose up -d 

停止

docker compose up down

更新

docker compose pull

docker compose down

docker compose up -d