From bc190ec349cb912ff43e39971d78c52ad3444eda Mon Sep 17 00:00:00 2001 From: Supanut Date: Sun, 21 Jun 2026 00:09:09 +0700 Subject: [PATCH 1/4] fix: fix dockerfile and docker compose workflow --- .dockerignore | 46 ++++++++++++++++++++++++++++++++++++++++------ Dockerfile | 1 + Program.cs | 7 +++++-- compose.yaml | 3 ++- 4 files changed, 48 insertions(+), 9 deletions(-) diff --git a/.dockerignore b/.dockerignore index 79cec24..e2606cb 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,9 +1,43 @@ -**/bin/ -**/obj/ - -.git/ -.github/ -.vscode/ +# Build results +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ +# Visual Studio +.vs/ *.user *.suo +*.userosscache +*.sln.docstates + +# User-specific files +*.rsuser +*.userprefs + +# Build outputs +*.dll +*.exe +*.pdb +*.cache + +# NuGet +*.nupkg +*.snupkg +packages/ +.nuget/ + +# Test results +TestResults/ +*.trx + +# VS Code +.vscode/ +!.vscode/tasks.json +!.vscode/launch.json + +# Rider +.idea/ + +# Environment files (if they contain secrets) +*.env diff --git a/Dockerfile b/Dockerfile index 44eff6f..84c9b1f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,5 +14,6 @@ RUN apt-get update \ && apt-get install -y --no-install-recommends libgssapi-krb5-2 \ && rm -rf /var/lib/apt/lists/* COPY --from=build /app/publish . +ENV ASPNETCORE_URLS=http://+:5000 EXPOSE 5000 ENTRYPOINT ["dotnet", "EazyTrade.dll"] \ No newline at end of file diff --git a/Program.cs b/Program.cs index 5b0ca8a..2253bc8 100644 --- a/Program.cs +++ b/Program.cs @@ -92,8 +92,11 @@ var app = builder.Build(); #region Middleware -// Enforce HTTPS first for all incoming traffic -app.UseHttpsRedirection(); +// Enforce HTTPS first for all incoming traffic (disabled in development/Docker testing) +if (!app.Environment.IsDevelopment()) +{ + app.UseHttpsRedirection(); +} // Serve API documentation only in development environment if (app.Environment.IsDevelopment()) diff --git a/compose.yaml b/compose.yaml index e655ce3..fcce683 100644 --- a/compose.yaml +++ b/compose.yaml @@ -10,6 +10,7 @@ services: condition: service_healthy environment: ASPNETCORE_URLS: http://+:5000 + # ASPNETCORE_ENVIRONMENT: Development ConnectionStrings__DefaultConnection: Host=database;Port=5432;Database=EazyTrade;Username=supernut_t;Password=29042547 ports: - "5000:5000" @@ -50,7 +51,7 @@ services: entrypoint: - /bin/sh - -lc - - PGPASSWORD="$$SOURCE_DB_PASSWORD" pg_dump -h "$$SOURCE_DB_HOST" -p "$$SOURCE_DB_PORT" -U "$$SOURCE_DB_USER" -d "$$SOURCE_DB_NAME" --no-owner --no-privileges > /tmp/backup.sql && PGPASSWORD="$$TARGET_DB_PASSWORD" psql -h "$$TARGET_DB_HOST" -p "$$TARGET_DB_PORT" -U "$$TARGET_DB_USER" -d "$$TARGET_DB_NAME" -f /tmp/backup.sql + - PGPASSWORD="$$SOURCE_DB_PASSWORD" pg_dump -h "$$SOURCE_DB_HOST" -p "$$SOURCE_DB_PORT" -U "$$SOURCE_DB_USER" -d "$$SOURCE_DB_NAME" --clean --if-exists --no-owner --no-privileges > /tmp/backup.sql && PGPASSWORD="$$TARGET_DB_PASSWORD" psql -h "$$TARGET_DB_HOST" -p "$$TARGET_DB_PORT" -U "$$TARGET_DB_USER" -d "$$TARGET_DB_NAME" -f /tmp/backup.sql volumes: postgres_data: From 51d6a7bc0b5e0c457e8f1e5bb458d4a4e7055c8c Mon Sep 17 00:00:00 2001 From: Supanut Date: Sun, 21 Jun 2026 00:13:06 +0700 Subject: [PATCH 2/4] chore: remove space --- Program.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Program.cs b/Program.cs index 2253bc8..40216d1 100644 --- a/Program.cs +++ b/Program.cs @@ -87,8 +87,6 @@ builder.Services.Configure(builder.Configuration.GetSection(AwsS3Configuration.Section)); #endregion - - var app = builder.Build(); #region Middleware From c895be5403c619664aaa382ff8328261ff15db51 Mon Sep 17 00:00:00 2001 From: Supanut Date: Sun, 21 Jun 2026 00:30:12 +0700 Subject: [PATCH 3/4] fix: correct config by use case --- Program.cs | 7 ++----- compose.yaml | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Program.cs b/Program.cs index 40216d1..1b7e5c9 100644 --- a/Program.cs +++ b/Program.cs @@ -90,11 +90,8 @@ var app = builder.Build(); #region Middleware -// Enforce HTTPS first for all incoming traffic (disabled in development/Docker testing) -if (!app.Environment.IsDevelopment()) -{ - app.UseHttpsRedirection(); -} +// Enforce HTTPS first for all incoming traffic +app.UseHttpsRedirection(); // Serve API documentation only in development environment if (app.Environment.IsDevelopment()) diff --git a/compose.yaml b/compose.yaml index fcce683..f34d71a 100644 --- a/compose.yaml +++ b/compose.yaml @@ -10,7 +10,6 @@ services: condition: service_healthy environment: ASPNETCORE_URLS: http://+:5000 - # ASPNETCORE_ENVIRONMENT: Development ConnectionStrings__DefaultConnection: Host=database;Port=5432;Database=EazyTrade;Username=supernut_t;Password=29042547 ports: - "5000:5000" From f38bdded95d53c01f5a68533a79f74cfcde03260 Mon Sep 17 00:00:00 2001 From: Supanut Date: Sun, 21 Jun 2026 01:59:24 +0700 Subject: [PATCH 4/4] fix: add sonarqube ignore on gitignore and dockerignore --- .dockerignore | 5 +++++ .gitignore | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index e2606cb..61fa61d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -41,3 +41,8 @@ TestResults/ # Environment files (if they contain secrets) *.env + +# SonarQube / SonarScanner +.sonarqube/ +.sonar/ +.scannerwork/ diff --git a/.gitignore b/.gitignore index 249045a..300be0a 100644 --- a/.gitignore +++ b/.gitignore @@ -45,4 +45,9 @@ appsettings.Development.json # app setting appsettings.*.json -appsettings.json \ No newline at end of file +appsettings.json + +# SonarQube / SonarScanner +.sonarqube/ +.sonar/ +.scannerwork/ \ No newline at end of file