Skip to content

Commit 0d81fb4

Browse files
authored
Merge pull request #172 from CollActionteam/azure
Setup working Azure resources and CI
2 parents f05975c + b7bb51e commit 0d81fb4

5 files changed

Lines changed: 32 additions & 118 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,17 @@ jobs:
1313
name: Build and Deploy
1414
runs-on: ubuntu-latest
1515
steps:
16-
- name: Check out code
16+
- name: Checkout code
1717
uses: actions/checkout@v3
1818

19-
- uses: azure/login@v1
20-
with:
21-
creds: ${{ secrets.AZ_CREDENTIALS }}
22-
23-
- name: Login to Azure Container Registry
19+
- name: Azure Container Registry login
2420
uses: docker/login-action@v2
2521
with:
2622
registry: ${{ secrets.AZ_REGISTRY_URL }}
2723
username: ${{ secrets.AZ_REGISTRY_USERNAME }}
2824
password: ${{ secrets.AZ_REGISTRY_PASSWORD }}
2925

30-
- name: Build, tag, and push image to Azure Container Instances
26+
- name: Build, tag and push image to Azure Container Registry
3127
env:
3228
SERVICE_ACCOUNT_KEY: ${{ secrets.SERVICE_ACCOUNT_KEY }}
3329
ENV_FILE: ${{ secrets.ENV }}
@@ -36,22 +32,12 @@ jobs:
3632
run: |
3733
echo $SERVICE_ACCOUNT_KEY | base64 --decode > serviceAccountKey.json
3834
echo $ENV_FILE | base64 --decode > .env
39-
docker build --target production -t $ECR_REGISTRY/$ECR_REPOSITORY:${{ github.sha }} .
35+
docker build --target ${{ env.CURRENT_ENV }} -t $ECR_REGISTRY/$ECR_REPOSITORY:${{ github.sha }} .
4036
docker push $ECR_REGISTRY/$ECR_REPOSITORY:${{ github.sha }}
4137
42-
- name: Deploy to Azure Container Instances
43-
uses: azure/aci-deploy@v1
44-
env:
45-
ECR_REPOSITORY: collaction-api-${{ env.CURRENT_ENV }}
38+
- name: Deploy to Azure App Service
39+
uses: azure/webapps-deploy@v2
4640
with:
47-
resource-group: ${{ secrets.AZ_RESOURCE_GROUP }}
48-
dns-name-label: ${{ env.CURRENT_ENV }}-api
49-
image: ${{ secrets.AZ_REGISTRY_URL }}/${{ env.ECR_REPOSITORY }}:${{ github.sha }}
50-
registry-login-server: ${{ secrets.AZ_REGISTRY_URL }}
51-
registry-username: ${{ secrets.AZ_REGISTRY_USERNAME }}
52-
registry-password: ${{ secrets.AZ_REGISTRY_PASSWORD }}
53-
cpu: 1
54-
memory: 2.0
55-
name: ${{ env.ECR_REPOSITORY }}
56-
location: 'west europe'
57-
ports: '80 443 3000'
41+
app-name: 'collaction-api-${{ env.CURRENT_ENV }}'
42+
publish-profile: ${{ secrets.AZ_PUBLISH_PROFILE }}
43+
images: '${{ secrets.AZ_REGISTRY_URL }}/collaction-api-${{ env.CURRENT_ENV }}:${{ github.sha }}'

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ WORKDIR /usr/src/app
55

66
COPY package*.json ./
77

8-
RUN npm ci
8+
RUN npm i
99

1010
COPY . .
1111

12+
EXPOSE 3000
13+
14+
CMD ["npm", "run", "start:dev"]
15+
1216
# Production (multi-stage build)
1317
FROM node:16-alpine AS build
1418

azure/container_registry.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ resource "azurerm_container_registry" "collaction" {
33
resource_group_name = azurerm_resource_group.collaction_api.name
44
location = azurerm_resource_group.collaction_api.location
55
sku = "Standard"
6-
}
6+
admin_enabled = true
7+
}

azure/containers.tf

Lines changed: 0 additions & 85 deletions
This file was deleted.

azure/storage.tf

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
1-
resource "azurerm_storage_account" "collaction" {
2-
name = "collaction"
1+
resource "azurerm_storage_account" "collaction_static_dev" {
2+
name = "collactionstaticdev"
33
location = azurerm_resource_group.collaction_api.location
44
resource_group_name = azurerm_resource_group.collaction_api.name
55
account_tier = "Standard"
66
account_replication_type = "LRS"
77
}
88

9-
resource "azurerm_storage_container" "collaction_api_dev" {
10-
name = "collaction-api-dev"
11-
storage_account_name = azurerm_storage_account.collaction.name
9+
resource "azurerm_storage_container" "collaction_static_dev" {
10+
name = "$web"
11+
storage_account_name = azurerm_storage_account.collaction_static_dev.name
1212
container_access_type = "blob"
1313
}
1414

15-
resource "azurerm_storage_container" "collaction_api_production" {
16-
name = "collaction-api-production"
17-
storage_account_name = azurerm_storage_account.collaction.name
15+
resource "azurerm_storage_account" "collaction_static_production" {
16+
name = "collactionstaticprod"
17+
location = azurerm_resource_group.collaction_api.location
18+
resource_group_name = azurerm_resource_group.collaction_api.name
19+
account_tier = "Standard"
20+
account_replication_type = "LRS"
21+
}
22+
23+
resource "azurerm_storage_container" "collaction_static_production" {
24+
name = "$web"
25+
storage_account_name = azurerm_storage_account.collaction_static_production.name
1826
container_access_type = "blob"
1927
}

0 commit comments

Comments
 (0)