我想在服务器上用 Docker
部署 Gitlab + CI/CD
,我想用一个 docker-compose
把配置全写好.
Github
上看了不少,也做了不少尝试,但水平有限,希望各位指点下,也可以加bnpiZXRh
,一起趟坑.
我的 runner 是不是不应该写在这里, 因为可能会有好几个.
多谢.
version: '3'
services:
gitlab:
image: gitlab/gitlab-ce
restart: always
container_name: gitlab-ce
hostname: "${SERVER_IP}"
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url "http://${SERVER_IP}:9001"
gitlab_rails['time_zone'] = 'Pacific/Auckland'
gitlab_rails['gitlab_shell_ssh_port'] = 9002
letsencrypt['enable'] = false
# Configure headers for outgoing email.
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'no-reply@${SERVER_IP}'
gitlab_rails['gitlab_email_display_name'] = 'GitLab'
gitlab_rails['gitlab_email_reply_to'] = 'no-reply@${SERVER_IP}'
# Send outgoing email via the SMTP container:
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "mail"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_tls'] = false
# Limit backup lifetime to 7 days (604800 seconds):
# gitlab_rails['backup_keep_time'] = 604800
# GitLab Pages
pages_external_url "http://${SERVER_IP}:9005"
ports:
# - '9003:80'
# - '9004:443'
- '9001:9090'
- '9002:22'
volumes:
- ./volumes/config:/etc/gitlab
- ./volumes/logs:/var/log/gitlab
- ./volumes/data:/var/opt/gitlab
depends_on:
- redis
- postgres
mail:
image: bytemark/smtp
container_name: gitlab-mail
restart: always
runner:
image: gitlab/gitlab-runner
restart: always
container_name: gitlab_runner
environment:
- CI_SERVER_URL=http://${SERVER_IP}:9001/
volumes:
- ./volumes/runner/runner1:/etc/gitlab-runner
- ./volumes/runner/runner1/var/docker.sock:/var/run/docker.sock:rw
postgres:
image: postgres
restart: always
container_name: gitlab_pg
# http://github.com/docker-library/docs/tree/master/postgres#environment-variables
environment:
POSTGRES_USER: gitlab
POSTGRES_PASSWORD: gitlab
POSTGRES_DB: gitlab
volumes:
- ./volumes/postgres:/var/lib/postgresql/data
restart: always
redis:
image: redis
restart: always
container_name: gitlab_redis
command:
- --loglevel warning
volumes:
- ./volumes/postgres:/var/lib/redis
restart: always
1
XSG 2019-07-31 07:19:34 +08:00 via iPhone 1
你就一台机器吗? runner 一般不能跟 server 在一起,跑的任务如果很耗资源就会影响你的 server 服务质量,而且你也说了,可能有很多 runner,server 一定要稳定。
如果真的想用一个配置文件搞定,建议上 swarm,指定各个应用的节点 |
3
des 2019-07-31 08:37:42 +08:00 via Android
不要放一起+1
gitlab 本身就很吃资源的 |
5
cheshire 2019-07-31 09:47:10 +08:00 1
我们把 runner 丢到了 k8s 里
|
6
ETiV 2019-07-31 10:05:02 +08:00 1
官方建议用 gitlab-ee。「不导入 license 跑就可以了,功能跟 CE 一样的」
然后 postgres、redis 都可以不用自己搞,它内建了全套。 这样可以把 GITLAB_OMNIBUS_CONFIG 这一坨放配置放文件里… 然后 external_url 用 http 不带 s 的协议,不会默认启用任何 https 证书类的配置,所以后面的 letsencrypt 其实是可以省略的…… runner 没碰过,我用 TeamCity 的… |
7
0bject OP |
8
XSG 2019-07-31 14:38:18 +08:00 via iPhone
sever 丢到 k8s 集群了,runner 到处都是,不同项目用不同的 runner
|