返回介绍

PART Ⅰ : 容器云OPENSHIFT

PART Ⅱ:容器云 KUBERNETES

PART Ⅲ:持续集成与持续部署

PART Ⅴ:日志/监控/告警

PART Ⅵ:基础

PART Ⅶ:数据存储、处理

PART VIII:CODE

PART X:HACKINTOSH

PART XI:安全

部署与配置

发布于 2024-06-08 21:16:46 字数 5554 浏览 0 评论 0 收藏 0

1、对接gitlab

  • 生成随机secret

    openssl rand -hex 16
    # 611f45c7*****b715da0cb17c91
    
  • 配置Gitlab

    • 在gitlab的管理中心添加集成应用,获取应用客户端的ID和Secret。权限授予apiread_api

  • docker-compose

    integrated-gitlab-docker-compose.yaml

    drone:
      image: 'drone/drone:2.12.1'
      restart: always
      container_name: drone
      environment:
        TZ: Asia/Shanghai
        # gitlab地址
        DRONE_GITLAB_SERVER: http://192.168.1.7:30000
        DRONE_GITLAB_CLIENT_ID: 876442ae9a*****0cd35a2
        DRONE_GITLAB_CLIENT_SECRET: 053d4a*****1dd3b81bece
        # 指定与runner通信的随机secret
        DRONE_RPC_SECRET: 611f45c7*****b715da0cb17c91
        DRONE_SERVER_HOST: 192.168.1.7:3180
        DRONE_SERVER_PROTO: http
        # 指定gitlab的用户为admin角色
        DRONE_USER_CREATE: username:root,admin:true
      ports:
        - '3180:80'
      volumes:
        - '/data/drone/data:/data'
    runner-ssh:
      image: 'drone/drone-runner-ssh:linux-amd64'
      restart: always
      container_name: drone-runner-ssh
      environment:
        TZ: Asia/Shanghai
        DRONE_RPC_PROTO: http
        DRONE_RPC_HOST: 192.168.1.7:3180
        DRONE_RPC_SECRET: 611f45c7*****b715da0cb17c91
      volumes:
        - '/data/drone/runner-data/ssh:/drone/src'
    runner-docker:
      image: 'drone/drone-runner-docker:1.8.2'
      restart: always
      container_name: drone-runner-docker
      environment:
        TZ: Asia/Shanghai
        DRONE_RPC_PROTO: http
        DRONE_RPC_HOST: 192.168.1.7:3180
        DRONE_RPC_SECRET: 611f45c7*****b715da0cb17c91
        DRONE_RUNNER_CAPACITY: 2
        DRONE_RUNNER_NAME: runner-docekr
      volumes:
        - '/var/run/docker.sock:/var/run/docker.sock'
        - '/data/drone/runner-data/docker:/drone/src'
    
    docker-compose -f integrated-gitlab-docker-compose.yaml up -d
    

参考:https://docs.drone.io/server/provider/gitlab/

2、对接Gogs

  • 生成随机secret

    openssl rand -hex 16
    # 8433b8***d0bf5
    
  • docker-compose

    integrated-gogs-docker-compose.yaml

    drone:
      image: 'drone/drone:2.12.1'
      restart: always
      container_name: drone
      environment:
        TZ: Asia/Shanghai
        DRONE_AGENTS_ENABLED: "true"
        DRONE_GOGS_SERVER: http://192.168.1.7:10880
        DRONE_RPC_SECRET: 8433b8***d0bf5
        DRONE_SERVER_HOST: 192.168.1.7:3180
        DRONE_SERVER_PROTO: http
        DRONE_USER_CREATE: username:root,admin:true
      ports:
        - '3180:80'
      volumes:
        - '/data/drone/integrated-gogs-data:/data'
    runner-ssh:
      image: 'drone/drone-runner-ssh:linux-amd64'
      restart: always
      container_name: drone-runner-ssh
      environment:
        TZ: Asia/Shanghai
        DRONE_RPC_PROTO: http
        DRONE_RPC_HOST: 192.168.1.7:3180
        DRONE_RPC_SECRET: 8433b8***d0bf5
      volumes:
        - '/data/drone/runner-data/ssh:/drone/src'
    runner-docker:
      image: 'drone/drone-runner-docker:1.8.2'
      restart: always
      container_name: drone-runner-docker
      environment:
        TZ: Asia/Shanghai
        DRONE_RPC_PROTO: http
        DRONE_RPC_HOST: 192.168.1.7:3180
        DRONE_RPC_SECRET: 8433b8***d0bf5
        DRONE_RUNNER_CAPACITY: 2
        DRONE_RUNNER_NAME: runner-docekr
      volumes:
        - '/var/run/docker.sock:/var/run/docker.sock'
        - '/data/drone/runner-data/docker:/drone/src'
    

参考:https://docs.drone.io/server/provider/gogs/

---
kind: pipeline
type: docker
name: default

workspace:
  path: /drone/src

steps:
- name: build
  image: golang
  volumes:
  - name: cache
    path: /tmp/cache
  commands:
  - export GOPROXY=https://goproxy.io,direct
  - export GOCACHE=/tmp/cache
  - go build
trigger:
  branch:
  - master

volumes:
- name: cache
  host:
    path: /data/drone/runner-data/docker/go-cache

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文