The redmine + svn + apache2 of Docker 应用基于Debian系统部署,经改造后只需要 PULL+Compose后即可正常工作

镜像地址:https://hub.docker.com/r/yfshare/redmine_svn/

The redmine 3.4+svn+apache2 of Docker

基于Docker hub里redmine 3.4(docker pull redmine:3.4)(https://hub.docker.com/_/redmine/ )改造而成。

环境变量

使用到的环境变量有:

  • MYSQL_ROOT_PASSWORD:MYSQL的ROOT密码,需要和REDMINE_DB_PASSWORD变量值一致
  • MYSQL_DATABASE:MYSQL上创建存储redmine的库名
  • SVN_ROOT:存储SVN REPO的父目录
  • SVN_DIR:SVN REPO项目目录,一般放在变量SVN_ROOT下
  • REDMINE_DB_MYSQL:存储REDMINE的MYSQL DOCKER容器名,建议不要修改;如果修改它同时也需要修改docker-compose
  • REDMINE_DB_PASSWORD:REDMINE连接MYSQL Docker的密码,REDMINE_DB_PASSWORD需要和MYSQL_ROOT_PASSWORD密码一致
  • REDMINE_DB_ENCODING:新建MYSQL库REDMINE的字符集
  • REDMINE_MAIL_ADDRESS:发送REDMINE的邮件地址(configuration.yml)
  • REDMINE_MAIL_DOMAIN:发送REDMINE的邮件域名(configuration.yml)
  • REDMINE_MAIL_USER:发送REDMINE的邮件用户名(configuration.yml)
  • REDMINE_MAIL_PASSWD:发送REDMINE的邮件密码(configuration.yml)
  • 以上变量是在Dockerfile自定义的,如需要其他变量,请参考(https://hub.docker.com/_/redmine/ ) ,因调用的redmine:3.4,因此也支持它的变量

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
# cat Dockerfile
FROM docker.io/redmine:3.4
RUN apt-get update \
&& apt-get install -y subversion subversion-tools apache2 libapache2-svn apache2-utils vim \
&& useradd apache
RUN echo '' >/tmp/main
COPY configure /
VOLUME /usr/src/redmine/files
RUN echo "[ ! -d \${SVN_DIR} ] && svnadmin create \${SVN_DIR}" >>/tmp/redmine_svn.sh \
&& echo "[ -d /Authconf ] && mv /Authconf \${SVN_ROOT}/ && sed -i \"s#^password-db \= passwd#password-db \= \${SVN_ROOT}\/Authconf\/passwd#g\" \${SVN_ROOT}/Authconf/svnserve.conf && sed -i \"s#^authz-db \= authz#authz-db \= \${SVN_ROOT}\/Authconf\/authz#g\" \${SVN_ROOT}/Authconf/svnserve.conf && \mv \${SVN_ROOT}/Authconf/svnserve.conf \${SVN_DIR}/conf/" >> /tmp/redmine_svn.sh \
&& echo "[ -f /dav_svn.conf ] && mv /dav_svn.conf /etc/apache2/mods-enabled/ && sed -i \"s#SVNPath SVN_DIR#SVNPath \${SVN_DIR}#g\" /etc/apache2/mods-enabled/dav_svn.conf && sed -i \"s#Location \/svn#Location \/\`echo \${SVN_DIR} | awk -F '/' '{print \$NF}'\`#g\" /etc/apache2/mods-enabled/dav_svn.conf && sed -i \"/Include the virtual host configurations/aServerName localhost\:80\" /etc/apache2/apache2.conf" >> /tmp/redmine_svn.sh \
&& echo "[ -f /svnpass ] && mv /svnpass /etc/apache2/.svnpass" >> /tmp/redmine_svn.sh \
&& echo "[ -f /dav_svn.authz ]&& mv /dav_svn.authz /etc/apache2/ && sed -i \"s#SVN_DIR#\`echo \${SVN_DIR} | awk -F '/' '{print \$NF}'\`#g\" /etc/apache2/dav_svn.authz" >> /tmp/redmine_svn.sh \
&& echo "[ -f /configuration.yml ] && \mv /configuration.yml /usr/src/redmine/config && sed -i \"s#domain\: 'DOMAIN'#domain\: '\${REDMINE_MAIL_DOMAIN}'#g\" /usr/src/redmine/config/configuration.yml && sed -i \"s#address\: \\\"MAIL_ADDRESS\\\"#address\: \\\"\${REDMINE_MAIL_ADDRESS}\\\"#g\" /usr/src/redmine/config/configuration.yml && sed -i \"s#user_name\: 'MAILADDR'#user_name\: '\${REDMINE_MAIL_USER}'#g\" /usr/src/redmine/config/configuration.yml && sed -i \"s#password\: 'PASSWORD'#password\: '\${REDMINE_MAIL_PASSWD}'#g\" /usr/src/redmine/config/configuration.yml" >> /tmp/redmine_svn.sh \
&& echo "chown apache:apache \${SVN_ROOT} -R && chown apache:apache /etc/apache2 -R" >> /tmp/redmine_svn.sh \
&& echo "/etc/init.d/apache2 start &" >> /tmp/redmine_svn.sh \
&& echo "svnserve -d -r \${SVN_ROOT} --log-file \${SVN_ROOT}/svn.log &" >>/tmp/redmine_svn.sh \
&& echo "sleep 5 && /docker-entrypoint.sh rails server -b 0.0.0.0 &" >>/tmp/redmine_svn.sh \
&& echo "tail -f /tmp/main" >>/tmp/redmine_svn.sh \
&& chmod +x /tmp/redmine_svn.sh
EXPOSE 3000 3690 80
ENTRYPOINT ["/bin/sh","/tmp/redmine_svn.sh"]
#

Docker Compose

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
version: '2'
services:
db:
image: mysql:5.7
container_name: mysql
environment:
MYSQL_ROOT_PASSWORD: 'example12'
MYSQL_DATABASE: redmine
ports:
- 3306:3306
volumes:
- /data/docker_mount/mysql:/var/lib/mysql
restart: always
redmine_svn:
image: yfshare/redmine_svn:3.4
container_name: redmine_svn
ports:
- 3000:3000
- 3690:3690
- 80:80
links:
- db
environment:
SVN_ROOT: '/usr/src/SvnRepos'
SVN_DIR: '/usr/src/SvnRepos/Soros'
REDMINE_DB_MYSQL: db
REDMINE_DB_PASSWORD: 'example12'
REDMINE_DB_ENCODING: 'utf8'
REDMINE_MAIL_ADDRESS: 'smtp.exmail.qq.com'
REDMINE_MAIL_DOMAIN: 'example.com'
REDMINE_MAIL_USER: 'username'
REDMINE_MAIL_PASSWD: 'password'
volumes:
- /data/docker_mount/redmine/files:/usr/src/redmine/files
- /data/docker_mount/SvnRepos:/usr/src/SvnRepos
restart: always

部署Docker

1
2
docker pull yfshare/redmine_svn
docker-compose -f docker-redmine_svn_mysql.yml up -d

Q&A

  • 在redmine载入默认配置时,请选择“English“,而不是”简体中文“ 否则报下面错误

    1
    无法载入默认设置:Mysql2::Error: Incorrect string value: '\xE7\xAE\xA1\xE7\x90\x86...' for column 'name' at row 1: INSERT INTO `roles` (`name`, `issues_visibility`, `position`) VALUES ('管理人员', 'all', 1)
  • redmine默认用户名密码为:admin / admin

  • TortoiseSVN访问SVN默认用户名密码为:svnadmin / administrator#!001
  • http访问SVN默认用户名密码为:svnadmin / administrator#!001

The redmine latest+svn+apache2 of Docker

不同点

  • 其他与The redmine 3.4+svn+apache2 of Docker相同,不同的是在build时取消了FROM docker.io/redmine版本号,此时会拉取最新的版本,同时docker-compose也要去掉版本号即可

Docker Compose

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
version: '2'
services:
db:
image: mysql
container_name: mysql
environment:
MYSQL_ROOT_PASSWORD: 'example12'
MYSQL_DATABASE: redmine
ports:
- 3306:3306
volumes:
- /data/docker_mount/mysql:/var/lib/mysql
restart: always
redmine_svn:
image: yfshare/redmine_svn
container_name: redmine_svn
ports:
- 3000:3000
- 3690:3690
- 80:80
links:
- db
environment:
SVN_ROOT: '/usr/src/SvnRepos'
SVN_DIR: '/usr/src/SvnRepos/Soros'
REDMINE_DB_MYSQL: db
REDMINE_DB_PASSWORD: 'example12'
REDMINE_DB_ENCODING: 'utf8'
REDMINE_MAIL_ADDRESS: 'smtp.exmail.qq.com'
REDMINE_MAIL_DOMAIN: 'example.com'
REDMINE_MAIL_USER: 'username'
REDMINE_MAIL_PASSWD: 'password'
volumes:
- /data/docker_mount/redmine/files:/usr/src/redmine/files
- /data/docker_mount/SvnRepos:/usr/src/SvnRepos
restart: always

使用

1
2
3
4
5
6
7
8
#编译Dockerfile生成Docker images
docker build -t yfshare/redmine_svn -f Dockerfile .
#拉取镜像
docker pull yfshare/redmine_svn
#使用docker-compose 生成docker容器
docker-compose -f docker-redmine_svn_mysql.yml up -d

然后

  • 通过 http://localhost:3000访问Redmine
  • http://localhost/SvnRepos通过WEB界面访问SVN
  • 通过 TortoiseSVN svn://localhost:3690/SvnRepos 访问SVN
  • 通过3306端口访问mysql

本文出自”Jack Wang Blog”:http://www.yfshare.vip/2017/12/14/The-Redmine-svn-of-docker/