App ayarları değiştirildi.

This commit is contained in:
Sedat ÖZTÜRK 2025-05-08 10:17:50 +03:00
parent 7d8c335836
commit bdea6e655a
11 changed files with 137 additions and 4080 deletions

View file

@ -1,40 +0,0 @@
using System;
using System.Text.Json;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Kurs.Platform.Migrations
{
/// <inheritdoc />
public partial class LogEntry : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "PLogEntry",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Timestamp = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Level = table.Column<string>(type: "text", nullable: true, collation: "tr-x-icu"),
Message = table.Column<string>(type: "text", nullable: true, collation: "tr-x-icu"),
MessageTemplate = table.Column<string>(type: "text", nullable: true, collation: "tr-x-icu"),
Exception = table.Column<string>(type: "text", nullable: true, collation: "tr-x-icu"),
Properties = table.Column<JsonDocument>(type: "jsonb", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PLogEntry", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PLogEntry");
}
}
}

View file

@ -1,6 +1,5 @@
// <auto-generated />
using System;
using System.Text.Json;
using Kurs.Platform.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
@ -1473,38 +1472,6 @@ namespace Kurs.Platform.Migrations
b.ToTable("PListFormField", (string)null);
});
modelBuilder.Entity("Kurs.Platform.Entities.LogEntry", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<string>("Exception")
.HasColumnType("text")
.UseCollation("tr-x-icu");
b.Property<string>("Level")
.HasColumnType("text")
.UseCollation("tr-x-icu");
b.Property<string>("Message")
.HasColumnType("text")
.UseCollation("tr-x-icu");
b.Property<string>("MessageTemplate")
.HasColumnType("text")
.UseCollation("tr-x-icu");
b.Property<JsonDocument>("Properties")
.HasColumnType("jsonb");
b.Property<DateTime>("Timestamp")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.ToTable("PLogEntry", (string)null);
});
modelBuilder.Entity("Kurs.Platform.Entities.Menu", b =>
{
b.Property<Guid>("Id")

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
@ -6,6 +7,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Sinks.PostgreSQL;
namespace Kurs.Platform;
@ -19,8 +21,26 @@ public class Program
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? ""}.json", true)
.Build();
var columnWriters = new Dictionary<string, ColumnWriterBase>
{
{ "Message", new RenderedMessageColumnWriter() },
{ "Message_Template", new MessageTemplateColumnWriter() },
{ "Level", new LevelColumnWriter() },
{ "Timestamp", new TimestampColumnWriter() },
{ "Exception", new ExceptionColumnWriter() },
{ "Properties", new LogEventSerializedColumnWriter() }
};
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.MinimumLevel.Information()
.WriteTo.PostgreSQL(
connectionString: configuration.GetConnectionString("Default"),
tableName: "PLogEntry",
columnOptions: columnWriters,
needAutoCreateTable: true,
respectCase: true
)
.CreateLogger();
try

View file

@ -23,34 +23,9 @@
"StringEncryption": {
"DefaultPassPhrase": "UQpiYfT79zRZ3yYH"
},
"Elastic": {
"Url": "http://elastic:9200",
"Index": "dev"
},
"Serilog": {
"Using": ["Elastic.Serilog.Sinks", "Serilog.Sinks.Console"],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Information",
"Microsoft.EntityFrameworkCore": "Warning",
"Microsoft.AspNetCore": "Warning",
"OpenIddict": "Information"
}
},
"Enrich": ["FromLogContext"],
"WriteTo:Async": {
"Name": "Async",
"Args": {
"configure": [
{
"Name": "Console",
"Args": {
"outputTemplate": "{Level}: {Message:lj} {Properties:j}{NewLine}{Exception}"
}
}
]
}
"Default": "Information"
}
}
}

View file

@ -23,34 +23,9 @@
"StringEncryption": {
"DefaultPassPhrase": "UQpiYfT79zRZ3yYH"
},
"Elastic": {
"Url": "http://elastic:9200",
"Index": "prod"
},
"Serilog": {
"Using": ["Elastic.Serilog.Sinks", "Serilog.Sinks.Console"],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Information",
"Microsoft.EntityFrameworkCore": "Warning",
"Microsoft.AspNetCore": "Warning",
"OpenIddict": "Information"
}
},
"Enrich": ["FromLogContext"],
"WriteTo:Async": {
"Name": "Async",
"Args": {
"configure": [
{
"Name": "Console",
"Args": {
"outputTemplate": "{Level}: {Message:lj} {Properties:j}{NewLine}{Exception}"
}
}
]
}
"Default": "Information"
}
}
}

View file

@ -24,38 +24,9 @@
"StringEncryption": {
"DefaultPassPhrase": "UQpiYfT79zRZ3yYH"
},
"Elastic": {
"Url": "http://localhost:9200",
"Index": "dev"
},
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"WriteTo": [
{
"Name": "PostgreSQL",
"Args": {
"connectionString": "User ID=sa;Password=NvQp8s@l;Host=localhost;Port=5432;Database=Demo;",
"tableName": "LogEntry",
"needAutoCreateTable": false,
"columnOptions": {
"timestamp": { "ColumnName": "timestamp" },
"level": { "ColumnName": "level" },
"message": { "ColumnName": "message" },
"messageTemplate": { "ColumnName": "message_template" },
"exception": { "ColumnName": "exception" },
"properties": {
"ColumnName": "properties",
"Store": "Json"
"Default": "Information"
}
}
}
}
]
}
}

View file

@ -0,0 +1,110 @@
# 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
-
## 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 *
## docker-compose-devops.yml kurulumu
Bu kurulumu yapmak için home klasörü altına 3 tane dosyaya ihtiyaç duyuyor. Aşağıdaki klasör ve dosya yapısı kurulmalıdır.
-> kurs-platform->configs->deployment->configs->nginx-devops.conf
-> kurs-platform->configs->deployment->docker-compose-devops.yml
-> kurs-platform->configs->deployment->Dockerfile
Bu dosyaları el ile oluşturduğumuz için kullanım yetkisi yok. Yetki verebilmek için configs->deployment klasöründe aşağıdaki kod çalıştırılır.
-> chmod 775 *
`docker compose -f ./docker-compose-devops.yml up -d` kodu çalıştırıldı.
n8n çalışmayınca `docker run --rm -v kurs-devops_n8n_data:/data alpine chown -R 1000:1000 /data` kodu çalıştırılacak.
`docker compose -f ./docker-compose-devops.yml down` kodu çalıştırıldı.
`docker compose -f ./docker-compose-devops.yml up -d` kodu çalıştırıldı.
## devops.sozsoft.com olarak sanal dns isimlendirmesi
/etc/hosts dosyasıılacak ve içerisine `127.0.1.1 devops.sozsoft.com` eklenecek
## Docker ayarları yapılacak
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"]
}
docker login devops.sozsoft.com
## Forgejo 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 kurulumu ayarları
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 Remotes tanımlaması yapılacak. Remote: devops.sozsoft.com RepositoryUrl: https://devops.sozsoft.com/kurs/kurs-platform
Fork üzerinden Authorization işlemi yapılacak URL kısmı localhost olarak geliyor. Onu devops.sozsoft.com olarak değiştirmek gerekiyor.
cd ~
git config core.fileMode false
git config --global http.sslVerify false
git clone https://devops.sozsoft.com/kurs/kurs-platform.git
## Build
~/kurs-platform klasöründe `chmod 775 *` çalıştırılacak
~/kurs-platform/configs/deployment klasöründe `chmod 775 *` çalıştırılacak
~/kurs-platform/configs/deployment/scripts klasöründe `chmod 775 *` çalıştırılacak
~/kurs-platform/configs/deployment/configs klasöründe `chmod 775 *` çalıştırılacak

View file

@ -3,8 +3,6 @@ name: kurs-platform-app
networks:
kurs-platform-data_db:
external: true
kurs-platform-data_log:
external: true
volumes:
cdn:
@ -19,7 +17,6 @@ services:
- SEED=${SEED}
networks:
- kurs-platform-data_db
- kurs-platform-data_log
api:
image: devops.sozsoft.com/kurs/kurs-platform-api:latest
profiles: ["app"]
@ -27,7 +24,6 @@ services:
- ASPNETCORE_ENVIRONMENT=Dev
networks:
- kurs-platform-data_db
- kurs-platform-data_log
- default
volumes:
- cdn:/etc/api/cdn

View file

@ -4,8 +4,6 @@ name: kurs-platform-data
networks:
db:
external: false
log:
external: false
volumes:
sql-pg:

View file

@ -82,7 +82,7 @@ define(['./workbox-54d0af47'], (function (workbox) { 'use strict';
"revision": "3ca0b8505b4bec776b69afdba2768812"
}, {
"url": "index.html",
"revision": "0.85ufv4pqo4o"
"revision": "0.gqab4md54bg"
}], {});
workbox.cleanupOutdatedCaches();
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {