Docker/Compose/GitLab: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| (7 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
==PSQL » Schema » Drop== | ==PSQL » Schema » Drop== | ||
<syntaxhighlight lang= | {|class='wikitable mw-collapsible' style='width:100%;margin:3px 0' | ||
!scope='col' style='text-align:left' colspan='2'| | |||
PSQL » Schema » Drop | |||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight style='margin:3px 0' lang='sql'> | |||
cat << DDL | psql -U${USER} | cat << DDL | psql -U${USER} | ||
DROP DATABASE IF EXISTS gitlab; | DROP DATABASE IF EXISTS gitlab; | ||
| Line 6: | Line 11: | ||
DDL | DDL | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|valign='top' style='width:50%'| | |||
|} | |||
==PSQL » Schema » Create== | ==PSQL » Schema » Create== | ||
<syntaxhighlight lang= | {|class='wikitable mw-collapsible' style='width:100%;margin:3px 0' | ||
!scope='col' style='text-align:left' colspan='2'| | |||
PSQL » Schema » Create | |||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight style='margin:3px 0' lang='sql'> | |||
cat << DDL | psql -U${USER} | cat << DDL | psql -U${USER} | ||
CREATE DATABASE gitlab; | CREATE DATABASE gitlab; | ||
CREATE USER gitlab WITH ENCRYPTED PASSWORD 'sadaqah!'; | CREATE USER gitlab WITH ENCRYPTED PASSWORD 'sadaqah!'; | ||
GRANT ALL PRIVILEGES ON DATABASE gitlab TO gitlab; | GRANT ALL PRIVILEGES ON DATABASE gitlab TO gitlab; | ||
ALTER USER | ALTER USER gitlab WITH SUPERUSER; | ||
DDL | DDL | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|valign='top' style='width:50%'| | |||
|} | |||
==PSQL » Schema » Import== | |||
{|class='wikitable mw-collapsible' style='width:100%;margin:3px 0' | |||
!scope='col' style='text-align:left' colspan='2'| | |||
PSQL » Schema » Import | |||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight style='margin:3px 0' lang='bash'> | |||
gunzip -c ./gitlab_archive/gitlab-sdlc-20241010-T1010-ZP0600.sql.gz|\ | |||
psql -p5432 -hlocalhost -Ugitlab -dgitlab | |||
</syntaxhighlight> | |||
|valign='top' style='width:50%'| | |||
|} | |||
==Linux » UFW » Allow » 5432== | |||
{|class='wikitable mw-collapsible' style='width:100%;margin:3px 0' | |||
!scope='col' style='text-align:left' colspan='2'| | |||
Linux » UFW » Allow » 5432 | |||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight style='margin:3px 0' lang='bash'> | |||
# please update these two filse to allow psql remote client | |||
# /etc/postgresql/14/main/{postgresql,pg_hba}.conf | |||
sudo ufw allow 5432/tcp | |||
sudo ufw status numbered | |||
</syntaxhighlight> | |||
|valign='top' style='width:50%'| | |||
|} | |||
==Linux » UFW » Allow » 1080== | |||
{|class='wikitable mw-collapsible' style='width:100%;margin:3px 0' | |||
!scope='col' style='text-align:left' colspan='2'| | |||
Linux » UFW » Allow » 1080 | |||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight style='margin:3px 0' lang='bash'> | |||
sudo ufw allow 1080/tcp | |||
sudo ufw status numbered | |||
</syntaxhighlight> | |||
|valign='top' style='width:50%'| | |||
|} | |||
==Docker » Compose » Volume== | |||
{|class='wikitable mw-collapsible' style='width:100%;margin:3px 0' | |||
!scope='col' style='text-align:left' colspan='2'| | |||
Docker » Compose » Volume | |||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight style='margin:3px 0' lang='bash'> | |||
mkdir -p ${HOME}/Documents/gitlab-playground/ | |||
cd ${HOME}/Documents/gitlab-playground/ | |||
sudo tar -xzf gitlab_archive/gitlab-sdlc-20241010-T1010-ZP0600.tar.gz | |||
</syntaxhighlight> | |||
|valign='top' style='width:50%'| | |||
|} | |||
==Docker » Compose » Create== | ==Docker » Compose » Create== | ||
<syntaxhighlight lang= | {|class='wikitable mw-collapsible' style='width:100%;margin:3px 0' | ||
!scope='col' style='text-align:left'| | |||
Docker » Compose » Create | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight style='margin:3px 0' lang='yaml'> | |||
cat << YML | tee ${HOME}/Documents/gitlab-playground/docker-compose.yml >/dev/null | cat << YML | tee ${HOME}/Documents/gitlab-playground/docker-compose.yml >/dev/null | ||
--- | --- | ||
| Line 81: | Line 155: | ||
YML | YML | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|} | |||
==Docker » Compose » Manage== | |||
{|class='wikitable mw-collapsible' style='width:100%;margin:3px 0' | |||
!scope='col' style='text-align:left' colspan='2'| | |||
Docker » Compose » Manage | |||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight style='margin:3px 0' lang='bash'> | |||
docker compose up -d | |||
docker compose logs -f -t | |||
docker compose down | |||
</syntaxhighlight> | |||
|valign='top' style='width:50%'| | |||
|} | |||
==Docker » Compose » Systemd== | |||
{|class='wikitable mw-collapsible' style='width:100%;margin:3px 0' | |||
!scope='col' style='text-align:left' colspan='2'| | |||
Docker » Compose » Systemd | |||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight style='margin:3px 0' lang='ini'> | |||
cat << INI | sudo tee /etc/systemd/system/gitlab.service >/dev/null | |||
[Unit] | |||
Description=Gitlab CE | |||
After=docker.service | |||
[Service] | |||
Restart=always | |||
User=gitlab | |||
Group=gitlab | |||
ExecStart=/usr/bin/docker-compose -f /etc/gitlab/docker-compose.yml up | |||
ExecStop=/usr/bin/docker-compose -f /etc/gitlab/docker-compose.yml stop | |||
[Install] | |||
WantedBy=multi-user.target | |||
INI | |||
</syntaxhighlight> | |||
|valign='top' style='width:50%'| | |||
|} | |||
==Minikube » Internal » Namespace== | |||
{|class='wikitable mw-collapsible' style='width:100%;margin:3px 0' | |||
!scope='col' style='text-align:left' colspan='2'| | |||
Minikube » Internal » Namespace | |||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight style='margin:3px 0' lang='bash'> | |||
kubectl get ns|grep internal | |||
kubectl create namespace internal | |||
</syntaxhighlight> | |||
|valign='top' style='width:50%'| | |||
|} | |||
==Minikube » Internal » Service== | |||
{|class='wikitable mw-collapsible' style='width:100%;margin:3px 0' | |||
!scope='col' style='text-align:left' colspan='2'| | |||
Minikube » Internal » Service | |||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight style='margin:3px 0' lang='yaml'> | |||
cat << YML|kubectl apply -n internal -f - | |||
--- | |||
apiVersion: v1 | |||
kind: Service | |||
metadata: | |||
name: minikube-host | |||
namespace: internal | |||
labels: | |||
app.kubernetes.io/version: 1.0.0 | |||
app.kubernetes.io/managed-by: kubectl | |||
app.kubernetes.io/name: minikube-host | |||
app.kubernetes.io/instance: minikube-host | |||
spec: | |||
type: ExternalName | |||
externalName: host.minikube.internal | |||
YML | |||
</syntaxhighlight> | |||
|valign='top' style='width:50%'| | |||
|} | |||
==Minikube » Internal » Ingress== | |||
{|class='wikitable mw-collapsible' style='width:100%;margin:3px 0' | |||
!scope='col' style='text-align:left' colspan='2'| | |||
Minikube » Internal » Ingress | |||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight style='margin:3px 0' lang='yaml'> | |||
cat << YML | kubectl apply -n internal -f - | |||
--- | |||
apiVersion: networking.k8s.io/v1 | |||
kind: Ingress | |||
metadata: | |||
name: gitlab | |||
namespace: internal | |||
labels: | |||
app.kubernetes.io/version: 1.0.0 | |||
app.kubernetes.io/managed-by: kubectl | |||
app.kubernetes.io/name: minikube-host | |||
app.kubernetes.io/instance: minikube-host | |||
spec: | |||
ingressClassName: nginx | |||
rules: | |||
- host: "gitlab.host.k8s.local" | |||
http: | |||
paths: | |||
- path: / | |||
pathType: ImplementationSpecific | |||
backend: | |||
service: | |||
name: minikube-host | |||
port: | |||
number: 1080 | |||
YML | |||
</syntaxhighlight> | |||
|valign='top' style='width:50%'| | |||
|} | |||
==GitLab » Update » Password== | |||
{|class='wikitable mw-collapsible' style='width:100%;margin:3px 0' | |||
!scope='col' style='text-align:left' colspan='2'| | |||
GitLab » Update » Password | |||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight style='margin:3px 0' lang='ruby'> | |||
docker exec -it gitlab gitlab-rails console -e production | |||
user = User.where(id: 1).first | |||
user.password = 'sadaqah!' | |||
user.password_confirmation = 'sadaqah!' | |||
user.save | |||
</syntaxhighlight> | |||
|valign='top' style='width:50%'| | |||
|} | |||
==GitLab » Open » Browser== | |||
{|class='wikitable mw-collapsible' style='width:100%;margin:3px 0' | |||
!scope='col' style='text-align:left' colspan='2'| | |||
GitLab » Open » Browser | |||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight style='margin:3px 0' lang='bash'> | |||
xdg-open http://gitlab.host.k8s.local &>/dev/null & | |||
gnome-open http://gitlab.host.k8s.local &>/dev/null & | |||
x-www-browser http://gitlab.host.k8s.local &>/dev/null & | |||
sensible-browser http://gitlab.host.k8s.local &>/dev/null & | |||
</syntaxhighlight> | |||
|valign='top' style='width:50%'| | |||
|} | |||
==References== | |||
{|class='wikitable mw-collapsible' style='width:100%;margin:3px 0' | |||
!scope='col' style='text-align:left' colspan='3'| | |||
References | |||
|- | |||
|valign='top' style='width:33%'| | |||
* [https://hub.docker.com/r/gitlab/gitlab-ce/tags?name=17.1.3 GitLab » Docker » <code>gitlab/gitlab-ce:17.1.3</code>] | |||
* [https://hub.docker.com/r/gitlab/gitlab-ce/tags?name=16.1.3 GitLab » Docker » <code>gitlab/gitlab-ce:16.1.3</code>] | |||
* [https://hub.docker.com/r/gitlab/gitlab-ce/tags?name=15.1.3 GitLab » Docker » <code>gitlab/gitlab-ce:15.1.3</code>] | |||
* [[GitLab]] | |||
|valign='top' style='width:34%'| | |||
|valign='top' style='width:33%'| | |||
|- | |||
|valign='top'| | |||
* [[Linux Containers]] | |||
* [[Kubernetes]] | |||
* [[Multipass]] | |||
* [[Minikube]] | |||
* [[Podman]] | |||
* [[Vagrant]] | |||
* [[Qemu]] | |||
* [[Helm]] | |||
* [[K9s]] | |||
* [[K8s]] | |||
|valign='top'| | |||
* [[Docker Compose|Docker » Compose]] | |||
* [[Terraform]] | |||
* [[Kubectl]] | |||
* [[Ansible]] | |||
* [[Docker]] | |||
* [[CIDR]] | |||
* [[UFW]] | |||
* [[Git]] | |||
|valign='top'| | |||
|} | |||
Latest revision as of 10:25, 15 January 2026
PSQL » Schema » Drop
|
PSQL » Schema » Drop | |
|---|---|
cat << DDL | psql -U${USER}
DROP DATABASE IF EXISTS gitlab;
DROP USER IF EXISTS gitlab;
DDL
|
|
PSQL » Schema » Create
|
PSQL » Schema » Create | |
|---|---|
cat << DDL | psql -U${USER}
CREATE DATABASE gitlab;
CREATE USER gitlab WITH ENCRYPTED PASSWORD 'sadaqah!';
GRANT ALL PRIVILEGES ON DATABASE gitlab TO gitlab;
ALTER USER gitlab WITH SUPERUSER;
DDL
|
|
PSQL » Schema » Import
|
PSQL » Schema » Import | |
|---|---|
gunzip -c ./gitlab_archive/gitlab-sdlc-20241010-T1010-ZP0600.sql.gz|\
psql -p5432 -hlocalhost -Ugitlab -dgitlab
|
|
Linux » UFW » Allow » 5432
|
Linux » UFW » Allow » 5432 | |
|---|---|
# please update these two filse to allow psql remote client
# /etc/postgresql/14/main/{postgresql,pg_hba}.conf
sudo ufw allow 5432/tcp
sudo ufw status numbered
|
|
Linux » UFW » Allow » 1080
|
Linux » UFW » Allow » 1080 | |
|---|---|
sudo ufw allow 1080/tcp
sudo ufw status numbered
|
|
Docker » Compose » Volume
|
Docker » Compose » Volume | |
|---|---|
mkdir -p ${HOME}/Documents/gitlab-playground/
cd ${HOME}/Documents/gitlab-playground/
sudo tar -xzf gitlab_archive/gitlab-sdlc-20241010-T1010-ZP0600.tar.gz
|
|
Docker » Compose » Create
|
Docker » Compose » Create |
|---|
cat << YML | tee ${HOME}/Documents/gitlab-playground/docker-compose.yml >/dev/null
---
name: gitlab
services:
gitlab:
image: gitlab/gitlab-ce:15.1.3-ce.0
container_name: gitlab
restart: always
hostname: 'gitlab.host.k8s.local'
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
portal:
aliases:
- gitlab.host.k8s.local
labels:
gitlab: "GitLab CE"
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://gitlab.host.k8s.local'
gitlab_rails['db_adapter'] = 'postgresql'
gitlab_rails['db_database'] = 'gitlab'
gitlab_rails['db_username'] = 'gitlab'
gitlab_rails['db_password'] = 'sadaqah!'
gitlab_rails['db_host'] = 'host.docker.internal'
gitlab_rails['gitlab_ssh_host'] = 'code.host.k8s.local'
nginx['proxy_set_headers'] = { 'X-Forwarded-Proto' => 'http', 'X-Forwarded-Ssl' => 'Off' }
nginx['listen_port'] = 80
nginx['listen_https'] = false
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_domain'] = "mail.k8s.local"
gitlab_rails['smtp_address'] = 'mail.k8s.local'
gitlab_rails['smtp_port'] = 10587
gitlab_rails['smtp_user_name'] = 'dev@mail.k8s.local'
gitlab_rails['smtp_password'] = 'sadaqah!'
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['gitlab_email_from'] = 'gitlab@mail.k8s.local'
gitlab_rails['gitlab_email_display_name'] = 'Academia Gitlab'
gitlab_rails['gitlab_email_reply_to'] = 'no-reply@mail.k8s.local'
gitlab_rails['omniauth_enabled'] = true
gitlab_rails['omniauth_allow_single_sign_on'] = ['openid_connect']
gitlab_rails['omniauth_block_auto_created_users'] = false
gitlab_rails['gitlab_default_can_create_group'] = false
gitlab_rails['gitlab_username_changing_enabled'] = false
gitlab_rails['omniauth_providers'] = [{ 'name' => 'openid_connect', 'label' => 'Academia OpenID', 'icon' => '', 'args' => {'name' => 'openid_connect', 'scope' => ['openid','profile'], 'response_type' => 'code', 'issuer' => 'http://keycloak.k8s.local/realms/GoogleWorkspace', 'discovery' => true, 'client_auth_method' => 'query', 'uid_field' => 'sub', 'send_scope_to_token_endpoint' => 'false', 'client_options' => { 'identifier' => 'gitlab.host.k8s.local', 'secret' => 'sRQwifypRYYhvXPZId8yh3wK0oU9Jqgh', 'redirect_uri' => 'http://gitlab.host.k8s.local/users/auth/openid_connect/callback' }}}]
ports:
- '4430:443'
- '1080:80'
- '1022:22'
volumes:
- './gitlab/config:/etc/gitlab'
- './gitlab/logs:/var/log/gitlab'
- './gitlab/data:/var/opt/gitlab'
shm_size: '256m'
networks:
portal:
ipam:
config:
- subnet: 10.10.10.0/24
YML
|
Docker » Compose » Manage
|
Docker » Compose » Manage | |
|---|---|
docker compose up -d
docker compose logs -f -t
docker compose down
|
|
Docker » Compose » Systemd
|
Docker » Compose » Systemd | |
|---|---|
cat << INI | sudo tee /etc/systemd/system/gitlab.service >/dev/null
[Unit]
Description=Gitlab CE
After=docker.service
[Service]
Restart=always
User=gitlab
Group=gitlab
ExecStart=/usr/bin/docker-compose -f /etc/gitlab/docker-compose.yml up
ExecStop=/usr/bin/docker-compose -f /etc/gitlab/docker-compose.yml stop
[Install]
WantedBy=multi-user.target
INI
|
|
Minikube » Internal » Namespace
|
Minikube » Internal » Namespace | |
|---|---|
kubectl get ns|grep internal
kubectl create namespace internal
|
|
Minikube » Internal » Service
|
Minikube » Internal » Service | |
|---|---|
cat << YML|kubectl apply -n internal -f -
---
apiVersion: v1
kind: Service
metadata:
name: minikube-host
namespace: internal
labels:
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/managed-by: kubectl
app.kubernetes.io/name: minikube-host
app.kubernetes.io/instance: minikube-host
spec:
type: ExternalName
externalName: host.minikube.internal
YML
|
|
Minikube » Internal » Ingress
|
Minikube » Internal » Ingress | |
|---|---|
cat << YML | kubectl apply -n internal -f -
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: gitlab
namespace: internal
labels:
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/managed-by: kubectl
app.kubernetes.io/name: minikube-host
app.kubernetes.io/instance: minikube-host
spec:
ingressClassName: nginx
rules:
- host: "gitlab.host.k8s.local"
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: minikube-host
port:
number: 1080
YML
|
|
GitLab » Update » Password
|
GitLab » Update » Password | |
|---|---|
docker exec -it gitlab gitlab-rails console -e production
user = User.where(id: 1).first
user.password = 'sadaqah!'
user.password_confirmation = 'sadaqah!'
user.save
|
|
GitLab » Open » Browser
|
GitLab » Open » Browser | |
|---|---|
xdg-open http://gitlab.host.k8s.local &>/dev/null &
gnome-open http://gitlab.host.k8s.local &>/dev/null &
x-www-browser http://gitlab.host.k8s.local &>/dev/null &
sensible-browser http://gitlab.host.k8s.local &>/dev/null &
|
|
References
|
References | ||
|---|---|---|