-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
82 lines (68 loc) · 3.8 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
###################################################
## the final Docker image genshen/gitlab-ce:latest
###################################################
FROM debian:buster-20200908-slim AS gitlab
LABEL maintainer="[email protected]" \
description="gitlab images, which includes necessary gitlab components: gitlab-server, gitaly, gitlab-shell, gitlab-workhorse."
ARG LSB_RELEASE="buster"
ENV GITLAB_USER="git" \
GITLAB_HOME="/home/git" \
GITLAB_CONFIG_DIR="/etc/gitlab" \
GITLAB_DATA_DIR="/gitlab/data" \
GITLAB_PAGES_DATA_DIR="/gitlab/gitlab-pages" \
GITLAB_CACHE_DIR="/tmp/gitlab" \
GITLAB_LOG_DIR="/var/log/gitlab" \
RAILS_ENV=production
# copy ruby with bundle
COPY --chown=root:root --from=gitlab-base-packages-builder /usr/local/ruby /usr/local/ruby/
COPY --chown=root:root --from=gitlab-base-packages-builder /usr/local/git /usr/local/git/
## create a user ans setup env.
# package postgresql-client is not installed.
# libxml2 is needed for db:migrate todo
# zip unzip is used for artifacts extract.
# For libmagic-dev, see https://elementaryos.stackexchange.com/q/4436
# graphicsmagick: for Custom Favicon to work
# libimage-exiftool-perl: remove EXIF data from uploaded images.
RUN adduser --disabled-login --gecos 'GitLab' ${GITLAB_USER} \
&& passwd -d ${GITLAB_USER} \
&& apt-get clean \
&& apt-get update -y && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
sudo nodejs gnupg2 yarn ca-certificates wget openssh-server logrotate curl zip unzip \
libxml2 libpq5 libicu63 libre2-5 libmagic-dev libimage-exiftool-perl graphicsmagick \
&& echo "deb http://apt.postgresql.org/pub/repos/apt ${LSB_RELEASE}-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& apt-get update -y && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y postgresql-client-12 \
&& export PATH=/usr/local/ruby/bin:$PATH \
&& mkdir -p /usr/local/bin /usr/local/include /usr/local/lib /usr/local/libexec /usr/local/share \
&& ln -s /usr/local/ruby/bin/* /usr/local/bin/ \
&& ln -s /usr/local/ruby/include/* /usr/local/include/ \
&& ln -s /usr/local/ruby/lib/* /usr/local/lib/ \
&& ln -s /usr/local/git/bin/* /usr/bin/ \
&& ln -s /usr/local/git/libexec/* /usr/local/libexec/ \
&& ln -s /usr/local/git/share/* /usr/local/share/
# fixme: we use bundler version 1.17.3, not bundler 2, until "BUNDLED WITH" section in
# https://gitlab.com/gitlab-org/gitaly/blob/master/ruby/Gemfile.lock is updated.
## define gitlab components install directories.
ENV GIT_REPOSITORIES_DIR="${GITLAB_HOME}/repositories" \
GITLAB_RUNTIME_DIR="${GITLAB_CACHE_DIR}/runtime" \
GITLAB_DIR="${GITLAB_HOME}/gitlab" \
GITALY_DIR="${GITLAB_HOME}/gitaly" \
GITLAB_SHELL_DIR="${GITLAB_HOME}/gitlab-shell" \
GITLAB_WORKHORSE_DIR="${GITLAB_HOME}/gitlab-workhorse" \
WORKHORSE_LISTEN_NETWORK="tcp"
# note: replace ${GITLAB_USER} as git.
COPY --chown=git:git --from=gitlab-shell-builder ${GITLAB_SHELL_DIR} ${GITLAB_SHELL_DIR}/
COPY --chown=git:git --from=gitlab-builder ${GITLAB_WORKHORSE_DIR} ${GITLAB_WORKHORSE_DIR}/
COPY --chown=git:git --from=gitlab-gitaly-builder ${GITALY_DIR} ${GITALY_DIR}/
COPY --chown=git:git --from=gitlab-builder ${GITLAB_DIR} ${GITLAB_DIR}/
# https://github.com/ochinchina/supervisord
# COPY --from=ochinchina/supervisord:latest /usr/local/bin/supervisord
COPY create.sh entrypoint.sh /usr/local/sbin/
RUN chmod +x /usr/local/sbin/create.sh /usr/local/sbin/entrypoint.sh \
&& bash /usr/local/sbin/create.sh \
&& rm /usr/local/sbin/create.sh
EXPOSE 22/tcp 8181/tcp
VOLUME ["${GITLAB_DATA_DIR}", "${GITLAB_CONFIG_DIR}", "${GITLAB_LOG_DIR}"]
ENTRYPOINT ["/usr/local/sbin/entrypoint.sh"]
CMD ["start"]
## todo: backup schedule