I wanted to try various things using the Mattermost API, and when I tried to build a GitLab environment quickly, I was addicted to it unexpectedly, so I will leave what I did. What I want to do is build a GitLab environment using DockerForWindows.
I put it on GitHub. (https://github.com/shimi58/CentOS8_GitLab) However, the Mattermost setting changes each time you build it, so the procedure described below is required.
Operation check environment | version |
---|---|
Windows10 Home Edition | Version 2004 |
Docker for Windows | 2.4.0.0 |
I will describe it in the Dockerfile. The result is as follows.
FROM centos:8
#Localizing into Japanese
RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial && \
dnf -y upgrade && \
dnf -y install glibc-locale-source && \
dnf clean all && \
localedef -f UTF-8 -i ja_JP ja_JP.UTF-8 && \
ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
#C LANG for Gitlab installation.UTF-Change to 8
ENV LANG="C.UTF-8" \
LANGUAGE="ja_JP:ja" \
LC_ALL="ja_JP.UTF-8"
#root password setting
RUN echo "root:root" | chpasswd
# =====
# BASE packages
# =====
RUN dnf install -y openssl openssl-devel openssh openssh-server wget sudo unzip which tree git firewalld
# =====
#Install GitLab CE
# =====
RUN curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
RUN dnf install -y gitlab-ce
docker-compose.yml
version: '3'
services:
centos8:
container_name: "centos8"
build: ./
tty: true
privileged: true
command: /sbin/init
ports:
- "2222:22"
- "9080:9080" #For GitLab
- "9081:9081" #For GitLab Mattermost
- '10443:443'
volumes:
#Persistence according to the formula
- './srv/gitlab/config:/etc/gitlab' #Place GitLab definition file
- './srv/gitlab/logs:/var/log/gitlab' #GItLab log file output
- './srv/gitlab/data:/var/opt/gitlab' #GItLab data storage
--Japanese environment settings
```
#Localizing into Japanese
RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial && \
dnf -y upgrade && \
dnf -y install glibc-locale-source && \
dnf clean all && \
localedef -f UTF-8 -i ja_JP ja_JP.UTF-8 && \
ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
#C LANG for Gitlab installation.UTF-Change to 8
ENV LANG="C.UTF-8" \
LANGUAGE="ja_JP:ja" \
LC_ALL="ja_JP.UTF-8"
```
I referred to this (https://qiita.com/polarbear08/items/e5c00869c7566db5f7b8). If you do not set LANG to C.UTF-8, it will stop around DB migration of "gitlab-ctl reconfigure", so be careful.
--Install GitLab CE
```cmd
RUN curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
RUN dnf install -y gitlab-ce
```
This is the official procedure. (Note that the official sample is gitlab-ee)
--Data persistence
```docker-compose.yml
volumes:
#Persistence according to the formula
- './srv/gitlab/config:/etc/gitlab' #Place GitLab definition file
- './srv/gitlab/logs:/var/log/gitlab' #GItLab log file output
- './srv/gitlab/data:/var/opt/gitlab' #GItLab data storage
```
If this is set, the data will be retained even if the container is dropped.
Place the above Dockerfile and docker-compose.yml in any directory.
Move to the placed directory and start the container
docker-compose up -d
Place gitlab.rb in the specified folder
srv
└─gitlab
├─config
│ gitlab.rb
│
├─data
└─logs
This file can be found here (https://github.com/shimi58/CentOS8_GitLab).
Set the port of GitLab
external_url 'http://localhost:9080'
Enable GitLab Mattermost
mattermost_external_url 'http://localhost:9081'
mattermost['enable'] = true
Log in to the container
docker exec -it centos8 bash
Reflect GitLab settings
sudo /opt/gitlab/embedded/bin/runsvdir-start &
gitlab-ctl reconfigure
After the reflection, access GitLab
http://localhost:9080
--Mattermost can also be displayed at this timing
```url
http://localhost:9081
```
――After that, it will be the procedure of Mattermost SSO cooperation
After completing the initial password settings, log in
Check the Mattermost settings --Move to "Admin Area"-> "Applications" --If there is already a definition for Mattermost, use it, if not, create a new one (* It will not be displayed if the mattermost setting in gitlab.rb is enabled)
Reflect the "Application ID" and "Secret" confirmed above in gitlab.rb At the same time, add the necessary settings
mattermost['gitlab_enable'] = true #SSO enabled
mattermost['gitlab_id'] = "5e7f43cdf588e92c8b0ca589832c64dd5094969c5848667a09e50ffe4834c065" #Application ID
mattermost['gitlab_secret'] = "23791f7219f6782f38c9c1f462c5e715e88216ee13d3513a122dc9c302ba130b" #secret
mattermost['gitlab_auth_endpoint'] = "http://localhost:9080/oauth/authorize" #Enter the URL of GitLab
mattermost['gitlab_token_endpoint'] = "http://localhost:9080/oauth/token" #Enter the URL of GitLab
mattermost['gitlab_user_api_endpoint'] = "http://localhost:9080/api/v4/user" #Enter the URL of GitLab
Reflect GitLab settings
gitlab-ctl reconfigure
From Mattermost, select "Sign in with GitLab" and log in
Confirm that the transition to the Mattermost screen is displayed.
GitLab built this time is heavy even with CORE i7 and memory 16G.
After rebuilding the container, restore persistent data. Gitlab-ctl reconfigure is required to reflect.
Recommended Posts