Files
taxbaik/TaxBaik.Admin/Program.cs
T
kjh2064 6963152e97
TaxBaik CI/CD / build-and-deploy (push) Failing after 29s
배포 버전 정보 표시 및 포트 충돌 해결
### 버전 정보 표시 기능
- CI/CD에서 빌드 시간과 git commit hash를 version.txt에 기록
- Web과 Admin 앱이 시작 시 version.txt를 읽어 VersionInfo 싱글톤으로 등록
- 홈페이지 푸터에 "버전: <커밋해시> | 배포: <빌드시간>" 표시
- 최신 소스 반영 여부를 즉시 확인 가능

### 포트 충돌 해결
- 배포 후 기존 프로세스 종료 시 포트 릴리스 대기 로직 추가
- lsof 명령으로 포트 사용 여부 확인 (최대 30초 대기)
- 5001/5002 포트가 완전히 릴리스될 때까지 new process 시작 지연
- "Address already in use" 오류 해결

파일 변경:
- .gitea/workflows/deploy.yml: 버전 파일 생성 + 포트 대기 로직
- TaxBaik.Web/Program.cs: version.txt 읽기 + VersionInfo 등록
- TaxBaik.Admin/Program.cs: version.txt 읽기 + VersionInfo 등록
- TaxBaik.Web/Pages/Shared/_Footer.cshtml: 버전 정보 표시
- TaxBaik.Web/VersionInfo.cs: 새로 추가
- TaxBaik.Admin/VersionInfo.cs: 새로 추가

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-26 17:13:12 +09:00

69 lines
2.1 KiB
C#

using Microsoft.AspNetCore.Authentication.Cookies;
using MudBlazor.Services;
using TaxBaik.Application;
using TaxBaik.Infrastructure;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(opts => {
opts.LoginPath = "/login";
opts.ExpireTimeSpan = TimeSpan.FromHours(8);
opts.Cookie.SameSite = SameSiteMode.Lax;
});
builder.Services.AddAuthorizationCore();
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.Services.AddMudServices();
builder.Services.AddMemoryCache();
builder.Services.AddInfrastructure();
builder.Services.AddApplication();
// Register version info
var versionInfo = new VersionInfo();
var versionFilePath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "version.txt");
if (File.Exists(versionFilePath))
{
var lines = File.ReadAllLines(versionFilePath);
foreach (var line in lines)
{
if (line.StartsWith("Version:"))
versionInfo.Version = line.Substring("Version:".Length).Trim();
else if (line.StartsWith("Built:"))
versionInfo.Built = line.Substring("Built:".Length).Trim();
}
}
builder.Services.AddSingleton(versionInfo);
var app = builder.Build();
// Run migrations on startup
using (var scope = app.Services.CreateScope())
{
var connectionFactory = scope.ServiceProvider.GetRequiredService<TaxBaik.Domain.Interfaces.IDbConnectionFactory>();
var cs = builder.Configuration.GetConnectionString("Default")
?? throw new InvalidOperationException("Missing connection string");
var migrationRunner = new TaxBaik.Infrastructure.Data.MigrationRunner(cs, connectionFactory);
await migrationRunner.RunAsync();
}
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
app.UseHsts();
}
app.UsePathBase("/taxbaik/admin");
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseAntiforgery();
app.MapRazorComponents<TaxBaik.Admin.Components.App>()
.AddInteractiveServerRenderMode();
app.Run();