兴趣所致,使用Docker部署下Redmine和GitLab,体验下Docker的魅力。

一、安装Docker

二、安装Redmie

地址 http://172.20.1.15
账号 admin
密码 admin

三、安装Gitlab

地址 http://172.20.1.16
账号 root
密码 5iveL!fe

集成安装脚本

PS1:安全起见,以下绑定的地址均为本地IP,无法对外提供服务,如需部署到服务器请酌情修改。
PS2:也可以安装 rinetd 软件包,实现任意端口转发。

请下载下面的集成安装脚本,修改password和email参数后,一键安装Redmine/GitLab吧~

#!/bin/bash
#
# Author  Anrip <mail@anrip.com>
# Website http://www.anrip.com/post/1811
# Refs https://github.com/sameersbn/docker-gitlab
# Refs https://github.com/sameersbn/docker-redmine
#

if [ ! `which docker` ]; then
    wget -qO- https://get.docker.com/ | sh
fi

docker network create --subnet=172.20.1.0/24 docker1

docker pull sameersbn/redis:latest
docker pull sameersbn/mysql:latest
docker pull sameersbn/gitlab:latest
docker pull sameersbn/redmine:latest

docker run --name app-redis -d \
    --net docker1 --ip 172.20.1.11 \
    --volume /srv/app-redis:/var/lib/redis \
    sameersbn/redis:latest

docker run --name app-mysql -d \
    --net docker1 --ip 172.20.1.12 \
    --env 'MYSQL_CHARSET=utf8' \
    --env 'MYSQL_COLLATION=utf8_general_ci' \
    --env 'DB_REMOTE_ROOT_NAME=root' \
    --env 'DB_REMOTE_ROOT_PASS=password' \
    --volume /srv/app-mysql:/var/lib/mysql \
    sameersbn/mysql:latest

MYSQL_CHARSET="DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci"
cat > /opt/app-mysql/init.sql <<EOF
    CREATE USER 'gitlab'@'%.%.%.%' IDENTIFIED BY 'password';
    CREATE DATABASE IF NOT EXISTS gitlabhq_production ${MYSQL_CHARSET};
    GRANT ALL PRIVILEGES ON \`gitlabhq_production\`.* TO 'gitlab'@'%.%.%.%';
    CREATE USER 'redmine'@'%.%.%.%' IDENTIFIED BY 'password';
    CREATE DATABASE IF NOT EXISTS redmine_production ${MYSQL_CHARSET};
    GRANT ALL PRIVILEGES ON \`redmine_production\`.* TO 'redmine'@'%.%.%.%';
EOF

sleep 30
docker exec -it app-mysql mysql "-e source /var/lib/mysql/init.sql"
rm -rf /opt/app-mysql/init.sql

docker run --name app-redmine -d \
    --net docker1 --ip 172.20.1.15 \
    --env 'REDMINE_PORT=80' \
    --env 'REDMINE_RELATIVE_URL_ROOT=/redmine' \
    --env 'SMTP_DOMAIN=anrip.com' \
    --env 'SMTP_HOST=smtp.exmail.qq.com' \
    --env 'SMTP_PORT=587' \
    --env 'SMTP_USER=team@anrip.com' \
    --env 'SMTP_PASS=anrip.2010' \
    --env='DB_ADAPTER=mysql2' \
    --env 'DB_HOST=172.20.1.12' \
    --env='DB_NAME=redmine_production' \
    --env 'DB_USER=redmine' \
    --env 'DB_PASS=password' \
    --volume /opt/app-redmine:/home/redmine/data \
    sameersbn/redmine:latest

docker run --name app-gitlab -d \
    --net docker1 --ip 172.20.1.16 \
    --env 'GITLAB_SSH_PORT=22' \
    --env 'GITLAB_PORT=80' \
    --env 'GITLAB_HOST=team.vmlu.com' \
    --env 'GITLAB_RELATIVE_URL_ROOT=/gitlab' \
    --env 'GITLAB_EMAIL=team@anrip.com' \
    --env 'GITLAB_EMAIL_DISPLAY_NAME=Vmlu Team' \
    --env 'GITLAB_SECRETS_DB_KEY_BASE=your-db-key-base' \
    --env 'GITLAB_SECRETS_SECRET_KEY_BASE=your-secert-key-base' \
    --env 'GITLAB_SECRETS_OTP_KEY_BASE=your-opt-key-base' \
    --env 'GITLAB_USERNAME_CHANGE=false' \
    --env 'UNICORN_TIMEOUT=120' \
    --env 'SMTP_DOMAIN=anrip.com' \
    --env 'SMTP_HOST=smtp.exmail.qq.com' \
    --env 'SMTP_PORT=587' \
    --env 'SMTP_USER=your@anrip.com' \
    --env 'SMTP_PASS=your-mail-pasowrd' \
    --env 'REDIS_HOST=172.20.1.11' \
    --env 'REDIS_PORT=6379' \
    --env 'DB_ADAPTER=mysql2' \
    --env 'DB_HOST=172.20.1.12' \
    --env 'DB_NAME=gitlabhq_production' \
    --env 'DB_USER=gitlab' \
    --env 'DB_PASS=password' \
    --volume /opt/app-gitlab:/home/git/data \
    sameersbn/gitlab:latest

#sudo aptitude install -y rinetd
#sudo echo "12.34.56.78 22 172.20.1.16 22" >>/etc/rinetd.conf

标签: ubuntu, shell, linux, docker

添加新评论