154 lines
No EOL
6.1 KiB
Markdown
154 lines
No EOL
6.1 KiB
Markdown
# Devops Makinası kurulumu
|
||
|
||
## VS Code -> Extensions kısmında "Docker" kurulmalıdır.
|
||
|
||
## VS Code -> Extensions kısmında "Save as Root in Remote" kurulmalıdır.
|
||
|
||
## VS Code üzerinden SSH parolası sabitleme (Firewall ve SSH)
|
||
|
||
- Windows Terminal üzerinde ssh_keygen komutu çalıştırılır.
|
||
- C:\Users\sedat.ozturk\.ssh klasörün altında id_rsa ve id_rsa.pub isimli 2 dosya oluşturur.
|
||
- C:\Users\sedat.ozturk\.ssh dosyasının içerisindeki id_rsa.pub dosyasının içeriğini ~/.ssh klasöründeki authorized_keys içeriğine kopyalanır.
|
||
- Bu sayede VS Code üzerinden bağlanırken her defasında ssh paroları yazmak durumunda olmayız.
|
||
|
||
## Docker kurulumu
|
||
|
||
- sudo apt update
|
||
- sudo apt install apt-transport-https ca-certificates curl software-properties-common
|
||
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||
- sudo apt update
|
||
- apt-cache policy docker-ce
|
||
- sudo apt install docker-ce
|
||
- sudo systemctl status docker
|
||
- sudo usermod -aG docker ${USER}
|
||
- su - ${USER}
|
||
- sudo reboot
|
||
- sudo su
|
||
- cd /etc/docker
|
||
- touch daemon.json
|
||
daemon.json dosyasının içerisine aşağıdaki satırlar eklenecek.
|
||
{
|
||
"insecure-registries": ["devops.sozsoft.com"]
|
||
}
|
||
- sudo systemctl restart docker
|
||
- /etc/hosts dosyası açılacak ve içerisine `127.0.1.1 devops.sozsoft.com` eklenecek
|
||
- docker login devops.sozsoft.com
|
||
|
||
## Wildcard için Sertifika alma
|
||
|
||
- sudo apt-get remove certbot
|
||
- sudo snap install --classic certbot
|
||
- sudo ln -s /snap/bin/certbot /usr/bin/certbot
|
||
- sudo certbot certonly --manual --preferred-challenges=dns --email system@sozsoft.com --agree-tos -d sozsoft.com -d *.sozsoft.com
|
||
- sudo su
|
||
- cd /etc/letsencrypt/archive
|
||
- chgrp docker -R sozsoft.com
|
||
- chown ${USER} -R sozsoft.com
|
||
- cd /etc/letsencrypt/archive/sozsoft.com
|
||
- cp -R /etc/letsencrypt/archive/sozsoft.com /home/sedat/sozsoft.com
|
||
- exit
|
||
- cd sozsoft.com/
|
||
- sudo chmod 775 *
|
||
|
||
## Subdomainler için Otomatik Sertifika alma
|
||
|
||
- /configs/deployment/scripts/7-setup_ssl.sh içerisinde subdomainlerin otomatik ssl sertifikası oluşturulmaktadır.
|
||
|
||
## Git Kurulumu
|
||
|
||
- cd ~
|
||
- git config --global http.sslVerify false
|
||
- git clone https://github.com/iamsedatozturk/kurs-platform.git
|
||
- cd kurs-platform/
|
||
- git config core.fileMode false
|
||
- chmod 775 *
|
||
- cd configs/deployment
|
||
- chmod 775 *
|
||
- cd configs
|
||
- chmod 775 *
|
||
- cd ..
|
||
- cd scripts
|
||
- chmod 775 *
|
||
- cd ~/kurs-platform/configs/deployment/scripts/
|
||
- İçerisindeki ihtiyaç olan scriptler çalıştırılır.
|
||
- n8n çalışmayınca n8n containerını çalıştırır ve hızlıca `docker run --rm -v kurs-devops_n8n_data:/data alpine chown -R 1000:1000 /data` kodu çalıştırılacak.
|
||
|
||
## Nginx Kurulumu
|
||
|
||
- sudo apt update
|
||
- sudo apt install nginx -y
|
||
- sudo systemctl status nginx
|
||
- sudo rm /etc/nginx/sites-enabled/default
|
||
- sudo rm /etc/nginx/sites-enabled/nginx.conf
|
||
- sudo cp ~/kurs-platform/configs/deployment/configs/nginx.conf /etc/nginx/sites-available/
|
||
- sudo ln -s /etc/nginx/sites-available/nginx.conf /etc/nginx/sites-enabled/
|
||
- sudo cp -r ./sozsoft.com /etc/ssl/sozsoft.com
|
||
- sudo systemctl restart nginx
|
||
- sudo nginx -t
|
||
|
||
## Forgejo kurulumu ayarları yapılacak
|
||
|
||
- home klasöründeki `cd ~/forgejo/data/gitea/conf` klasörün altındaki app.ini dosyasına aşağıdaki satırlar eklenecek.
|
||
[server]
|
||
APP_DATA_PATH = /data/gitea
|
||
DOMAIN = devops.sozsoft.com
|
||
SSH_DOMAIN = devops.sozsoft.com
|
||
DISABLE_SSH = false
|
||
SSH_PORT = 222
|
||
SSH_LISTEN_PORT = 22
|
||
LFS_START_SERVER = true
|
||
LFS_JWT_SECRET = CDy3ldC2cTbYHalO_dH68QJseoD7dGvH9x0Zx9aq2J0
|
||
OFFLINE_MODE = true
|
||
PROTOCOL=http
|
||
HTTP_PORT = 3000
|
||
ROOT_URL = https://devops.sozsoft.com/
|
||
CERT_FILE = /etc/ssl/cert1.pem
|
||
KEY_FILE = /etc/ssl/privkey1.pem
|
||
- https://devops.sozsoft.com
|
||
- sedat.ozturk isimli kullanıcı tanımlanacak.
|
||
- "kurs" isimli new organization tanımlanacak.
|
||
- "kurs-platform" isimli repository kurs organizasyonunun içerisine tanımlanacak.
|
||
- Fork üzerinden https://devops.sozsoft.com/user/settings/applications kısmına "sozsoft.com" ismiyle Access Token ekle. Eklenen token bilgisi Fork içerisinde kullanılacak.
|
||
- Fork üzerinden Remotes tanımlaması yapılacak.
|
||
Remote: devops.sozsoft.com
|
||
RepositoryUrl: https://sedat.ozturk:1b48921c4cc6cd5c79e8ac121ede9f78afd1d9be@devops.sozsoft.com/kurs/kurs-platform.git
|
||
- https://devops.sozsoft.com/user/settings/applications sayfasında OAuth2 kısmında "sozsoft.com" ismiyle Application Name eklenecek. Redirect URL kısmında https://devops.sozsoft.com eklenecektir.
|
||
|
||
## docker-compose-devops.yml kurulumu
|
||
|
||
Bu kurulumu yapmak için home klasörü altına 3 tane dosyaya ihtiyaç duyuyor.
|
||
|
||
- Klasör yapısı
|
||
cd ~/
|
||
mkdir kurs-platform
|
||
cd kurs-platform
|
||
mkdir configs
|
||
cd configs
|
||
mkdir deployment
|
||
cd deployment
|
||
mkdir configs
|
||
|
||
- Dosya yapısı
|
||
-> kurs-platform->configs->deployment->configs->nginx-devops.conf
|
||
-> kurs-platform->configs->deployment->docker-compose-devops.yml
|
||
-> kurs-platform->configs->deployment->Dockerfile
|
||
|
||
cd ~/kurs-platform/configs/deployment
|
||
chmod 775 *
|
||
cd ~/kurs-platform
|
||
docker compose -f ./docker-compose-devops.yml up -d
|
||
docker compose -f ./docker-compose-devops.yml down
|
||
docker compose -f ./docker-compose-devops.yml up -d
|
||
|
||
## hosts yönlendirme
|
||
- 192.168.0.2 devops.sozsoft.com
|
||
- 192.168.0.2 chat.sozsoft.com
|
||
- 192.168.0.2 ai.sozsoft.com
|
||
- 192.168.0.2 sozsoft.com
|
||
- 192.168.0.2 demo.sozsoft.com
|
||
- 192.168.0.2 kurs.sozsoft.com
|
||
- 192.168.0.2 kurs-api.sozsoft.com
|
||
- 192.168.0.2 kurs-cdn.sozsoft.com
|
||
|
||
`ipconfig /flushdns` |