dimanche 19 juin 2022

Free Gitlab ARM on OCI

With Oracle Cloud Infrastructure article, you can deploy for free 2 VM ARM, for example your GitLab instance.

The article guides you through deploying your GitLab instance.

https://docs.oracle.com/en/solutions/deploy-GitLab-ci-cd-oci/index.html#GUID-02762BBC-6B22-4547-B542-2C021CDEA870

Here I provide you with the steps to update GitLab to the latest version and configure your instance to use a custom domain for free using DuckDNS, send emails and enable free SSL certificate with Let's Encrypt.

Upgrade GitLab

Upgrade following the GitLab upgrade path

https://docs.GitLab.com/ee/update/index.html#upgrade-paths

sudo yum -y update Gitlab-ee-13.12.15-ee.0.el8
sudo yum -y update Gitlab-ee-14.0.12-ee.0.el8

Finally, one last update

sudo yum -y update

Register your custom domain with DuckDNS

Create an account on www.duckdons.org.

Create your subdomain

Create your subdomain myinstance.duckdns.org using your OCI instance public IP.

Follow DuckDNS steps. Create /etc/duckdns/duck.sh

mkdir duckdns
cd duckdns
vi duck.sh

In the file add your custom DuckDNS configuration.

echo url="https://www.duckdns.org/update?domains=myinstance&token=a7c4b0ad-114e-40ef-ba1d-d218904a50f2&ip=" | curl -k -o ~/duckdns/duck.log -K -

Create your cron entry

*/5 * * * * ~/duckdns/duck.sh >/dev/null 2>&1

Update GitLab to use your custom domain

Update GitLab configuration file to update your external_url

sudo vim /etc/gitlab/gitlab.rb
external_url 'http://GitLab.example.com'

Set your hostname

sudo hostnamectl set-hostname myinstance.duckdns.org

Reload configuration sudo GitLab-ctl reconfigure
Review configuration
sudo GitLab-ctl show-config

Configure GitLab to send email

Create OCI SMTP credentials

Follow the OCI steps to generate a username and password
https://docs.oracle.com/en-us/iaas/Content/Email/Reference/gettingstarted.htm https://docs.oracle.com/en-us/iaas/Content/Email/Tasks/generatesmtpcredentials.htm#Generate_SMTP_Credentials_for_a_User

Configuration GitLab to use Postfix
https://docs.oracle.com/en-us/iaas/Content/Email/Reference/postfix.htm

SMTP credentials to send emails

Edit GitLab configuration to use the credentials generated

sudo vim /etc/GitLab/GitLab.rb
  GitLab_rails['smtp_user_name'] = "ocid1.user.oc1..aaaaaaaaaxxxxx.ii@ocid1.tenancy.oc1...kd.com" 
  GitLab_rails['smtp_password'] = "3e4rtyhu6yt_W"    

Test to send email from GitLab

sudo GitLab-rails console
Notify.test_email('my.email@domain.com', 'Message Subject', 'Message Body').deliver_now

https://docs.GitLab.com/omnibus/settings/smtp.html#testing-the-smtp-configuration

Tips and tricks

Send email in bash

sudo yum install mailx

The sender needs to be approved
https://docs.oracle.com/en-us/iaas/Content/Email/Reference/gettingstarted.htm#start__config

echo "This is a test message" | mail -s "Test" -r my.email@domain.com my.email@domain.com
Check maillog sudo tail -f /var/log/maillog

SSL configuration

https://docs.GitLab.com/omnibus/settings/ssl.html#install-custom-public-certificates

In the following article, how to deploy your code