initial attempt at IaC and CI/CD
This commit is contained in:
parent
597c7e4e0b
commit
820b251c61
11 changed files with 355 additions and 1 deletions
90
infrastructure/app.bicep
Normal file
90
infrastructure/app.bicep
Normal file
|
@ -0,0 +1,90 @@
|
|||
import { Context } from 'types.bicep'
|
||||
|
||||
targetScope = 'resourceGroup'
|
||||
|
||||
param context Context
|
||||
param registry resource'Microsoft.ContainerRegistry/registries@2023-07-01'
|
||||
|
||||
var appName = 'app'
|
||||
var version = 'latest'
|
||||
|
||||
resource environment 'Microsoft.App/managedEnvironments@2024-03-01' = {
|
||||
name: 'acr-${context.locationAbbreviation}-${context.environment}-${context.projectName}'
|
||||
location: context.location
|
||||
properties: {
|
||||
appLogsConfiguration: {
|
||||
destination: 'azure-monitor'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource app 'Microsoft.App/containerApps@2024-03-01' = {
|
||||
name: 'acr-${context.locationAbbreviation}-${context.environment}-${context.projectName}-app'
|
||||
location: context.location
|
||||
identity: {
|
||||
type: 'SystemAssigned'
|
||||
}
|
||||
properties: {
|
||||
environmentId: environment.id
|
||||
|
||||
configuration: {
|
||||
activeRevisionsMode: 'Single'
|
||||
|
||||
ingress: {
|
||||
external: true
|
||||
targetPort: 8080
|
||||
transport: 'http2'
|
||||
allowInsecure: false
|
||||
traffic: [
|
||||
{
|
||||
weight: 100
|
||||
latestRevision: true
|
||||
}
|
||||
]
|
||||
corsPolicy: {
|
||||
allowedOrigins: [
|
||||
// 'https://localhost:3000'
|
||||
'*'
|
||||
]
|
||||
allowCredentials: true
|
||||
allowedHeaders: ['*']
|
||||
allowedMethods: ['Get, POST']
|
||||
maxAge: 0
|
||||
}
|
||||
}
|
||||
registries: [
|
||||
{
|
||||
identity: 'system'
|
||||
server: registry.properties.loginServer
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
template: {
|
||||
containers: [
|
||||
{
|
||||
image: '${registry.properties.loginServer}/${context.projectName}-${appName}:${version}'
|
||||
name: '${context.projectName}-${appName}'
|
||||
resources: {
|
||||
cpu: json('0.25')
|
||||
memory: '0.5Gi'
|
||||
}
|
||||
}
|
||||
]
|
||||
scale: {
|
||||
minReplicas: 1
|
||||
maxReplicas: 2
|
||||
rules: [
|
||||
{
|
||||
name: 'http-rule'
|
||||
http: {
|
||||
metadata: {
|
||||
concurrentRequests: '50'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
infrastructure/bicepconfig.json
Normal file
11
infrastructure/bicepconfig.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"experimentalFeaturesEnabled": {
|
||||
"assertions": true,
|
||||
"testFramework": true,
|
||||
"extensibility": true,
|
||||
"resourceDerivedTypes": true,
|
||||
"resourceTypedParamsAndOutputs": true,
|
||||
"sourceMapping": true,
|
||||
"symbolicNameCodegen": true
|
||||
}
|
||||
}
|
46
infrastructure/main.bicep
Normal file
46
infrastructure/main.bicep
Normal file
|
@ -0,0 +1,46 @@
|
|||
import { Context } from 'types.bicep'
|
||||
|
||||
targetScope = 'subscription'
|
||||
|
||||
param locationAbbreviation string
|
||||
param location string
|
||||
param environment string
|
||||
param projectName string
|
||||
param deployedAt string = utcNow('yyyyMMdd')
|
||||
|
||||
var context = {
|
||||
locationAbbreviation: locationAbbreviation
|
||||
location: location
|
||||
environment: environment
|
||||
projectName: projectName
|
||||
deployedAt: deployedAt
|
||||
}
|
||||
|
||||
resource calqueResourceGroup 'Microsoft.Resources/resourceGroups@2024-07-01' = {
|
||||
name: 'rg-${locationAbbreviation}-${environment}-${projectName}'
|
||||
location: location
|
||||
}
|
||||
|
||||
module monitoring 'monitoring.bicep' = {
|
||||
name: 'monitoring'
|
||||
scope: calqueResourceGroup
|
||||
params: {
|
||||
context: context
|
||||
}
|
||||
}
|
||||
|
||||
module registry 'registry.bicep' = {
|
||||
name: 'registry'
|
||||
scope: calqueResourceGroup
|
||||
params: {
|
||||
context: context
|
||||
}
|
||||
}
|
||||
|
||||
module app 'app.bicep' = {
|
||||
name: 'app'
|
||||
scope: calqueResourceGroup
|
||||
params: {
|
||||
context: context
|
||||
}
|
||||
}
|
11
infrastructure/monitoring.bicep
Normal file
11
infrastructure/monitoring.bicep
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { Context } from 'types.bicep'
|
||||
|
||||
targetScope = 'resourceGroup'
|
||||
|
||||
param context Context
|
||||
|
||||
// resource monitoring 'Microsoft.___/___@___' = {
|
||||
// name: 'acr-${context.locationAbbreviation}-${context.environment}-${context.projectName}'
|
||||
// location: context.location
|
||||
// properties: {}
|
||||
// }
|
6
infrastructure/params/prod.bicepparam
Normal file
6
infrastructure/params/prod.bicepparam
Normal file
|
@ -0,0 +1,6 @@
|
|||
using '../main.bicep'
|
||||
|
||||
param locationAbbreviation = 'euw'
|
||||
param location = 'westeurope'
|
||||
param environment = 'prd'
|
||||
param projectName = 'calque'
|
16
infrastructure/registry.bicep
Normal file
16
infrastructure/registry.bicep
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { Context } from 'types.bicep'
|
||||
|
||||
targetScope = 'resourceGroup'
|
||||
|
||||
param context Context
|
||||
|
||||
resource registry 'Microsoft.ContainerRegistry/registries@2023-07-01' = {
|
||||
name: 'acr-${context.locationAbbreviation}-${context.environment}-${context.projectName}'
|
||||
location: context.location
|
||||
sku: {
|
||||
name: 'Basic'
|
||||
}
|
||||
properties: {}
|
||||
}
|
||||
|
||||
output registry resource'Microsoft.ContainerRegistry/registries@2023-07-01' = registry
|
8
infrastructure/types.bicep
Normal file
8
infrastructure/types.bicep
Normal file
|
@ -0,0 +1,8 @@
|
|||
@export()
|
||||
type Context = {
|
||||
locationAbbreviation: string
|
||||
location: string
|
||||
environment: string
|
||||
projectName: string
|
||||
deployedAt: string
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue