GitLab学习笔记
安装
条件
- Docker
- Docker-compose
- 内存至少分配4GB
通过docker-compose.yml来安装启动,注意wdm.life是我的域名我在本机上加了自定义域名解析。使用IP容易出错,127.0.0.1可更改为你的IP。
mac 下添加本域名解析方式,添加一行 127.0.0.1 wdm.life
$ vim /etc/hosts
#添加一行 127.0.0.1 wdm.life
version: '3.0'
services:
redis:
restart: always
image: redis:6.0.5
container_name: gitlab-redis
command:
- --loglevel warning
networks:
- gitlab_net
volumes:
- "~/docker/gitlab/redis:/var/lib/redis"
postgresql:
restart: always
image: postgres:12.3
container_name: gitlab-postgresql
volumes:
- "~/docker/gitlab/postgresql_data:/var/lib/postgresql"
networks:
- gitlab_net
environment:
- DB_NAME=gitlabhq_production
- DB_USER=gitlab
- DB_PASS=password
- DB_EXTENSION=pg_trgm
- POSTGRES_HOST_AUTH_METHOD=trust
gitlab:
image: gitlab/gitlab-ce:13.0.6-ce.0
restart: always
hostname: wdm.life
container_name: "devops-gitlab"
depends_on:
- redis
- postgresql
ports:
- "80:80"
- "443:443"
- "22:222"
environment:
- DB_ADAPTER=postgresql
- DB_ENCODING=utf8
- DB_HOST=wdm.life
- DB_PORT=5432
- DB_NAME=gitlabhq_production
- DB_USER=gitlab
- DB_PASS=password
- DB_POOL=10
- REDIS_HOST=wdm.life
- REDIS_PORT=6379
- REDIS_DB_NUMBER=0
- DEBUG=false
- GITLAB_HOST=wdm.life
- GITLAB_PORT=80
# ssh端口号22
- GITLAB_SSH_PORT=22
# 监听端口默认22
- GITLAB_SSH_LISTEN_PORT=22
# GitLab服务器的相对网址
- GITLAB_RELATIVE_URL_ROOT=
# 是否支持https 默认为false
- GITLAB_HTTPS=false
# 主题
- GITLAB_DEFAULT_THEME=7
# 首次运行 启用或禁用注册 true
- GITLAB_SIGNUP_ENABLED=false
# 启用或禁用Gitlab的支持
- GITLAB_ARTIFACTS_ENABLED=false
# 设置自动备份时间 04:00
- GITLAB_BACKUP_TIME=22:00
# 备份保留时间 默认7天9604800s)后过期 0为永久保存
- GITLAB_BACKUP_EXPIRY=
# 备份方式 daily weekly monthly disable
- GITLAB_BACKUP_SCHEDULE=weekly
# 加密信息
- GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alphanumeric-string
- GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alphanumeric-string
- GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alphanumeric-string
# 时区
- GITLAB_TIMEZONE=Asia/Shanghai
# root 首次登录用户配置信息
- GITLAB_ROOT_PASSWORD=test123.
# 设置GitLab页面外部http以在独立端口上接收请求。默认禁用
- GITLAB_PAGES_EXTERNAL_HTTP=http://wdm.life
# 设置GitLab页面外部https以在独立端口上接收请求。默认禁用
- GITLAB_PAGES_ACCESS_CONTROL_SERVER=https://wdm.life
volumes:
- "~/docker/gitlab/gitlab/data:/home/git/data"
networks:
- gitlab_net
runner:
image: gitlab/gitlab-runner:v13.0.1
container_name: "gitlab-runner"
restart: always
volumes:
- "~/docker/gitlab_runner/config:/etc/gitlab-runner"
- "~/docker/gitlab_runner/var/run/docker.sock:/var/run/docker.sock"
networks:
- gitlab_net
extra_hosts:
- "wdm.life:127.0.0.1"
networks:
gitlab_net:
备注:在mac通过这个方式来添加docker网络连接可能会失败。可执行以下命令来解决
$ docker network create gitlab_net