From 2c702976b25a148a108bd84117dec1236bcab215 Mon Sep 17 00:00:00 2001 From: Abdullah Al Sazib Date: Sun, 30 Nov 2025 18:41:08 +0600 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20Add=20deployment=20step=20to=20?= =?UTF-8?q?CI/CD=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci-cd.yml | 54 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 9124066..900281e 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -30,30 +30,30 @@ jobs: push: true tags: ghcr.io/dapplesoft-ad/auth-server:latest - # deploy-on-server: - # runs-on: ubuntu-latest - # needs: build-and-push - # steps: - # - name: Deploy on server via SSH - # uses: appleboy/ssh-action@v1.2.0 - # with: - # host: ${{ secrets.SERVER_IP }} - # username: ${{ secrets.SERVER_USER }} - # key: ${{ secrets.SERVER_SSH_KEY }} - # script: | - # echo "Starting deployment..." - # # Login to GHCR on VPS using PAT - # echo "${{ secrets.SERVER_GHCR_PAT }}" | docker login ghcr.io -u "dapplesoft-ad" --password-stdin - # echo "Logged in to GitHub Container Registry" - # # Navigate to Docker compose directory - # cd /home/dapplesoft-ad/apps/docker-composes - # # Pull latest image for the auth server service - # docker compose -f auth-server.yml pull auth-server - # echo "Pulled latest image" - # # Recreate the container with the updated image - # docker compose -f auth-server.yml up -d --force-recreate auth-server - # echo "Recreated container with latest image" - # # Clean unused images safely - # docker image prune -f || true - # echo "Cleaned unused Docker images" - # echo "Deployment complete" + deploy-on-server: + runs-on: ubuntu-latest + needs: build-and-push + steps: + - name: Deploy on server via SSH + uses: appleboy/ssh-action@v1.2.0 + with: + host: ${{ secrets.SERVER_IP }} + username: ${{ secrets.SERVER_USER }} + key: ${{ secrets.SERVER_SSH_KEY }} + script: | + echo "Starting deployment..." + # Login to GHCR on VPS using PAT + echo "${{ secrets.SERVER_GHCR_PAT }}" | docker login ghcr.io -u "dapplesoft-ad" --password-stdin + echo "Logged in to GitHub Container Registry" + # Navigate to Docker compose directory + cd /home/dapplesoft/apps/docker-compose + # Pull latest image for the auth server service + docker compose -f auth-server.yml pull auth-server + echo "Pulled latest image" + # Recreate the container with the updated image + docker compose -f auth-server.yml up -d --force-recreate auth-server + echo "Recreated container with latest image" + # Clean unused images safely + docker image prune -f || true + echo "Cleaned unused Docker images" + echo "Deployment complete" From 8b67edb688c68d41f5d9a6eb33104da635592d48 Mon Sep 17 00:00:00 2001 From: Hasan Uddin Date: Mon, 1 Dec 2025 14:29:26 +0600 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A9=B9=20CORS=20Fix=5F2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-local-compose.yml | 21 +++++++++++++-------- src/Web.Api/Program.cs | 8 ++++---- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/docker-local-compose.yml b/docker-local-compose.yml index c979651..a177e4a 100644 --- a/docker-local-compose.yml +++ b/docker-local-compose.yml @@ -5,16 +5,22 @@ services: build: context: . dockerfile: ./Dockerfile - volumes: - - webapi:/app/ ports: - 5000:8080 - 5001:8081 environment: - - ASPNETCORE_ENVIRONMENT=Development - - ConnectionStrings__Database=Host=postgres;Port=5432;Database=clean-architecture;Username=postgres;Password=1234 - - ASPNETCORE_URLS=http://+:8080;http://+:8081 - - Jwt__Secret=YOUR_SECURE_GENERATED_SECRET + ASPNETCORE_ENVIRONMENT: Development + ConnectionStrings__Database: Host=postgres;Port=5432;Database=clean-architecture;Username=postgres;Password=1234 + ASPNETCORE_URLS: http://+:8080;http://+:8081 + Jwt__Secret: YOUR_SECURE_GENERATED_SECRET + Cors__AllowedOrigins__0: "http://localhost:4200" + Cors__AllowedOrigins__1: "https://localhost:4200" + Cors__AllowedOrigins__2: "http://localhost:40033" + Cors__AllowedOrigins__3: "https://localhost:40003" + Cors__AllowedOrigins__4: "http://auth.dapplesoft.com" + Cors__AllowedOrigins__5: "https://auth.dapplesoft.com" + Cors__AllowedOrigins__6: "http://authapi.dapplesoft.com" + Cors__AllowedOrigins__7: "https://authapi.dapplesoft.com" restart: on-failure depends_on: postgres: @@ -49,5 +55,4 @@ services: volumes: - postgres_data: # Declares the named volume 'postgres_data' - webapi: \ No newline at end of file + postgres_data: # Declares the named volume 'postgres_data' \ No newline at end of file diff --git a/src/Web.Api/Program.cs b/src/Web.Api/Program.cs index 235620d..91d9c47 100644 --- a/src/Web.Api/Program.cs +++ b/src/Web.Api/Program.cs @@ -21,10 +21,10 @@ .AddPresentation() .AddInfrastructure(builder.Configuration); -builder.Services.AddCors(options => options.AddPolicy("AllowAngular", builder => builder +builder.Services.AddCors(options => options.AddPolicy("Allowed_Origins", builder => builder .WithOrigins(allowedOrigins) - .AllowAnyMethod() - .AllowAnyHeader() + .WithMethods("GET", "POST", "PUT", "DELETE") + .WithHeaders("Content-Type", "Authorization") .AllowCredentials())); builder.Services.AddEndpoints(Assembly.GetExecutingAssembly()); @@ -52,7 +52,7 @@ app.UseAuthentication(); -app.UseCors("AllowAngular"); +app.UseCors("Allowed_Origins"); app.UseAuthorization();