首页 公告 项目 RSS

树莓派上编译gitlab docker镜像

March 23, 2020 本文有 784 个字 需要花费 2 分钟阅读

简介

因为有了四块4g内存的树莓派4b,所以就想把自己的代码仓库从gogs换成gitlab,但是gitlab是没有arm镜像的,所以又要自己编译了,我使用的ci工具还是drone

编译镜像

首先clone代码仓库

git clone https://gitlab.com/gitlab-org/omnibus-gitlab.git

网速会有点慢,幸好家里的路由器可以设置fq

之后进入dockerfile所在的文件夹

cd omnibus-gitlab/docker

直接基于这个目录建立一个git仓库,然后新建drone的ci配置文件

vim .drone.yml

---
kind: pipeline
type: docker
name: gitlab


platform:
  os: linux
  arch: arm


steps:
- name: docker
  image: plugins/docker
  settings:
    repo: 10.10.100.12:5000/gitlab
    tags:
      - latest
      - '12.9.0-ce.0-rpi'
    insecure: true
    registry: 10.10.100.12:5000
    custom_dns: 114.114.114.114
...

接着新建release文件,关于这个release文件是这样的,因为第一次build的时候在Dockerfile中COPY RELEASE /这一步就构建失败了,但是翻了翻文档,也没有找到这个文件是干什么用的,知道后来看到了这个

https://gitlab.com/gitlab-org/omnibus-gitlab/-/blob/7884e0d4f5c828217afc09d37898bb1883185b83/doc/build/README.md

# Build with stable packagecloud packages
# This will build gitlab-ee (8.0.2-ee.1) using STABLE repo and tag it as gitlab-ee:latest
make docker_build RELEASE_VERSION=8.0.2-ee.1 PACKAGECLOUD_REPO=gitlab-ee RELEASE_PACKAGE=gitlab-ee

# Build with unstable packagecloud packages
# This will build gitlab-ce (8.0.2-ce.1) using UNSTABLE repo and tag it as gitlab-ce:latest
make docker_build RELEASE_VERSION=8.0.2-ce.1 PACKAGECLOUD_REPO=unstable RELEASE_PACKAGE=gitlab-ce

这才意识到可能是存储变量用的,于是就新建一个RELEASE文件然后添加变量进去

RELEASE_VERSION=12.9.0-ce.0
PACKAGECLOUD_REPO=unstable
RELEASE_PACKAGE=gitlab-ce

继续编译,然后又失败,这次是在assets/download-package这里卡住了,原来还需要定义deb包下载地址的变量,于是找了下deb包的地址,在RELEASE文件里添加

DOWNLOAD_URL=https://packages.gitlab.com/gitlab/raspberry-pi2/packages/raspbian/stretch/gitlab-ce_12.9.0-ce.0_armhf.deb/download.deb

并且修改assets/download-package

#!/bin/bash

#if [[ ${DOWNLOAD_URL} == *"amazonaws"* ]]; then
#    echo "Downloading package from Amazon bucket - ${DOWNLOAD_URL}"
#    wget --quiet ${DOWNLOAD_URL} -O /tmp/gitlab.deb
#else
#    echo "Downloading package as artifact - ${DOWNLOAD_URL}"
#    # If we are fetching the package which is available as an artifact, we need
#    # to authenticate to access it. Hence, we pass PRIVATE-TOKEN header.
#    wget --quiet --header "PRIVATE-TOKEN: ${TRIGGER_PRIVATE_TOKEN}" ${DOWNLOAD_URL} -O /tmp/gitlab.deb
#fi


wget --content-disposition --quiet ${DOWNLOAD_URL} -O /tmp/gitlab.deb

最后一个问题,就是当gitlab第一次启动的时候,因为树莓派性能的缘故,所以第一次启动会很慢,这个时候当容器启动时间超过容器的健康检查的时间,容器会自动退出,这里我是直接去掉了健康检查,你可以把时间加得长一点

HEALTHCHECK --interval=60s --timeout=30s --retries=10

最后提交仓库编译就成功了

下面是dockerhub中我编译好的镜像地址

https://hub.docker.com/r/bboysoul/gitlab

有需要的可以拿走

欢迎关注我的博客www.bboy.app

Have Fun