install gitaly

This commit is contained in:
timfeirg 2017-06-29 15:38:59 +08:00
parent 0c28126033
commit 793b33c2e5
6 changed files with 65 additions and 3 deletions

View File

@ -7,6 +7,7 @@ ENV GITLAB_VERSION=9.3.0 \
GITLAB_SHELL_VERSION=5.0.5 \
GITLAB_WORKHORSE_VERSION=2.1.1 \
GITLAB_PAGES_VERSION=0.4.3 \
GITALY_SERVER_VERSION=0.11.2 \
GITLAB_USER="git" \
GITLAB_HOME="/home/git" \
GITLAB_LOG_DIR="/var/log/gitlab" \
@ -17,6 +18,7 @@ ENV GITLAB_INSTALL_DIR="${GITLAB_HOME}/gitlab" \
GITLAB_SHELL_INSTALL_DIR="${GITLAB_HOME}/gitlab-shell" \
GITLAB_WORKHORSE_INSTALL_DIR="${GITLAB_HOME}/gitlab-workhorse" \
GITLAB_PAGES_INSTALL_DIR="${GITLAB_HOME}/gitlab-pages" \
GITLAB_GITALY_INSTALL_DIR="${GITLAB_HOME}/gitaly" \
GITLAB_DATA_DIR="${GITLAB_HOME}/data" \
GITLAB_BUILD_DIR="${GITLAB_CACHE_DIR}/build" \
GITLAB_RUNTIME_DIR="${GITLAB_CACHE_DIR}/runtime"

View File

@ -5,6 +5,7 @@ GITLAB_CLONE_URL=https://gitlab.com/gitlab-org/gitlab-ce.git
GITLAB_SHELL_URL=https://gitlab.com/gitlab-org/gitlab-shell/repository/archive.tar.gz
GITLAB_WORKHORSE_URL=https://gitlab.com/gitlab-org/gitlab-workhorse.git
GITLAB_PAGES_URL=https://gitlab.com/gitlab-org/gitlab-pages/repository/archive.tar.gz
GITLAB_GITALY_URL=https://gitlab.com/gitlab-org/gitaly/repository/archive.tar.gz
GEM_CACHE_DIR="${GITLAB_BUILD_DIR}/cache"
@ -105,6 +106,20 @@ cd "$GODIR"
PATH=/tmp/go/bin:$PATH GOROOT=/tmp/go make gitlab-pages
mv gitlab-pages /usr/local/bin/
# download gitaly
echo "Downloading gitaly v.${GITALY_SERVER_VERSION}..."
mkdir -p ${GITLAB_GITALY_INSTALL_DIR}
wget -cq ${GITLAB_GITALY_URL}?ref=v${GITALY_SERVER_VERSION} -O ${GITLAB_BUILD_DIR}/gitaly-${GITALY_SERVER_VERSION}.tar.gz
tar xf ${GITLAB_BUILD_DIR}/gitaly-${GITALY_SERVER_VERSION}.tar.gz --strip 1 -C ${GITLAB_GITALY_INSTALL_DIR}
rm -rf ${GITLAB_BUILD_DIR}/gitaly-${GITALY_SERVER_VERSION}.tar.gz
chown -R ${GITLAB_USER}: ${GITLAB_GITALY_INSTALL_DIR}
# copy default config for gitaly
exec_as_git cp ${GITLAB_GITALY_INSTALL_DIR}/config.toml.example ${GITLAB_GITALY_INSTALL_DIR}/config.toml
# install gitaly
cd ${GITLAB_GITALY_INSTALL_DIR}
PATH=/tmp/go/bin:$PATH GOROOT=/tmp/go make install && make clean
# remove go
rm -rf ${GITLAB_BUILD_DIR}/go${GOLANG_VERSION}.linux-amd64.tar.gz /tmp/go
@ -299,6 +314,20 @@ stdout_logfile=${GITLAB_INSTALL_DIR}/log/%(program_name)s.log
stderr_logfile=${GITLAB_INSTALL_DIR}/log/%(program_name)s.log
EOF
# configure supervisord to start gitaly
cat > /etc/supervisor/conf.d/gitaly.conf <<EOF
[program:gitaly]
priority=5
directory=${GITLAB_GITALY_INSTALL_DIR}
environment=HOME=${GITLAB_HOME}
command=/usr/local/bin/gitaly ${GITLAB_GITALY_INSTALL_DIR}/config.toml
user=git
autostart={{GITALY_ENABLED}}
autorestart=true
stdout_logfile=${GITLAB_LOG_DIR}/supervisor/%(program_name)s.log
stderr_logfile=${GITLAB_LOG_DIR}/supervisor/%(program_name)s.log
EOF
# configure supervisord to start mail_room
cat > /etc/supervisor/conf.d/mail_room.conf <<EOF
[program:mail_room]

View File

@ -0,0 +1,11 @@
# Example Gitaly configuration file
socket_path = "{{GITALY_SOCKET_PATH}}"
# # Optional: listen on a TCP socket. This is insecure (no authentication)
# listen_addr = "localhost:9999"
#
[[storage]]
name = "default"
path = "{{GITLAB_REPOS_DIR}}"

View File

@ -478,7 +478,7 @@ production: &base
# This setting controls whether GitLab uses Gitaly (new component
# introduced in 9.0). Eventually Gitaly use will become mandatory and
# this option will disappear.
enabled: true
enabled: {{GITALY_ENABLED}}
#
# 4. Advanced settings

View File

@ -366,3 +366,8 @@ GITLAB_PAGES_PORT=${GITLAB_PAGES_PORT:-80}
GITLAB_PAGES_HTTPS=${GITLAB_PAGES_HTTPS:-false}
GITLAB_PAGES_EXTERNAL_HTTP=${GITLAB_PAGES_EXTERNAL_HTTP:-}
GITLAB_PAGES_EXTERNAL_HTTPS=${GITLAB_PAGES_EXTERNAL_HTTPS:-}
## Gitaly
GITALY_ENABLED=${GITALY_ENABLED:-true}
GITALY_SOCKET_PATH=${GITLAB_INSTALL_DIR}/tmp/sockets/private/gitaly.socket
GITALY_ADDRESS=${GITALY_ADDRESS:-unix:$GITALY_SOCKET_PATH}

View File

@ -19,6 +19,7 @@ GITLAB_NGINX_CONFIG="/etc/nginx/sites-enabled/gitlab"
GITLAB_CI_NGINX_CONFIG="/etc/nginx/sites-enabled/gitlab_ci"
GITLAB_REGISTRY_NGINX_CONFIG="/etc/nginx/sites-enabled/gitlab-registry"
GITLAB_PAGES_NGINX_CONFIG="/etc/nginx/sites-enabled/gitlab-pages"
GITLAB_GITALY_CONFIG="${GITLAB_GITALY_INSTALL_DIR}/config.toml"
# Compares two version strings `a` and `b`
# Returns
@ -269,6 +270,19 @@ gitlab_configure_redis() {
REDIS_DB_NUMBER
}
gitlab_configure_gitaly() {
echo "Configuring gitlab::gitaly..."
update_template /etc/supervisor/conf.d/gitaly.conf GITALY_ENABLED
update_template ${GITLAB_GITALY_CONFIG} \
GITALY_SOCKET_PATH \
GITLAB_REPOS_DIR
if [[ ${GITALY_ENABLED} != true ]]; then
exec_as_git sed -i "/{{GITALY_ADDRESS}}/d" ${GITLAB_CONFIG}
fi
}
gitlab_configure_gitlab_workhorse() {
echo "Configuring gitlab::gitlab-workhorse..."
update_template /etc/supervisor/conf.d/gitlab-workhorse.conf \
@ -498,7 +512,7 @@ gitlab_configure_oauth_authentiq() {
OAUTH_AUTHENTIQ_CLIENT_ID \
OAUTH_AUTHENTIQ_CLIENT_SECRET \
OAUTH_AUTHENTIQ_SCOPE \
OAUTH_AUTHENTIQ_REDIRECT_URI
OAUTH_AUTHENTIQ_REDIRECT_URI
else
exec_as_git sed -i "/name: 'authentiq'/,/{{OAUTH_AUTHENTIQ_SCOPE}}/d" ${GITLAB_CONFIG}
fi
@ -1054,7 +1068,7 @@ nginx_configure_pages(){
else
update_template ${GITLAB_PAGES_NGINX_CONFIG} \
GITLAB_PAGES_DOMAIN \
GITLAB_LOG_DIR
GITLAB_LOG_DIR
fi
fi
}
@ -1369,6 +1383,7 @@ configure_gitlab() {
gitlab_configure_redis
gitlab_configure_secrets
gitlab_configure_sidekiq
gitlab_configure_gitaly
gitlab_configure_gitlab_workhorse
gitlab_configure_relative_url
gitlab_configure_trusted_proxies