Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
21 changes: 13 additions & 8 deletions docker-local-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -49,5 +55,4 @@ services:


volumes:
postgres_data: # Declares the named volume 'postgres_data'
webapi:
postgres_data: # Declares the named volume 'postgres_data'
8 changes: 4 additions & 4 deletions src/Web.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -52,7 +52,7 @@

app.UseAuthentication();

app.UseCors("AllowAngular");
app.UseCors("Allowed_Origins");

app.UseAuthorization();

Expand Down