Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wassim's changes to develop #3

Merged
merged 2 commits into from Mar 4, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
93 changes: 51 additions & 42 deletions azure.yaml
Expand Up @@ -3,51 +3,60 @@
name: contoso-real-estate
metadata:
template: contoso-real-estate@0.0.1
hooks:
postprovision:
shell: "sh"
continueOnError: false
interactive: true
# hooks:
# postprovision:
# shell: "sh"
# continueOnError: false
# interactive: true

# TODO: provide a cross platform way to run this script
run: ./scripts/database/restore.sh strapi_20230922
# # TODO: provide a cross platform way to run this script
# run: ./scripts/database/restore.sh strapi_20230922

services:
portal:
project: packages/portal
dist: dist/contoso-app
language: ts
host: staticwebapp
module: app/portal
hooks:
postpackage:
shell: sh
interactive: true
# Note: the current working directory is ./packages/portal
run: ../../infra/hooks/portal/predeploy.js

api:
project: packages/api
language: ts
host: function
module: app/api

cms:
project: packages/blog-cms
host: containerapp
language: js
module: app/cms
# portal:
# project: packages/portal
# dist: dist/contoso-app
# language: ts
# host: staticwebapp
# module: app/portal
# hooks:
# postpackage:
# shell: sh
# interactive: true
# # Note: the current working directory is ./packages/portal
# run: ../../infra/hooks/portal/predeploy.js

blog:
project: packages/blog
host: containerapp
notifications:
project: packages/notifications
docker:
context: .
path: ./Dockerfile
language: js
module: app/blog

stripe:
project: packages/stripe
host: containerapp
language: js
docker:
context: ../..
module: app/stripe
module: app/notifications

# api:
# project: packages/api
# language: ts
# host: function
# module: app/api

# cms:
# project: packages/blog-cms
# host: containerapp
# language: js
# module: app/cms

# blog:
# project: packages/blog
# host: containerapp
# language: js
# module: app/blog

# stripe:
# project: packages/stripe
# host: containerapp
# language: js
# docker:
# context: ../..
# module: app/stripe
9 changes: 9 additions & 0 deletions docker-compose.yml
@@ -1,6 +1,15 @@
version: "3"

services:
notifications:
build:
context: ./packages/notifications
environment:
SERVICE_WEB_PUBSUB_CONNECTION_STRING: "Endpoint=https://contoso-realtime.webpubsub.azure.com;AccessKey=rZbmrucfuf6Bg0emc1WD4y9Cw8CBK02Ui5Gg/UoMqZA=;Version=1.0;"
SERVICE_WEB_PUBSUB_PORT: 4300
ports:
- "4300:4300"

stripe:
build:
context: .
Expand Down
68 changes: 68 additions & 0 deletions infra/app/notifications-backend.bicep
@@ -0,0 +1,68 @@
param name string
param location string = resourceGroup().location
param tags object = {}
param serviceName string = 'notifications'

param applicationInsightsName string
param notificationsServiceName string
param containerAppsEnvironmentName string
param containerRegistryName string
param notificationsImageName string = ''
param keyVaultName string

var targetPort = 4300

module app '../core/host/container-app.bicep' = {
name: '${serviceName}-container-app-module'
params: {
name: name
location: location
tags: union(tags, { 'azd-service-name': '${serviceName}-container-app' })
containerAppsEnvironmentName: containerAppsEnvironmentName
containerRegistryName: containerRegistryName
containerCpuCoreCount: '1.0'
containerMemory: '2.0Gi'
secrets: [
{
name: 'appinsights-cs'
value: applicationInsights.properties.ConnectionString
}
{
name: 'webpubsub-cs'
value: awps.listKeys().primaryConnectionString
}
]
env: [
{
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
secretRef: 'appinsights-cs'
}
{
name: 'SERVICE_WEB_PUBSUB_CONNECTION_STRING'
secretRef: 'webpubsub-cs'
}
{
name: 'SERVICE_WEB_PUBSUB_PORT'
value: '${targetPort}'
}
]
imageName: !empty(notificationsImageName) ? notificationsImageName : 'nginx:latest'
keyVaultName: keyVault.name
targetPort: targetPort
}
}

resource applicationInsights 'Microsoft.Insights/components@2020-02-02' existing = {
name: applicationInsightsName
}

resource awps 'Microsoft.SignalRService/webPubSub@2023-02-01' existing = {
name: notificationsServiceName
}

resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = {
name: keyVaultName
}

output SERVICE_WEBPUBSUB_URI string = app.outputs.uri
output SERVICE_NOTIFICATIONS_IMAGE_NAME string = app.outputs.imageName
16 changes: 16 additions & 0 deletions infra/app/notifications.bicep
@@ -0,0 +1,16 @@
param name string
param location string = resourceGroup().location
param tags object = {}
param serviceName string = 'notifications'

module notifications '../core/pubsub/web-pub-sub.bicep' = {
name: '${serviceName}-awps-module'
params: {
name: name
location: location
tags: union(tags, { 'azd-service-name': '${serviceName}-awps' })
sku: 'Free_F1'
}
}

output SERVICE_WEBPUBSUB_NAME string = notifications.outputs.name
98 changes: 98 additions & 0 deletions infra/core/pubsub/web-pub-sub.bicep
@@ -0,0 +1,98 @@
@description('The name for your new Web PubSub instance.')
@maxLength(63)
@minLength(3)
param name string = uniqueString(resourceGroup().id)

param tags object = {}

@description('The region in which to create the new instance, defaults to the same location as the resource group.')
param location string = resourceGroup().location

@description('Unit count')
@allowed([
1
2
5
10
20
50
100
])
param unitCount int = 1

@description('SKU name')
@allowed([
'Standard_S1'
'Free_F1'
])
param sku string = 'Free_F1'

@description('Pricing tier')
@allowed([
'Free'
'Standard'
])
param pricingTier string = 'Free'

// Resource definition
resource webpubsub 'Microsoft.SignalRService/webPubSub@2023-02-01' = {
name: name
location: location
tags: union(tags, { 'azd-service-name': name })
sku: {
capacity: unitCount
name: sku
tier: pricingTier
}
identity: {
type: 'None'
}
properties: {
disableAadAuth: false
disableLocalAuth: false
liveTraceConfiguration: {
categories: [
{
enabled: 'false'
name: 'ConnectivityLogs'
}
{
enabled: 'false'
name: 'MessagingLogs'
}
]
enabled: 'false'
}
networkACLs: {
defaultAction: 'Deny'
publicNetwork: {
allow: [
'ServerConnection'
'ClientConnection'
'RESTAPI'
'Trace'
]
}
}
publicNetworkAccess: 'Enabled'
resourceLogConfiguration: {
categories: [
{
enabled: 'true'
name: 'ConnectivityLogs'
}
{
enabled: 'true'
name: 'MessagingLogs'
}
]
}
tls: {
clientCertEnabled: false
}
}
}

output name string = webpubsub.name
output uri string = 'https://${webpubsub.properties.hostName}'
output id string = webpubsub.id