-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19698ae
commit 59de992
Showing
5 changed files
with
92 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,8 @@ on: | |
workflow_dispatch: | ||
|
||
env: | ||
DOCKER_IMAGE_NAME: tranvuongduy2003/eventhub-api:linux-latest # Replace with your Docker Hub repo name | ||
REGISTRY: ${{ secrets.SERVER_IP }}:5000 | ||
DOCKER_IMAGE_NAME: eventhub-api # Replace with your Docker Hub repo name | ||
CONTAINER_NAME: "eventhub.api" | ||
|
||
jobs: | ||
|
@@ -16,16 +17,20 @@ jobs: | |
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Log in to Docker Hub | ||
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | ||
|
||
- name: Build Docker image | ||
run: | | ||
docker build -t $DOCKER_IMAGE_NAME -f source/EventHub.Presentation/Dockerfile . | ||
- name: Push Docker image to Docker Hub | ||
run: docker push $DOCKER_IMAGE_NAME | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
config-inline: | | ||
[registry."${{ secrets.SERVER_IP }}:5000"] | ||
http = true | ||
insecure = true | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./source/EventHub.Presentation/Dockerfile | ||
push: true | ||
tags: ${{ secrets.SERVER_IP }}:5000/eventhub-api:linux-latest | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
|
@@ -43,37 +48,15 @@ jobs: | |
sudo apt-get install -y sshpass | ||
- name: Deploy Docker container on remote server | ||
env: | ||
SERVER_IP: ${{ secrets.SERVER_IP }} | ||
SERVER_USERNAME: ${{ secrets.SERVER_USERNAME }} | ||
SERVER_PASSWORD: ${{ secrets.SERVER_PASSWORD }} | ||
DATABASE_USERNAME: ${{ secrets.DATABASE_USERNAME }} | ||
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} | ||
MONGO_DB_ROOT_USERNAME: ${{ secrets.MONGO_DB_ROOT_USERNAME }} | ||
MONGO_DB_ROOT_PASSWORD: ${{ secrets.MONGO_DB_ROOT_PASSWORD }} | ||
run: | | ||
sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no $SERVER_USERNAME@$SERVER_IP << EOF | ||
# Login to Docker Hub | ||
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | ||
# Pull the latest image from Docker Hub | ||
docker pull $DOCKER_IMAGE_NAME | ||
# Stop and remove the old container if it exists | ||
sshpass -p "${{ secrets.SERVER_PASSWORD }}" ssh -o StrictHostKeyChecking=no ${{ secrets.SERVER_USERNAME}}@${{ secrets.SERVER_IP }} << EOF | ||
docker pull "127.0.0.1:5000/${DOCKER_IMAGE_NAME}:linux-latest" | ||
docker stop $CONTAINER_NAME || true | ||
docker rm $CONTAINER_NAME || true | ||
# Run the new container | ||
docker container rm $CONTAINER_NAME || true | ||
docker run -d --name $CONTAINER_NAME \ | ||
--network eventhub \ | ||
-p 5002:80 \ | ||
-e ASPNETCORE_ENVIRONMENT=Development \ | ||
-e ASPNETCORE_URLS=http://+:80 \ | ||
-e "ConnectionStrings:DefaultConnectionString=Server=eventhub.db,1433;Database=EventHubDB;User Id=$DATABASE_USERNAME;Password=$DATABASE_PASSWORD;TrustServerCertificate=True;Multipleactiveresultsets=true" \ | ||
-e "ConnectionStrings:CacheConnectionString=eventhub.cache:6379" \ | ||
-e "SeqConfiguration:ServerUrl=http://eventhub.seq:5341" \ | ||
-e "HangfireSettings:Storage:ConnectionString=mongodb://$MONGO_DB_ROOT_USERNAME:[email protected]:27017/hangfire-webapi?authSource=admin" \ | ||
-v "${APPDATA}/Microsoft/UserSecrets:/home/app/.microsoft/usersecrets:ro" \ | ||
-v "${APPDATA}/ASP.NET/Https:/home/app/.aspnet/https:ro" \ | ||
$DOCKER_IMAGE_NAME | ||
"${{ secrets.SERVER_IP }}:5000/${DOCKER_IMAGE_NAME}:linux-latest" | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"AllowedHosts": "*", | ||
"ConnectionStrings": { | ||
"DefaultConnectionString": "Server=localhost,1437;Database=EventHubDB;User Id=sa;Password=@Admin123;TrustServerCertificate=True;Multipleactiveresultsets=true", | ||
"CacheConnectionString": "localhost:6379", | ||
"AzureSignalRConnectionString": "" | ||
}, | ||
"JwtOptions": { | ||
"Secret": "VERY STRONG SECRET KEY BY TRAN VUONG DUY", | ||
"Issuer": "eventhub-auth-api", | ||
"Audience": "eventhub-client" | ||
}, | ||
"SeqConfiguration": { | ||
"ServerUrl": "http://localhost:5341" | ||
}, | ||
"AzureBlobStorage": { | ||
"StorageAccount": "eventhubstorage27072024", | ||
"Key": "zka6DrmOLJ1ejftXWJWMuHyf2wVehs470V4Z2D4zEigDBnx9dBGEtdpCsto3DDYTCwXqhn2Z7Vyy+AStjJUYJQ==", | ||
"ConnectionString": "DefaultEndpointsProtocol=https;AccountName=eventhubstorage27072024;AccountKey=zka6DrmOLJ1ejftXWJWMuHyf2wVehs470V4Z2D4zEigDBnx9dBGEtdpCsto3DDYTCwXqhn2Z7Vyy+AStjJUYJQ==;EndpointSuffix=core.windows.net", | ||
"ContainerName": "files" | ||
}, | ||
"Authentication": { | ||
"Google": { | ||
"ClientSecret": "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", | ||
"ClientId": "561476722239-kimb64ln11mqfpo2adm5rd60gcv96sud.apps.googleusercontent.com" | ||
}, | ||
"Facebook": { | ||
"ClientSecret": "4f9c952dbd98eba1390f04d09ee62e2f", | ||
"ClientId": "426547706699316" | ||
} | ||
}, | ||
"EmailSettings": { | ||
"Email": "[email protected]", | ||
"Password": "jqvckxgzkuwrynre", | ||
"Host": "smtp.gmail.com", | ||
"DisplayName": "EventHub", | ||
"Port": 587 | ||
}, | ||
"HangfireSettings": { | ||
"Route": "/jobs", | ||
"ServerName": "Hangfire Server", | ||
"Dashboard": { | ||
"AppPath": "/", | ||
"StatsPollingInterval": 2000, | ||
"DashboardTitle": "Jobs" | ||
}, | ||
"Storage": { | ||
"DBProvider": "mongodb", | ||
"ConnectionString": "mongodb://admin:admin@localhost:27018/hangfire-webapi?authSource=admin" | ||
} | ||
}, | ||
"Serilog": { | ||
"MinimumLevel": { | ||
"Default": "Information", | ||
"Override": { | ||
"Microsoft": "Information", | ||
"Microsoft.Hosting.Lifetime": "Information", | ||
"Microsoft.AspNetCore.Authentication": "Debug", | ||
"System": "Warning" | ||
} | ||
} | ||
} | ||
} |