Skip to content

Commit 312dbd4

Browse files
Karacs PéterKaracs Péter
authored andcommitted
deploy
1 parent 223b3cf commit 312dbd4

10 files changed

Lines changed: 182 additions & 0 deletions

File tree

‎.DS_Store‎

6 KB
Binary file not shown.

‎.dockerignore‎

Whitespace-only changes.

‎.github/workflows/deploy.yml‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Deploy Bicep to Azure
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout Code
14+
uses: actions/checkout@v3
15+
16+
- name: Login to Azure
17+
uses: azure/login@v1
18+
with:
19+
creds: ${{ secrets.AZURE_CREDENTIALS }}
20+
21+
- name: Deploy Bicep Template
22+
uses: azure/arm-deploy@v1
23+
with:
24+
scope: resourceGroup
25+
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
26+
resourceGroupName: BCSAI2024-DEVOPS-STUDENTS-A-DEV
27+
template: ./main.bicep
28+
parameters: ./main.parameters.json

‎Dockerfile‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM python:3.11
4+
5+
# Set working directory
6+
WORKDIR /code
7+
8+
# Copy and install dependencies
9+
COPY requirements.txt .
10+
RUN pip3 install --no-cache-dir -r requirements.txt
11+
12+
# Copy the application code
13+
COPY . .
14+
15+
# Expose the correct port
16+
EXPOSE 50505
17+
18+
# Run the app with Gunicorn, binding to 0.0.0.0
19+
ENTRYPOINT ["gunicorn", "-b", "0.0.0.0:50505", "app:app"]

‎gunicorn.conf.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Gunicorn configuration file
2+
import multiprocessing
3+
4+
max_requests = 1000
5+
max_requests_jitter = 50
6+
7+
log_file = "-"
8+
9+
bind = "0.0.0.0:50505"
10+
11+
workers = (multiprocessing.cpu_count() * 2) + 1
12+
threads = workers
13+
14+
timeout = 120

‎main.bicep‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
param acrName string
2+
param acrLocation string
3+
param servicePlanName string
4+
param servicePlanLocation string
5+
param webAppName string
6+
param webAppLocation string
7+
param containerRegistryImageName string
8+
param containerRegistryImageVersion string
9+
10+
module acrModule './modules/acr.bicep' = {
11+
name: 'deployACR'
12+
params: {
13+
name: acrName
14+
location: acrLocation
15+
acrAdminUserEnabled: true
16+
}
17+
}
18+
19+
module servicePlanModule './modules/servicePlan.bicep' = {
20+
name: 'deployServicePlan'
21+
params: {
22+
name: servicePlanName
23+
location: servicePlanLocation
24+
sku: {
25+
capacity: 1
26+
family: 'B'
27+
name: 'B1'
28+
size: 'B1'
29+
tier: 'Basic'
30+
}
31+
}
32+
}
33+
34+
module webAppModule './modules/webApp.bicep' = {
35+
name: 'deployWebApp'
36+
params: {
37+
name: webAppName
38+
location: webAppLocation
39+
kind: 'app'
40+
serverFarmResourceId: servicePlanModule.outputs.servicePlanId
41+
siteConfig: {
42+
linuxFxVersion: 'DOCKER|${acrModule.outputs.registryLoginServer}/${containerRegistryImageName}:${containerRegistryImageVersion}'
43+
appCommandLine: ''
44+
}
45+
appSettingsKeyValuePairs: {
46+
WEBSITES_ENABLE_APP_SERVICE_STORAGE: false
47+
DOCKER_REGISTRY_SERVER_URL: acrModule.outputs.registryLoginServer
48+
DOCKER_REGISTRY_SERVER_USERNAME: acrModule.outputs.adminUsername
49+
DOCKER_REGISTRY_SERVER_PASSWORD: acrModule.outputs.adminPassword
50+
}
51+
}
52+
}

‎main.parameters.json‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"acrName": { "value": "demo-acr" },
6+
"acrLocation": { "value": "eastus" },
7+
"servicePlanName": { "value": "myServicePlan" },
8+
"servicePlanLocation": { "value": "eastus" },
9+
"webAppName": { "value": "demo-webapp" },
10+
"webAppLocation": { "value": "eastus" },
11+
"containerRegistryImageName": { "value": "demo-image" },
12+
"containerRegistryImageVersion": { "value": "latest" }
13+
}
14+
}
15+

‎modules/acr.bicep‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
param name string
2+
param location string
3+
param acrAdminUserEnabled bool
4+
5+
resource containerRegistry 'Microsoft.ContainerRegistry/registries@2023-01-01-preview' = {
6+
name: name
7+
location: location
8+
sku: {
9+
name: 'Basic'
10+
}
11+
properties: {
12+
adminUserEnabled: acrAdminUserEnabled
13+
}
14+
}
15+
16+
output registryLoginServer string = containerRegistry.properties.loginServer
17+
output adminUsername string = listCredentials(containerRegistry.id, '2023-01-01-preview').username
18+
output adminPassword string = listCredentials(containerRegistry.id, '2023-01-01-preview').passwords[0].value

‎modules/servicePlan.bicep‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
param name string
2+
param location string
3+
param sku object
4+
5+
resource servicePlan 'Microsoft.Web/serverfarms@2022-03-01' = {
6+
name: name
7+
location: location
8+
sku: sku
9+
kind: 'Linux'
10+
properties: {
11+
reserved: true
12+
}
13+
}
14+
15+
output servicePlanId string = servicePlan.id

‎modules/webApp.bicep‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
param name string
2+
param location string
3+
param kind string
4+
param serverFarmResourceId string
5+
param siteConfig object
6+
param appSettingsKeyValuePairs object
7+
8+
resource webApp 'Microsoft.Web/sites@2022-03-01' = {
9+
name: name
10+
location: location
11+
kind: kind
12+
properties: {
13+
serverFarmId: serverFarmResourceId
14+
siteConfig: siteConfig
15+
}
16+
}
17+
18+
resource appSettings 'Microsoft.Web/sites/config@2022-03-01' = {
19+
name: '${webApp.name}/appsettings'
20+
properties: appSettingsKeyValuePairs
21+
}

0 commit comments

Comments
 (0)