Ubuntu 18.04 上の GitLab CI で Docker イメージをビルドして GCP の Container Registry に登録するまで

環境 さくらVPS に Ubuntu 18.04 をOSカスタムインストールしていて、GitLab CE をインストールします。GitLab CI Runner も同ホストで動かします。 CI で Docker イメージをビルドして、Google Cloud Platform (GCP) の Container Registry にプッシュします。 GitLab のインストール 下記のページの通りです。EEとCEの差はライセンスを適用するかどうかで変わりますが、絶対にCEのままというならインストールスクリプトのURLを変えるとそちらでインストールされます。 about.gitlab.com GitLab CI 機能の設定 Docker CE をインストール 単に apt からインストールもできますが、バージョンが古いと嵌りやすいので最新の Docker CE をインストールします。 docs.docker.com GitLab Runner のインストール こちらは、Dockerへのインストールではなく、リポジトリからインストールしました。GitLab Runner はほぼ CI Runner のコマンド管理ツールで、実際ジョブ処理する Runner (ないし Executor) は次でインストールという認識です。 docs.gitlab.com 実際の GitLab Runner(Executor) として動作するDockerコンテナを登録 下記の Building Docker images with GitLab CI/CD ページ内の Use docker-in-docker executor* を実行します。 https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-docker-in-docker-executor 各リポジトリの CI 設定 GCPにストレージ管理者権限を持つサービスアカウントを作成し、JSONキーファイルを取得します。 https://cloud.google.com/container-registry/docs/advanced-authentication#json_key_file ...

2018年11月18日 · Toshimitsu Takahashi

Ubuntu で GitLab を Omnibus に移行し GitLab CI も使い始める

インストールが大変という定評のあった GitLab ですが、マニュアルインストールとアップグレードで凌いでいました。 GitLab CI を導入しようと試す過程で、サブディレクトリ運用だと OAuth 連携が上手くいかないことがわかりました。 現在はオールインワンのパッケージが提供されているため、下記を使えば簡単に GitLab, GitLab CI を一気に入れることができます。Nginx、PostgreSQL、Redis なども全てまとめて /opt/gitlab に入ります。 GitLab | Download GitLab Community Edition (CE) サーバスペックをアップグレードするついでに上げますが、基本的にバーチャルホストを使うため FQDN を GitLab, GitLab CI で同じにできません。SSL 証明書に関しては、ワイルドカードを持ってないと辛いところです。 GitLab を最新に更新 下記の手順どおりやれば簡単に今は上がります。 gitlabhq/upgrader.md at master · gitlabhq/gitlabhq · GitHub バックアップ $ cd /home/git/gitlab $ sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production サービス停止 $ sudo service gitlab stop アップグレード $ sudo -u git -i $ bundle exec rake gitlab:backup:create RAILS_ENV=production $ cd gitlab $ ruby bin/upgrade.rb GitLab 7 upgrade tool Your version is 7.5.3 Latest available version for GitLab 7 is 7.7.2 Newer GitLab version is available Do you want to upgrade (yes/no)? yes Stash changed files -\> git stash Saved working directory and index state WIP on 7-5-stable: b656b85 Version 7.5.3 HEAD is now at b656b85 Version 7.5.3 -\> OK Get latest code -\> git fetch remote: Counting objects: 7452, done. remote: Compressing objects: 100% (3095/3095), done. remote: Total 7452 (delta 5170), reused 6001 (delta 4268) Receiving objects: 100% (7452/7452), 2.18 MiB | 387.00 KiB/s, done. Resolving deltas: 100% (5170/5170), done. From https://github.com/gitlabhq/gitlabhq (省略) \* \[new tag\] v7.7.2 -> v7.7.2 -\> OK Switch to new version -\> git checkout v7.7.2 Note: checking out 'v7.7.2'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b new\_branch\_name HEAD is now at bd98290... Version 7.7.2 -\> OK Install gems -\> bundle Fetching source index from https://rubygems.org/ (省略) Your bundle is complete! Gems in the groups development, test and postgres were not installed. It was installed into ./vendor/bundle -\> OK Migrate DB -\> bundle exec rake db:migrate (省略) -\> OK Recompile assets -\> bundle exec rake assets:clean assets:precompile (省略) -\> OK Clear cache -\> bundle exec rake cache:clear -\> OK Done サービス起動 $ sudo service gitlab start このタイミングで自分の環境では、rbenv で入っていたのが、2.1.3 で 2.1.5 じゃないとエラーが出ました。 /home/git/gitlab/.ruby-version を 2.1.5 に書き換えたら動きました。 ...

2015年2月8日 · Toshimitsu Takahashi

Ubuntu 12.04 への HTTPS およびサブディレクトリでの GitLab セットアップメモ

設定した環境 フロントの Nginx は https である。 URL は<ドメイン>/gitlab で受ける. さくらの VPS Ruby 1.9, MySQL で Redmine 2.3 が既に動いている。 gitユーザを追加 $ sudo adduser --disabled-login --gecos 'GitLab' git GitLab shell のセットアップ インストール $ sudo -u git -i $ cd /home/git $ git clone https://github.com/gitlabhq/gitlab-shell.git $ cd gitlab-shell $ git checkout v1.5.0 $ cp config.yml.example config.yml ※バージョンは最新のものにチェックアウト 設定 config.yml config.yml の gitlab_url を外から見えるURLに変更する。 gitlab_url: “https://<ドメイン>/gitlab/” ライブラリのインストール $ sudo apt-get install libicu-dev $ sudo gem install charlock_holmes --version '0.6.9.4' データベースのセットアップ MySQL を使う https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/databases.md に従う。 ※gitlab ユーザのパスワードを控える。 ...

2013年6月19日 · Toshimitsu Takahashi