LoginSignup
3
3

More than 5 years have passed since last update.

Azure Linux 仮想マシンでgitlab環境を構築する

Posted at

はじめに

個人的に使用できるようなGit環境が欲しかったので、Azure の Linux仮想マシン(Ubuntu 18.04)にgitlab ceを構築してみました。

事前準備

Azure Marketplace でCanonicalから公開されている Ubuntu Server 18.04 LTSイメージを使用して仮想マシンを作成 。ssh(port: 22)接続できる設定
gitlabは4GB以上のメモリを推奨しているので、適したサイズを利用する必要があります
ubuntu1804.PNG

作業

  1. Azure VMの設定
  2. Ubutnu OSの設定

Azure VMの設定

Azure VMの firewallポジションNSG(Network Security Group)を開放し、gitlabで設定するdns名を確認します。
作ったAzure Linux仮想マシンは、インターネット接続はssh(22ポート)しか開放されていないので、HTTP用に80と、HTTPS用に443を開放する。
Azureポータル(https://portal.azure.com) のネットワーク > 「受信ポート規則の追加」から、宛先ポート範囲 80, 443でTCPを許可する
NSG.PNG

次にgitlabでサイトのurlに設定するために、パブリックIPアドレスのDNS名を確認あるいは設定する。ネットワーク > パブリックIPを選択し、構成のDNS名ラベル(オプション)を設定する。このDNS名(xxx.japaneast.cloudapp.azure.com)を使って、VMのパブリックIPアドレスにアクセスすることができるようになる。
public.PNG

Ubuntu OSの設定

基本的に https://about.gitlab.com/install/#ubuntu に従って作業していく。
まずは、パブリックIPでVMにssh接続し、Rootに変更

azureuser@ub18lts:~$ sudo su -

aptの最新化ととgitlabのdependencyのあるパッケージをインストール

apt-get update
apt-get install -y curl openssh-server ca-certificates

公式手順では、メール送信のためにpostfixをインストールしているが、azure仮想マシンはメールサーバとしての利用が非推奨なので使わないと思いskipしました。

apt line に GitLab CE を登録するためにスクリプトを実行します。

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
root@ub18lts:~# cat /etc/apt/sources.list.d/gitlab_gitlab-ce.list
# this file was generated by packages.gitlab.com for
# the repository at https://packages.gitlab.com/gitlab/gitlab-ce

deb https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ bionic main
deb-src https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ bionic main

gitlab-ceをインストールします。この時、EXTERNAL_URLにVMのパブリックIPアドレスのDNS名を登録します。

EXTERNAL_URL="http://xxx![gitlab.PNG](https://qiita-image-store.s3.amazonaws.com/0/192113/8e227e93-5b3c-d494-f310-9873c937c773.png)
.japaneast.cloudapp.azure.com" apt-get install gitlab-ce

設定を再構成して、起動します。

sudo gitlab-ctl reconfigure

ブラウザで、設定したEXTERNAL_URL(http://xxxx.japaneast.cloudapp.azure.com)にアクセスします。

最初に root ユーザーのパスワードを変更するように促さるので、New password と Confirm new password に新しいパスワードを入れて Change Your password ボタンをクリックしてください。次からrootとパスワードでログインできるようになります。

gitlab.PNG

最後に

MSがgithub買収したのにAzureでgitlabもどうかと思いましたが何とか構築できました。
Docker Imageも公開されているのでそちらから作るというのもありかもと思いました。

参考

  1. GitLab Installation
  2. GitLab をインストールしよう! (omnibus package)
3
3
0

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
3
3