(feature): deployments, docker build and push to cr script

This commit is contained in:
Maksym Sadovnychyy 2024-11-14 21:26:17 +01:00
parent a6f3089cb5
commit 5f4f0772e2
4 changed files with 69 additions and 16 deletions

View File

@ -0,0 +1,7 @@
@echo off
REM Change directory to the location of the script
cd /d %~dp0
REM Invoke the PowerShell script (Release-NuGetPackage.ps1) in the same directory
powershell -ExecutionPolicy Bypass -File "%~dp0Release-DockerImage.ps1"

View File

@ -0,0 +1,36 @@
# Set variables
$projectName = "dapr-test"
$harborUrl = "cr.maks-it.com" # e.g., "harbor.yourdomain.com"
$tag = "latest" # Customize the tag as needed
# Retrieve username and password from environment variable
$creds = $Env:CR_MAKS_IT -split '\|'
$harborUsername = $creds[0]
$harborPassword = $creds[1]
# Authenticate with Harbor
docker login $harborUrl -u $harborUsername -p $harborPassword
# List of services to build and push with the current context
$services = @{
"publisher" = "Publisher/Dockerfile"
"subscriber" = "Subscriber/Dockerfile"
}
$contextPath = "."
foreach ($service in $services.Keys) {
$dockerfilePath = $services[$service]
$imageName = "$harborUrl/$projectName/${service}:${tag}"
# Build the Docker image
Write-Output "Building image $imageName from $dockerfilePath..."
docker build -t $imageName -f $dockerfilePath $contextPath
# Push the Docker image
Write-Output "Pushing image $imageName..."
docker push $imageName
}
# Logout after pushing images
docker logout $harborUrl

View File

@ -15,13 +15,28 @@ spec:
annotations: annotations:
dapr.io/enabled: "true" dapr.io/enabled: "true"
dapr.io/app-id: "publisher" dapr.io/app-id: "publisher"
dapr.io/app-port: "3000" dapr.io/app-port: "5000" # Adjust to your service port
spec: spec:
containers: containers:
- name: publisher - name: publisher
image: daprio/quickstart-pubsub-publisher image: cr.maks-it.com/dapr-test/subscriber:latest
ports: ports:
- containerPort: 3000 - containerPort: 5000 # Match your internal app port
---
apiVersion: v1
kind: Service
metadata:
name: publisher-service
namespace: dapr-test
spec:
selector:
app: publisher
ports:
- protocol: TCP
port: 80
targetPort: 5000 # Match the internal port of the publisher service
--- ---
@ -42,15 +57,10 @@ spec:
annotations: annotations:
dapr.io/enabled: "true" dapr.io/enabled: "true"
dapr.io/app-id: "subscriber" dapr.io/app-id: "subscriber"
dapr.io/app-port: "3001" dapr.io/app-port: "5000" # Adjust to match the subscriber service port
spec: spec:
containers: containers:
- name: subscriber - name: subscriber
image: daprio/quickstart-pubsub-subscriber image: cr.maks-it.com/dapr-test/subscriber:latest
ports: ports:
- containerPort: 3001 - containerPort: 5000 # Match the internal port of the subscriber service
env:
- name: PUBSUB_TOPIC
value: "pubsub" # The topic used by pubsub component
- name: STATE_STORE
value: "statestore" # The name of your statestore component

View File

@ -10,7 +10,7 @@ spec:
- name: redisHost - name: redisHost
value: redis:6379 value: redis:6379
- name: keyPrefix - name: keyPrefix
value: none # Disables prefixing value: none
--- ---