├── gitbucket
├── backups
│ └── .gitkeep
├── gitbucket
│ ├── war
│ │ └── .gitkeep
│ ├── Dockerfile
│ ├── war_download.sh
│ └── docker-entrypoint.sh
├── logs
│ ├── gitbucket
│ │ └── .gitkeep
│ └── nginx
│ │ └── .gitkeep
├── storage
│ ├── mysql
│ │ └── data
│ │ │ └── .gitkeep
│ └── gitbucket
│ │ └── data
│ │ ├── .gitkeep
│ │ └── config
│ │ └── logback-settings.xml
├── mysql
│ ├── Dockerfile
│ └── config
│ │ └── etc
│ │ └── conf.d
│ │ └── mysql_custom.cnf
├── nginx
│ ├── Dockerfile
│ └── config
│ │ └── nginx.conf
├── backup.sh
└── docker-compose.yml
├── .gitignore
├── doc
├── img
│ ├── export.png
│ └── overview.png
└── overview.pptx
└── README.md
/gitbucket/backups/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/gitbucket/gitbucket/war/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/gitbucket/logs/gitbucket/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/gitbucket/logs/nginx/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/gitbucket/storage/mysql/data/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/gitbucket/storage/gitbucket/data/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/gitbucket/mysql/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM mysql:8.0.28
2 |
--------------------------------------------------------------------------------
/gitbucket/nginx/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM nginx:1.21.6
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.war
2 | */logs/*
3 | */storage/*
4 | */sslkeys/*
5 |
--------------------------------------------------------------------------------
/doc/img/export.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yoshinorin/docker-gitbucket-orchestration/HEAD/doc/img/export.png
--------------------------------------------------------------------------------
/doc/overview.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yoshinorin/docker-gitbucket-orchestration/HEAD/doc/overview.pptx
--------------------------------------------------------------------------------
/doc/img/overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yoshinorin/docker-gitbucket-orchestration/HEAD/doc/img/overview.png
--------------------------------------------------------------------------------
/gitbucket/mysql/config/etc/conf.d/mysql_custom.cnf:
--------------------------------------------------------------------------------
1 | [mysqld]
2 | default_authentication_plugin = mysql_native_password
3 | character-set-server = utf8mb4
4 | default_password_lifetime = 0
5 | init-connect='SET NAMES utf8mb4'
6 | collation-server = utf8mb4_general_ci
7 |
8 | [client]
9 | default-character-set = utf8mb4
10 |
--------------------------------------------------------------------------------
/gitbucket/gitbucket/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM eclipse-temurin:17.0.2_8-jre-focal
2 |
3 | RUN mkdir -p /usr/opt/gitbucket
4 |
5 | WORKDIR /usr/opt/gitbucket
6 | COPY docker-entrypoint.sh /usr/opt/gitbucket
7 | COPY /war/gitbucket.war /usr/opt/gitbucket
8 |
9 | RUN chmod +x /usr/opt/gitbucket/docker-entrypoint.sh \
10 | && ln -s /gitbucket /root/.gitbucket \
11 | && apt-get update -y \
12 | && apt-get install mysql-client -y
13 |
14 | ENTRYPOINT "/usr/opt/gitbucket/docker-entrypoint.sh"
15 |
--------------------------------------------------------------------------------
/gitbucket/gitbucket/war_download.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | GITBUCKET_VERSION="4.37.2"
4 | SHA256_CHECKSUM="b6245065c504a6bd2135a76d0fb0e2495d9d2b4221879491b0bafb960df02cdc"
5 |
6 | echo "[INFO] warfile downloading..."
7 |
8 | cd $(dirname $0)
9 | echo pwd
10 |
11 | wget https://github.com/gitbucket/gitbucket/releases/download/${GITBUCKET_VERSION}/gitbucket.war
12 |
13 | line=`sha256sum gitbucket.war`
14 | set -f
15 | set -- $line
16 |
17 | if [ $SHA256_CHECKSUM = $1 ];then
18 | mv -f gitbucket.war ./war/
19 | else
20 | echo "[WARN] Doesn't match the check sum."
21 | fi
22 |
23 | echo "[INFO] Finish."
24 |
--------------------------------------------------------------------------------
/gitbucket/gitbucket/docker-entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set +e
3 |
4 | cat > /gitbucket/database.conf <<-EOCONF
5 | db {
6 | url = "$MYSQL_URL"
7 | user = "$MYSQL_USER"
8 | password = "$MYSQL_PASSWORD"
9 | }
10 | EOCONF
11 |
12 | if [ -n "$MYSQL_USER" ]; then
13 | echo `date '+%Y/%m/%d %H:%M:%S'` $0 "[INFO] Connection confriming..."
14 | while :
15 | do
16 | result=`/usr/bin/mysqladmin ping -h gb-mysql -u${MYSQL_USER} -p${MYSQL_PASSWORD}`
17 | echo $result;
18 | if echo $result|grep 'alive'; then
19 | break
20 | fi
21 | sleep 3;
22 | done
23 | fi
24 |
25 | if [ "$LOGGING" = 1 ]; then
26 | exec java -Dlogback.configurationFile=/gitbucket/config/logback-settings.xml -jar /usr/opt/gitbucket/gitbucket.war
27 | else
28 | exec java -jar /usr/opt/gitbucket/gitbucket.war
29 | fi
--------------------------------------------------------------------------------
/gitbucket/backup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | ROOT_DIR_NAME=backups
5 | SUB_DIR_NAME=`date +%Y%m%d`
6 | FILE_PREFIX=`date +%H%M%S`
7 | IMAGE_BASE_NAME=`basename $(pwd) | tr -d "-"`
8 |
9 | echo "[INFO] Start backup."
10 |
11 | if [ ! -d ./${ROOT_DIR_NAME}/${SUB_DIR_NAME} ]; then
12 | mkdir ./${ROOT_DIR_NAME}/${SUB_DIR_NAME}
13 | fi
14 |
15 | sudo docker run --volumes-from gb-mysql-storage -v $(pwd)/${ROOT_DIR_NAME}/${SUB_DIR_NAME}/:/${ROOT_DIR_NAME}/${SUB_DIR_NAME}/ \
16 | ${IMAGE_BASE_NAME}_gb-mysql-storage:latest tar cvf /${ROOT_DIR_NAME}/${SUB_DIR_NAME}/${FILE_PREFIX}_gitbucket_mysql.tar /var/lib/mysql
17 |
18 | sudo docker run --volumes-from gitbucket-storage -v $(pwd)/${ROOT_DIR_NAME}/${SUB_DIR_NAME}/:/${ROOT_DIR_NAME}/${SUB_DIR_NAME}/ \
19 | ${IMAGE_BASE_NAME}_gitbucket-storage:latest tar cvf /${ROOT_DIR_NAME}/${SUB_DIR_NAME}/${FILE_PREFIX}_gitbucket_data.tar /gitbucket
20 |
--------------------------------------------------------------------------------
/gitbucket/storage/gitbucket/data/config/logback-settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | INFO
7 | ACCEPT
8 | DENY
9 |
10 |
11 | ROLLING %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
12 |
13 |
14 |
15 |
16 |
18 | /opt/gitbucket/log/gitbucket.log
19 | false
20 |
21 |
22 | gitbucket-%d{yyyy-MM-dd}.%i.txt
23 |
24 |
25 | 25MB
26 |
27 |
28 |
29 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/gitbucket/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 | services:
3 | gb-nginx:
4 | build: ./nginx
5 | container_name: gb-nginx
6 | volumes:
7 | - ./logs/nginx/:/var/log/nginx/
8 | - ./nginx/config/nginx.conf:/etc/nginx/nginx.conf
9 | #NOTE : TLS key's path for HTTPS
10 | # - :
11 | # - :
12 | networks:
13 | - app_net
14 | hostname: nginx
15 | ports:
16 | - "8080:8080"
17 | - "29418:29418"
18 | depends_on:
19 | - gitbucket
20 | command: ["nginx", "-g", "daemon off;"]
21 | restart: unless-stopped
22 | gb-mysql:
23 | build: ./mysql
24 | container_name: gb-mysql
25 | environment:
26 | MYSQL_ROOT_PASSWORD: mypass
27 | MYSQL_DATABASE: gitbucket
28 | MYSQL_USER: gitbucket
29 | MYSQL_PASSWORD: gitbucket
30 | volumes:
31 | - ./storage/mysql/data:/var/lib/mysql
32 | - ./mysql/config/etc/conf.d/mysql_custom.cnf:/etc/mysql/conf.d/mysql_custom.cnf
33 | networks:
34 | - app_net
35 | hostname: gb-mysql
36 | expose:
37 | - "3306"
38 | command: ["mysqld"]
39 | restart: unless-stopped
40 | gitbucket:
41 | build: ./gitbucket
42 | container_name: gitbucket
43 | environment:
44 | MYSQL_USER: gitbucket
45 | MYSQL_PASSWORD: gitbucket
46 | MYSQL_URL: jdbc:mysql://gb-mysql:3306/gitbucket?useUnicode=true&characterEncoding=utf8
47 | LOGGING: 0
48 | networks:
49 | - app_net
50 | hostname: gitbucket
51 | expose:
52 | - "8080"
53 | - "29418"
54 | volumes:
55 | - ./storage/gitbucket/data:/gitbucket
56 | - ./logs/gitbucket/:/opt/gitbucket/log
57 | restart: unless-stopped
58 | networks:
59 | app_net:
60 | driver: bridge
61 |
--------------------------------------------------------------------------------
/gitbucket/nginx/config/nginx.conf:
--------------------------------------------------------------------------------
1 | user nginx;
2 | worker_processes auto;
3 | pid /var/run/nginx.pid;
4 |
5 | events {
6 | worker_connections 1024;
7 | accept_mutex_delay 100ms;
8 | use epoll;
9 | }
10 |
11 | http {
12 | server_tokens off;
13 | include mime.types;
14 | default_type application/octet-stream;
15 | #Please change below settings according to your repository size.
16 | #client_max_body_size xxM;
17 |
18 | log_format main '$remote_addr - $remote_user [$time_local] "$request" '
19 | '$status $body_bytes_sent "$http_referer" '
20 | '"$http_user_agent" "$http_x_forwarded_for"';
21 |
22 | access_log /var/log/nginx/access.log;
23 | error_log /var/log/nginx/error.log;
24 |
25 | sendfile on;
26 | tcp_nopush on;
27 |
28 | open_file_cache max=10000 inactive=120s;
29 | open_file_cache_valid 120s;
30 | open_file_cache_min_uses 1;
31 | open_file_cache_errors on;
32 |
33 | keepalive_timeout 65;
34 | gzip on;
35 |
36 | upstream gitbucket{
37 | server gitbucket:8080;
38 | }
39 |
40 | server {
41 | listen 8080;
42 | server_name gitbucket;
43 | proxy_set_header X-Real-IP $remote_addr;
44 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
45 |
46 | #ssl on;
47 | #ssl_protocols TLSv1.2;
48 | #ssl_certificate /etc/nginx/cert.pem;
49 | #ssl_certificate_key /etc/nginx/private.pem;
50 | #charset koi8-r;
51 |
52 | location / {
53 | proxy_pass http://gitbucket;
54 | }
55 |
56 | #error_page 404 /404.html;
57 |
58 | # redirect server error pages to the static page /50x.html
59 | #
60 | error_page 500 502 503 504 /50x.html;
61 | location = /50x.html {
62 | root html;
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # docker-gitbucket-orchestration
2 |
3 | 
4 |
5 | Docker compose for [GitBucket](//github.com/gitbucket/gitbucket).
6 |
7 | [日本語の記事はこちら](//yoshinorin.net/2017/02/26/gitbucket-based-on-nginx-mysql-using-by-docker-compose/)
8 |
9 | # Architecture
10 |
11 | * MySQL
12 | * nginx (Also you can ignore it)
13 |
14 | # Requirements
15 |
16 | * Higher than Docker compose 3
17 |
18 | # Overview
19 |
20 | 
21 |
22 | # Install and execute
23 |
24 | ## Install
25 |
26 | * At first. Download `gitbucket.war` using by `gitbucket/gitbucket/war_download.sh`.
27 |
28 | ## Docker compose up
29 |
30 | Please execute below command on `gitbucket` directory.
31 |
32 | ```sh
33 | docker-compose up -d
34 | ```
35 |
36 | # Settings
37 |
38 | ## MySQL
39 |
40 | ### Character set
41 |
42 | Default character set is utf8mb4.
43 |
44 | ### User and password
45 |
46 | **User and paswword are decided when build docker image.** You can specify user and password using by `docker-compose.yml`.
47 |
48 | ```yml
49 | gb-mysql:
50 | build: ./mysql
51 | container_name: gb-mysql
52 | environment:
53 | MYSQL_ROOT_PASSWORD: mypass
54 | MYSQL_DATABASE: gitbucket
55 | MYSQL_USER: gitbucket
56 | MYSQL_PASSWORD: gitbucket
57 | ```
58 |
59 | You can remove `MYSQL_ROOT_PASSWORD` key in `docker-compose.yml`, after first docker image build.
60 |
61 | If you change `MYSQL_USER` and `MYSQL_DATABASE`. Please change below settings in `docker-compose.yml`.
62 |
63 | ```yml
64 | gitbucket:
65 | build: ./gitbucket
66 | container_name: gitbucket
67 | environment:
68 | MYSQL_USER: gitbucket
69 | MYSQL_PASSWORD: gitbucket
70 | MYSQL_URL: jdbc:mysql://gb-mysql:3306/gitbucket?useUnicode=true&characterEncoding=utf8
71 | ```
72 |
73 | ### Directory connecting
74 |
75 | The default setting you can't connect MySQL directly.
76 | If you want to connect directly, please add below key in `docker-compose.yml`.
77 |
78 | ```yml
79 | gb-mysql:
80 | ports:
81 | - "3306:3306"
82 | ```
83 |
84 | You can connect MySQL directory using by `3306` port. Also you can change port number.
85 |
86 | ### Other config
87 |
88 | Please change `/gitbucket/mysql/config/etc/conf.d/mysql_custom.cnf`
89 |
90 | ## nginx
91 |
92 | Please change `gitbucket/nginx/config/nginx.conf`.
93 | Also you can change it after build image.
94 |
95 | ### Ignore nginx
96 |
97 | If you want ingnore nginx (for example you have already use other webserver.) please commented out nginx key in docker-compose.yml. And add below key in gitbucket key.
98 |
99 | ```
100 | ports:
101 | - "8080:8080"
102 | - "29418:29418"
103 | ```
104 |
105 | ### HTTPS
106 |
107 | You have to change `gitbucket/nginx/config/nginx.conf` and `docker-compose.yml`.
108 |
109 | At first please configure `gitbucket/nginx/config/nginx.conf`.
110 | And change server settings. Below is example.
111 |
112 | ```yml
113 | server {
114 | #NOTE : for TLS connection.
115 | ssl on;
116 | ssl_prefer_server_ciphers on;
117 | ssl_protocols TLSv1.2;
118 | ssl_certificate
119 | ssl_certificate_key
120 | ```
121 |
122 | Next please change `docker-compose.yml`. You have to put key on **host** machine. And mount these keys on nginx container. So you have to specify host key's path and mount volume path in `docker-compose.yml`.
123 |
124 | ```yml
125 | #NOTE : TLS key's path for HTTPS
126 | - :
127 | - :
128 | ```
129 |
130 | ### Upload size
131 |
132 | Please change `client_max_body_size` according to your repository size in `gitbucket/nginx/config/nginx.conf`.
133 |
134 | ```yml
135 | http {
136 | server_tokens off;
137 | include mime.types;
138 | default_type application/octet-stream;
139 | #Please change below settings according to your repository size.
140 | #client_max_body_size xxM;
141 | ```
142 |
143 | # Container's time zone
144 |
145 | If you want to change container's time zone. Please add `TZ` key to each container using by `docker-compose.yml`.
146 |
147 | # Others
148 |
149 | You can customize other settings using by `docker-compose.yml`
150 |
151 | # Back up
152 |
153 | Please execute backup.sh. Back up files are create in buckups directory by tar format.
154 |
155 | Below is example.
156 |
157 | ```txt
158 | .
159 | |-- backups
160 | | `-- 20170227
161 | | |-- 214142_gitbucket_data.tar
162 | | `-- 214142_gitbucket_mysql.tar
163 | ```
164 |
165 | # Version Up
166 |
167 | ## GitBucket
168 |
169 | Please take buckup befor version up.
170 | After buckup please deploy new version of `gitbucket.war` to `gitbucket/gitbucket/war`.
171 |
172 | Execute `docker-compose build` after deploy new version of `gitbucket.war` to `gitbucket/gitbucket/war`.
173 |
174 | ## Database
175 |
176 | #### NOTICEI : I confirm work it only `MySQL 5.7.17 to 8.0.1` on GitBucket version is `4.13.0`
177 |
178 | 1. **Please take backup.**
179 | 2. Please export gitbucket's data using by `System administration -> Data export/import`.
180 |
181 | 
182 |
183 | 3. Remove `gitbucket/storage/mysql/data/*` and bump to MySQL version and execute `docker-compose build`.
184 | 4. Execute `docker-compose up` command.
185 | 5. Copy `gitbucket-export-xxxxxxxx.sql` host os to mysql conrainer. Command is `docker cp gitbucket-export-xxxxxxxx.sql :
186 | `
187 | 6. Import `gitbucket-export-xxxxxxxx.sql` in mysql container. Command is `$ mysql -u root -p gitbucket < gitbucket-export-xxxxxxxx.sql`
188 |
189 | Please see [Data migration](//github.com/gitbucket/gitbucket/wiki/External-database-configuration).
190 |
191 |
192 | # Directory Hierarchy
193 |
194 | ```txt
195 | .
196 | |-- backups
197 | | `-- 20170227
198 | | |-- 214142_gitbucket_data.tar
199 | | `-- 214142_gitbucket_mysql.tar
200 | |-- backup.sh
201 | |-- docker-compose.yml
202 | |-- gitbucket
203 | | |-- docker-entrypoint.sh
204 | | |-- Dockerfile
205 | | |-- war
206 | | | `-- gitbucket.war
207 | | `-- war_download.sh
208 | |-- logs
209 | | `-- nginx
210 | | |-- access.log
211 | | `-- error.log
212 | |-- mysql
213 | | `-- Dockerfile
214 | |-- nginx
215 | | |-- config
216 | | | `-- nginx.conf
217 | | `-- Dockerfile
218 | |-- README.md
219 | `-- storage
220 | |-- gitbucket
221 | | `-- data
222 | `-- mysql
223 | `-- data
224 | ```
225 |
--------------------------------------------------------------------------------