-
Notifications
You must be signed in to change notification settings - Fork 175
/
Dockerfile
105 lines (94 loc) · 3.98 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#####################
# Building Stage #
#####################
FROM gitlab/gitlab-ce:10.6.6-ce.0 as builder
ENV GITLAB_DIR=/opt/gitlab/embedded/service/gitlab-rails
ENV GITLAB_GIT_ZH=https://gitlab.com/xhang/gitlab.git
# Reference:
# * https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/config/software/gitlab-rails.rb
# * https://gitlab.com/gitlab-org/gitlab-ce/blob/master/.gitlab-ci.yml
RUN set -xe \
&& echo " # Preparing ..." \
&& export DEBIAN_FRONTEND=noninteractive \
&& export SSL_CERT_DIR=/etc/ssl/certs/ \
&& export GIT_SSL_CAPATH=/etc/ssl/certs/ \
&& curl -sL https://deb.nodesource.com/setup_8.x | bash - \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get update \
&& apt-get install -yqq lsb-release patch nodejs python build-essential yarn cmake
RUN set -xe \
&& echo " # Generating translation patch ..." \
&& cd /tmp \
&& git clone ${GITLAB_GIT_ZH} gitlab \
&& cd gitlab \
&& export IGNORE_DIRS=':!qa :!spec :!features :!.gitignore :!.gitlab :!locale :!app/assets/ :!vendor/assets/' \
&& git diff --diff-filter=d v10.6.6..v10.6.6-zh -- . ${IGNORE_DIRS} > ../zh_CN.diff \
&& echo " # Patching ..." \
&& patch -d ${GITLAB_DIR} -p1 < ../zh_CN.diff \
&& echo " # Copy assets files ..." \
&& git checkout v10.6.6-zh \
&& cp -R locale ${GITLAB_DIR}/ \
&& mkdir -p ${GITLAB_DIR}/app \
&& cp -R app/assets ${GITLAB_DIR}/app/ \
&& mkdir -p ${GITLAB_DIR}/vendor \
&& cp -R vendor/assets ${GITLAB_DIR}/vendor/
RUN set -xe \
&& echo " # Regenerating the assets" \
&& cd ${GITLAB_DIR} \
&& cp config/gitlab.yml.example config/gitlab.yml \
&& cp config/database.yml.postgresql config/database.yml \
&& cp config/secrets.yml.example config/secrets.yml \
&& rm -rf public/assets \
&& export NODE_ENV=production \
&& export RAILS_ENV=production \
&& export SETUP_DB=false \
&& export USE_DB=false \
&& export SKIP_STORAGE_VALIDATION=true \
&& export WEBPACK_REPORT=true \
&& export NO_COMPRESSION=true \
&& export NO_PRIVILEGE_DROP=true \
&& export NODE_OPTIONS=--max-old-space-size=4086 \
&& yarn install --frozen-lockfile \
&& bin/bundle install --frozen \
&& bin/rake gettext:compile \
&& bin/rake gitlab:assets:compile
RUN set -xe \
&& echo " # Cleaning ..." \
&& yarn cache clean \
&& rm -rf log \
tmp \
config/gitlab.yml \
config/database.yml \
config/secrets.yml \
.secret \
.gitlab_shell_secret \
.gitlab_workhorse_secret \
app/assets \
node_modules \
&& find /usr/lib/ -name __pycache__ | xargs rm -rf \
&& rm -rf /tmp/gitlab /tmp/*.diff /root/.cache /var/lib/apt/lists/*
######################
# Production Stage #
######################
FROM gitlab/gitlab-ce:10.6.6-ce.0 as production
RUN set -xe \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -yqq locales tzdata \
&& locale-gen en_US.UTF-8 \
&& rm -rf /var/lib/apt/lists/*
ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
ENV TZ=Asia/Shanghai
ENV GITLAB_VERSION=v10.6.6
ENV GITLAB_DIR=/opt/gitlab/embedded/service/gitlab-rails
ENV GITLAB_GIT_ZH=https://gitlab.com/xhang/gitlab.git
ENV GITLAB_GIT_COMMIT_UPSTREAM=v10.6.6
ENV GITLAB_GIT_COMMIT_ZH=v10.6.6-zh
COPY --from=builder ${GITLAB_DIR}/app ${GITLAB_DIR}/app
COPY --from=builder ${GITLAB_DIR}/public ${GITLAB_DIR}/public
COPY --from=builder ${GITLAB_DIR}/config/application.rb ${GITLAB_DIR}/config/application.rb
COPY --from=builder ${GITLAB_DIR}/config/initializers ${GITLAB_DIR}/config/initializers
COPY --from=builder ${GITLAB_DIR}/config/locales ${GITLAB_DIR}/config/locales
COPY --from=builder ${GITLAB_DIR}/lib/gitlab ${GITLAB_DIR}/lib/gitlab
COPY --from=builder ${GITLAB_DIR}/locale ${GITLAB_DIR}/locale