├── .dockerignore ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md └── build.sh /.dockerignore: -------------------------------------------------------------------------------- 1 | volumes 2 | build.sh 3 | .gitignire 4 | LICENSE 5 | README.md 6 | run.sh -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | volumes 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ##################### 2 | # Building Stage # 3 | ##################### 4 | FROM gitlab/gitlab-ce:11.3.0-ce.0 as builder 5 | 6 | ENV GITLAB_DIR=/opt/gitlab/embedded/service/gitlab-rails 7 | ENV GITLAB_GIT_ZH=https://gitlab.com/xhang/gitlab.git 8 | 9 | # Reference: 10 | # * https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/config/software/gitlab-rails.rb 11 | # * https://gitlab.com/gitlab-org/gitlab-ce/blob/master/.gitlab-ci.yml 12 | RUN set -xe \ 13 | && echo " # Preparing ..." \ 14 | && export DEBIAN_FRONTEND=noninteractive \ 15 | && export SSL_CERT_DIR=/etc/ssl/certs/ \ 16 | && export GIT_SSL_CAPATH=/etc/ssl/certs/ \ 17 | && curl -sL https://deb.nodesource.com/setup_8.x | bash - \ 18 | && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ 19 | && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ 20 | && apt-get update \ 21 | && apt-get install -yqq lsb-release patch nodejs python build-essential yarn cmake 22 | 23 | RUN set -xe \ 24 | && echo " # Generating translation patch ..." \ 25 | && cd /tmp \ 26 | && git clone ${GITLAB_GIT_ZH} gitlab \ 27 | && cd gitlab \ 28 | && export IGNORE_DIRS=':!qa :!spec :!features :!.gitignore :!.gitlab :!locale :!app/assets/ :!vendor/assets/' \ 29 | && git diff --diff-filter=d v11.3.0..v11.3.0-zh -- . ${IGNORE_DIRS} > ../zh_CN.diff \ 30 | && echo " # Patching ..." \ 31 | && patch -d ${GITLAB_DIR} -p1 < ../zh_CN.diff \ 32 | && echo " # Copy assets files ..." \ 33 | && git checkout v11.3.0-zh \ 34 | && cp -R locale ${GITLAB_DIR}/ \ 35 | && mkdir -p ${GITLAB_DIR}/app \ 36 | && cp -R app/assets ${GITLAB_DIR}/app/ \ 37 | && mkdir -p ${GITLAB_DIR}/vendor \ 38 | && cp -R vendor/assets ${GITLAB_DIR}/vendor/ 39 | 40 | RUN set -xe \ 41 | && echo " # Regenerating the assets" \ 42 | && cd ${GITLAB_DIR} \ 43 | && cp config/gitlab.yml.example config/gitlab.yml \ 44 | && cp config/database.yml.postgresql config/database.yml \ 45 | && cp config/secrets.yml.example config/secrets.yml \ 46 | && rm -rf public/assets \ 47 | && export NODE_ENV=production \ 48 | && export RAILS_ENV=production \ 49 | && export SETUP_DB=false \ 50 | && export USE_DB=false \ 51 | && export SKIP_STORAGE_VALIDATION=true \ 52 | && export WEBPACK_REPORT=true \ 53 | && export NO_COMPRESSION=true \ 54 | && export NO_PRIVILEGE_DROP=true \ 55 | && export NODE_OPTIONS=--max-old-space-size=4086 \ 56 | && yarn install --frozen-lockfile \ 57 | && bin/bundle install --frozen \ 58 | && bin/rake gettext:compile \ 59 | && bin/rake gitlab:assets:compile 60 | 61 | RUN set -xe \ 62 | && echo " # Cleaning ..." \ 63 | && yarn cache clean \ 64 | && rm -rf log \ 65 | tmp \ 66 | config/gitlab.yml \ 67 | config/database.yml \ 68 | config/secrets.yml \ 69 | .secret \ 70 | .gitlab_shell_secret \ 71 | .gitlab_workhorse_secret \ 72 | app/assets \ 73 | node_modules \ 74 | && find /usr/lib/ -name __pycache__ | xargs rm -rf \ 75 | && rm -rf /tmp/gitlab /tmp/*.diff /root/.cache /var/lib/apt/lists/* 76 | 77 | 78 | ###################### 79 | # Production Stage # 80 | ###################### 81 | FROM gitlab/gitlab-ce:11.3.0-ce.0 as production 82 | 83 | RUN set -xe \ 84 | && export DEBIAN_FRONTEND=noninteractive \ 85 | && apt-get update \ 86 | && apt-get install -yqq locales tzdata \ 87 | && locale-gen en_US.UTF-8 \ 88 | && rm -rf /var/lib/apt/lists/* 89 | 90 | ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8 91 | ENV TZ=Asia/Shanghai 92 | 93 | ENV GITLAB_VERSION=v11.3.0 94 | ENV GITLAB_DIR=/opt/gitlab/embedded/service/gitlab-rails 95 | ENV GITLAB_GIT_ZH=https://gitlab.com/xhang/gitlab.git 96 | ENV GITLAB_GIT_COMMIT_UPSTREAM=v11.3.0 97 | ENV GITLAB_GIT_COMMIT_ZH=v11.3.0-zh 98 | 99 | COPY --from=builder ${GITLAB_DIR}/app ${GITLAB_DIR}/app 100 | COPY --from=builder ${GITLAB_DIR}/public ${GITLAB_DIR}/public 101 | COPY --from=builder ${GITLAB_DIR}/config/application.rb ${GITLAB_DIR}/config/application.rb 102 | COPY --from=builder ${GITLAB_DIR}/config/initializers ${GITLAB_DIR}/config/initializers 103 | COPY --from=builder ${GITLAB_DIR}/config/locales ${GITLAB_DIR}/config/locales 104 | COPY --from=builder ${GITLAB_DIR}/lib/gitlab ${GITLAB_DIR}/lib/gitlab 105 | COPY --from=builder ${GITLAB_DIR}/locale ${GITLAB_DIR}/locale 106 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 beginor 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 重要声明 2 | 3 | gitlab 官方已经开始支持多语言, 而且也提供了 docker 镜像, 因此这个 docker 镜像不再维护, 请大家切换到官方镜像, 感谢大家的支持。 4 | 5 | > 切换到官方镜像之后, 中文设置方法: 依次点击工具栏最右侧用户头像 》 `Settings` 》 `Preferred language` , 然后选择 `简体中文` 即可。 6 | 7 | # GitLab 中文社区版 Docker 镜像 8 | 9 | 基于 GitLab 官方社区版 Docker 镜像制作的中文 Docker 镜像, 汉化补丁来自网友 [larryli](https://gitlab.com/larryli/gitlab) (8.8.5之前), 后续由网友 [xhang](https://gitlab.com/xhang/gitlab) 维护。 10 | 11 | 由于汉化工作需要大量的人力, 所以中文版的版本会比官方的版本稍低, 如果刻意最求最新版, 请使用官方的 GitLab Docker 镜像。 12 | 13 | 如果发现汉化的问题, 请向 [xhang](https://gitlab.com/xhang/gitlab) 反映。 14 | 15 | ## 获取镜像 16 | 17 | ```sh 18 | docker pull beginor/gitlab-ce:11.3.0-ce.0 19 | ``` 20 | 21 | ## 运行 22 | 23 | 通常会将 GitLab 的配置 (etc) 、 日志 (log) 、数据 (data) 放到容器之外, 便于日后升级, 因此请先准备这三个目录。 24 | 25 | ```sh 26 | sudo mkdir -p /mnt/sda1/gitlab/etc 27 | sudo mkdir -p /mnt/sda1/gitlab/log 28 | sudo mkdir -p /mnt/sda1/gitlab/data 29 | ``` 30 | 准备好这三个目录之后, 就可以开始运行 Docker 镜像了。 我的建议是使用`unless-stopped` 作为重启策略, 因为这样可以手工停止容器, 方便维护。 31 | 32 | 完整的运行命令如下: 33 | 34 | ```sh 35 | docker run \ 36 | --detach \ 37 | --publish 8443:443 \ 38 | --publish 8080:80 \ 39 | --name gitlab \ 40 | --restart unless-stopped \ 41 | --volume /mnt/sda1/gitlab/etc:/etc/gitlab \ 42 | --volume /mnt/sda1/gitlab/log:/var/log/gitlab \ 43 | --volume /mnt/sda1/gitlab/data:/var/opt/gitlab \ 44 | beginor/gitlab-ce:11.3.0-ce.0 45 | ``` 46 | 47 | ## 升级 48 | 49 | 小版本升级(例如从 8.8.2 升级到 8.8.3), 参照官方的说明, 将原来的容器停止, 然后删除: 50 | 51 | ```sh 52 | docker stop gitlab 53 | docker rm gitlab 54 | ``` 55 | 56 | 然后重新拉一个新版本的镜像下来, 57 | 58 | ```sh 59 | docker pull beginor/gitlab-ce:11.3.0-ce.0 60 | ``` 61 | 62 | 还使用原来的运行命令运行, 63 | 64 | ```sh 65 | docker run \ 66 | --detach \ 67 | --publish 8443:443 \ 68 | --publish 8080:80 \ 69 | --name gitlab \ 70 | --restart unless-stopped \ 71 | --volume /mnt/sda1/gitlab/etc:/etc/gitlab \ 72 | --volume /mnt/sda1/gitlab/log:/var/log/gitlab \ 73 | --volume /mnt/sda1/gitlab/data:/var/opt/gitlab \ 74 | beginor/gitlab-ce:11.3.0-ce.0 75 | ``` 76 | 77 | GitLab 在初次运行的时候会自动升级, 为了预防万一, 还是建议先备份一下 `/mnt/sda1/gitlab/` 这个目录。 78 | 79 | 大版本升级(例如从 8.7.x 升级到 8.8.x)用上面的操作有可能会出现错误, 如果出现错误可以尝试登录到容器内部, 可以用 `docker exec` , 也可以用 ssh , 依次执行下面的命令: 80 | 81 | ```sh 82 | gitlab-ctl reconfigure 83 | gitlab-ctl restart 84 | ``` 85 | 86 | ## 更多 87 | 88 | 想知道更多高级的玩法, 请参考这些: 89 | 90 | - The official GitLab Community Edition Docker image is [available on Docker Hub](https://registry.hub.docker.com/u/gitlab/gitlab-ce/). 91 | - The official GitLab Enterprise Edition Docker image is [available on Docker Hub](https://registry.hub.docker.com/u/gitlab/gitlab-ee/). 92 | - The complete usage guide can be found in [Using GitLab Docker images](http://doc.gitlab.com/omnibus/docker/). 93 | - The Dockerfile used for building public images is in [Omnibus Repository](https://gitlab.com/gitlab-org/omnibus-gitlab/tree/master/docker). 94 | - Check the guide for [creating Omnibus-based Docker Image](http://doc.gitlab.com/omnibus/build/README.html#Build-Docker-image). 95 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | docker build --no-cache --rm -t beginor/gitlab-ce:11.3.0-ce.0 . 4 | --------------------------------------------------------------------------------