(feature): deployments, docker build and push to cr script
This commit is contained in:
parent
a6f3089cb5
commit
5f4f0772e2
7
src/Release-DockerImage.bat
Normal file
7
src/Release-DockerImage.bat
Normal 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"
|
||||
36
src/Release-DockerImage.ps1
Normal file
36
src/Release-DockerImage.ps1
Normal 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
|
||||
@ -15,13 +15,28 @@ spec:
|
||||
annotations:
|
||||
dapr.io/enabled: "true"
|
||||
dapr.io/app-id: "publisher"
|
||||
dapr.io/app-port: "3000"
|
||||
dapr.io/app-port: "5000" # Adjust to your service port
|
||||
spec:
|
||||
containers:
|
||||
- name: publisher
|
||||
image: daprio/quickstart-pubsub-publisher
|
||||
ports:
|
||||
- containerPort: 3000
|
||||
- name: publisher
|
||||
image: cr.maks-it.com/dapr-test/subscriber:latest
|
||||
ports:
|
||||
- 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:
|
||||
dapr.io/enabled: "true"
|
||||
dapr.io/app-id: "subscriber"
|
||||
dapr.io/app-port: "3001"
|
||||
dapr.io/app-port: "5000" # Adjust to match the subscriber service port
|
||||
spec:
|
||||
containers:
|
||||
- name: subscriber
|
||||
image: daprio/quickstart-pubsub-subscriber
|
||||
ports:
|
||||
- containerPort: 3001
|
||||
env:
|
||||
- name: PUBSUB_TOPIC
|
||||
value: "pubsub" # The topic used by pubsub component
|
||||
- name: STATE_STORE
|
||||
value: "statestore" # The name of your statestore component
|
||||
- name: subscriber
|
||||
image: cr.maks-it.com/dapr-test/subscriber:latest
|
||||
ports:
|
||||
- containerPort: 5000 # Match the internal port of the subscriber service
|
||||
|
||||
@ -10,7 +10,7 @@ spec:
|
||||
- name: redisHost
|
||||
value: redis:6379
|
||||
- name: keyPrefix
|
||||
value: none # Disables prefixing
|
||||
value: none
|
||||
|
||||
---
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user