LoginSignup
2
3

More than 3 years have passed since last update.

GitBucketをMySQL8で立ち上げるdocker-composeファイル

Last updated at Posted at 2020-01-20

目的 GitBucketを立てる

選定理由

とりあえずバージョン管理をしたい。オープンソースのgitサーバにGitLabというのもあるが鬼のようにスペックを要求される(機能も鬼のように多い)。かなりシンプルなgitサーバの機能だけで良いのでGitBucketにします。

注意

セキュリティ意識は低いスクリプトなので間違っても外部サイト公開用途ではしないでください。

献立

ソフトウェア名 バージョン 必要数  備考 
Windows10Pro 1809 1PC
Docker for Windows 2.1.0.4 1くっじらー 2.2が出たのでいずれアップデートする
GitBucket 4 1バケツ
MySQL 8.0.16 1人

構築手順

手順1

docker-compouseの置き場所を決める。そこにDBのファイルとgitbucketアプリが構築されます。
今回の例ではc:\docker-compose\gitbuketに配置するものとします。

手順2

以下の内容のdocker-compouse.ymlをc:\docker-compose\gitbuketに作成します。

docker-compouse.yml
version: '3.1'

services:
  gitbucket-db:
    image: mysql:8.0.16
    restart: always
    command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    ports:
      - "3306:3306"
    volumes:
      - ./mysql_init:/docker-entrypoint-initdb.d
      - ./mysql_data:/var/lib/mysql
    environment:
      TZ: Asia/Tokyo
      MYSQL_ROOT_PASSWORD: qawsedrftgyhujikolp
      MYSQL_DATABASE: gitbucket
      MYSQL_USER: gitbucket
      MYSQL_PASSWORD: 1q2w3e4r5t6y7u8i9
    security_opt: #Measures mbind: Operation not permitted
      - seccomp:unconfined
  gitbucket:
    image: gitbucket/gitbucket:4
    restart: always
    ports:
      - 3000:3000
      - 8080:8080
      - 29418:29418
    environment:
      - TZ=Asia/Tokyo
      - GITBUCKET_DB_URL=jdbc:mysql://gitbucket-db/gitbucket?useUnicode=true&characterEncoding=utf8
      - GITBUCKET_DB_USER=gitbucket
      - GITBUCKET_DB_PASSWORD=1q2w3e4r5t6y7u8i9
#      - GITBUCKET_BASE_URL=
      - GITBUCKET_HOME=./gitbucket
    volumes:
      - ./gitbucket-data:/gitbucket
    depends_on:
      - gitbucket-db
    command: bash -c 'while !</dev/tcp/gitbucket-db/3306; do sleep 1; done; sleep 10; java -jar /opt/gitbucket.war'

スペシャルサンクス
SIkebeさん

手順3

コマンドプロンプトを立ち上げdocker-compouseの置き場所に移動してください。

置き場所に移動
cd c:\docker-compose\gitbuket

docker-compouse upをします。
作る際はいきなり-dをつけるのではなく火加減を見る為にログを表示させるといいコックになれます。なおその場合、止める為にはCtrl+Cでを押すことで止められます。

立ち上げ
docker-compouse up

初回起動は時間がかかります。私の場合、3分弱はかかっていますがdockerhubからダウンロードを入れると多分もっとかかります。

ログサンプル
gitbucket-db_1  | Initializing database
gitbucket_1     | 20XX-XX-XX 11:32:54.208:INFO::main: Logging initialized @165ms to org.eclipse.jetty.util.log.StdErrLog

・・・・

gitbucket-db_1  | 20XX-XX-XXT02:33:26.147694Z 0 [System] [MY-013170] [Server] /usr/sbin/mysqld (mysqld 8.0.16) initializing of server has completed
gitbucket-db_1  | Database initialized
gitbucket-db_1  | MySQL init process in progress...
gitbucket-db_1  | MySQL init process in progress...
gitbucket-db_1  | MySQL init process in progress...
gitbucket-db_1  | MySQL init process in progress...
gitbucket-db_1  | 20XX-XX-XXT02:33:30.387137Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.

・・・・

gitbucket_1     | 20XX-XX-XX 11:33:47.031:INFO:oejw.StandardDescriptorProcessor:main: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
gitbucket-db_1  | 20XX-XX-XXT02:33:44.893380Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.

・・・・

gitbucket_1     | 20XX-XX-XX 11:36:05.450:INFO:oejs.Server:main: Started @191413ms

手順4

立ち上がったらおもむろにWebにアクセスする
URL localhost:8080

ログイン
ID root
Pass root

余談

Windowsでも永続化が簡単なのでMySQLを使っている。
このままでいいとは思っていないが、簡単だから使ってしまう。
オラクルの有料化警戒を強めます。

2
3
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3