Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
775acad
Add Azure Blob Storage for development and production
gillesmag Apr 5, 2023
f82059c
Remove tags
gillesmag Apr 5, 2023
7a7418f
Migrate AWS Route53 to Azure DNS
gillesmag Apr 5, 2023
d4b2dfc
Improve Docker image build process
gillesmag Apr 5, 2023
5e6ca61
Merge branch 'master' into azure
gillesmag Apr 5, 2023
ae4e047
Rename containers
gillesmag Apr 5, 2023
79d8136
Skip containers in Terraform for now
gillesmag Apr 5, 2023
cf1696a
Specify container resources and use commit hash instead of env
gillesmag Apr 5, 2023
41baa10
Forgot to change one
gillesmag Apr 5, 2023
ea1dd7a
Update package-lock.json
gillesmag Apr 5, 2023
52b0e90
Add cron package
gillesmag Apr 5, 2023
c16e109
bump
gillesmag Apr 5, 2023
f882362
Merge branch 'development' into azure
gillesmag Apr 5, 2023
634e77e
package lock
gillesmag Apr 5, 2023
90def71
refactor: scheduler module
Xazin Apr 5, 2023
69a87bf
test local build
gillesmag Apr 5, 2023
53c507b
try no dns
gillesmag Apr 5, 2023
125f816
fix: remove scheduler in favor of resolving statuses
Xazin Apr 5, 2023
7a8faa0
Merge pull request #169 from CollActionteam/fix/remove-scheduler
gillesmag Apr 5, 2023
7b9cdd2
chore: clean cd script
Xazin Apr 6, 2023
51be04b
chore: clean scheduler
Xazin Apr 6, 2023
bd2d9f2
fix: linter
Xazin Apr 6, 2023
654a5b0
tests: fix list crowdactions test
Xazin Apr 6, 2023
0b1dea5
Merge pull request #170 from CollActionteam/azure
Xazin Apr 6, 2023
e344933
cicd: add dns name label
Xazin Apr 6, 2023
3e1c17f
Merge pull request #171 from CollActionteam/fix/dns-name-label
Xazin Apr 6, 2023
f05975c
trigger
gillesmag Apr 6, 2023
6511f3c
dev
gillesmag Apr 6, 2023
d6917f5
prod
gillesmag Apr 6, 2023
5326e78
Create two storage accounts instead of just one
gillesmag Apr 7, 2023
721efbe
Naming
gillesmag Apr 7, 2023
47c9318
length
gillesmag Apr 7, 2023
0729177
Container registry admin enabled
gillesmag Apr 7, 2023
17f876f
Deploy to App Services
gillesmag Apr 7, 2023
9a53ef3
Deploy using publish profile
gillesmag Apr 7, 2023
e470b01
Deploy prod
gillesmag Apr 7, 2023
ee7150e
Build dev properly
gillesmag Apr 7, 2023
b7bb51e
Working deployment
gillesmag Apr 7, 2023
0d81fb4
Merge pull request #172 from CollActionteam/azure
gillesmag Apr 7, 2023
f849077
Merge branch 'master' into development
gillesmag Apr 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git
node_modules
dist
Dockerfile
Dockerfile.prod
33 changes: 10 additions & 23 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,31 @@ jobs:
name: Build and Deploy
runs-on: ubuntu-latest
steps:
- name: Check out code
- name: Checkout code
uses: actions/checkout@v3

- uses: azure/login@v1
with:
creds: ${{ secrets.AZ_CREDENTIALS }}

- name: Login to Azure Container Registry
- name: Azure Container Registry login
uses: docker/login-action@v2
with:
registry: ${{ secrets.AZ_REGISTRY_URL }}
username: ${{ secrets.AZ_REGISTRY_USERNAME }}
password: ${{ secrets.AZ_REGISTRY_PASSWORD }}

- name: Build, tag, and push image to Azure Container Instances
- name: Build, tag and push image to Azure Container Registry
env:
SERVICE_ACCOUNT_KEY: ${{ secrets.SERVICE_ACCOUNT_KEY }}
ENV_FILE: ${{ secrets.ENV }}
ECR_REGISTRY: ${{ secrets.AZ_REGISTRY_URL }}
ECR_REPOSITORY: collaction-api-${{ env.CURRENT_ENV }}
DOCKER_FILE: ${{ env.CURRENT_ENV == 'production' && 'Dockerfile.prod' || 'Dockerfile' }}
run: |
echo $SERVICE_ACCOUNT_KEY | base64 --decode > serviceAccountKey.json
echo $ENV_FILE | base64 --decode > .env
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:${{ env.CURRENT_ENV }} -f $DOCKER_FILE .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:${{ env.CURRENT_ENV }}
docker build --target ${{ env.CURRENT_ENV }} -t $ECR_REGISTRY/$ECR_REPOSITORY:${{ github.sha }} .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:${{ github.sha }}

- name: Deploy to Azure Container Instances
uses: azure/aci-deploy@v1
env:
ECR_REPOSITORY: collaction-api-${{ env.CURRENT_ENV }}
- name: Deploy to Azure App Service
uses: azure/webapps-deploy@v2
with:
resource-group: ${{ secrets.AZ_RESOURCE_GROUP }}
dns-name-label: api-${{ env.CURRENT_ENV }}
image: ${{ secrets.AZ_REGISTRY_URL }}/${{ env.ECR_REPOSITORY }}:${{ env.CURRENT_ENV }}
registry-login-server: ${{ secrets.AZ_REGISTRY_URL }}
registry-username: ${{ secrets.AZ_REGISTRY_USERNAME }}
registry-password: ${{ secrets.AZ_REGISTRY_PASSWORD }}
name: ${{ env.ECR_REPOSITORY }}
location: 'west europe'
ports: '80 443 3000'
app-name: 'collaction-api-${{ env.CURRENT_ENV }}'
publish-profile: ${{ secrets.AZ_PUBLISH_PROFILE }}
images: '${{ secrets.AZ_REGISTRY_URL }}/collaction-api-${{ env.CURRENT_ENV }}:${{ github.sha }}'
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,3 @@ dist/
test-coverage/
serviceAccountKey.json
serviceAccountKey-prod.json
package-lock.json
38 changes: 34 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,45 @@
FROM node:16-alpine3.12 as development
# Development
FROM node:16-alpine AS development

WORKDIR /home/node/app
WORKDIR /usr/src/app

COPY package*.json ./

RUN npm i

COPY . .

RUN npm run build

EXPOSE 3000

CMD ["npm", "run", "start:dev"]

# Production (multi-stage build)
FROM node:16-alpine AS build

WORKDIR /usr/src/app

COPY --chown=node:node package*.json ./
COPY --chown=node:node --from=development /usr/src/app/node_modules ./node_modules
COPY --chown=node:node . .

RUN npm run build

ENV NODE_ENV production

RUN npm ci --only=production && npm cache clean --force

USER node

FROM node:16-alpine AS production

WORKDIR /usr/src/app

COPY --chown=node:node --from=build /usr/src/app/node_modules ./node_modules
COPY --chown=node:node --from=build /usr/src/app/dist ./dist
COPY --chown=node:node serviceAccountKey.json .
COPY --chown=node:node .env .
COPY --chown=node:node assets ./assets
COPY --chown=node:node assets ./dist/assets
COPY --chown=node:node assets ./dist/src/assets

CMD [ "node", "dist/src/main.js" ]
15 changes: 0 additions & 15 deletions Dockerfile.prod

This file was deleted.

3 changes: 2 additions & 1 deletion azure/container_registry.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ resource "azurerm_container_registry" "collaction" {
resource_group_name = azurerm_resource_group.collaction_api.name
location = azurerm_resource_group.collaction_api.location
sku = "Standard"
}
admin_enabled = true
}
85 changes: 0 additions & 85 deletions azure/containers.tf

This file was deleted.

145 changes: 145 additions & 0 deletions azure/dns.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
resource "azurerm_dns_zone" "collaction_app" {
name = "collaction.app"
resource_group_name = azurerm_resource_group.collaction_api.name
}

resource "azurerm_dns_a_record" "collaction_app_website" {
name = "@"
zone_name = azurerm_dns_zone.collaction_app.name
resource_group_name = azurerm_resource_group.collaction_api.name
ttl = 300
# Website hosted on Vercel
records = ["76.76.21.21"]
}

resource "azurerm_dns_cname_record" "collaction_app_www" {
name = "www"
zone_name = azurerm_dns_zone.collaction_app.name
resource_group_name = azurerm_resource_group.collaction_api.name
ttl = 300
record = "cname.vercel-dns.com"
}

resource "azurerm_dns_zone" "collaction_org" {
name = "collaction.org"
resource_group_name = azurerm_resource_group.collaction_api.name
}

resource "azurerm_dns_a_record" "collaction_org_website" {
name = "@"
zone_name = azurerm_dns_zone.collaction_org.name
resource_group_name = azurerm_resource_group.collaction_api.name
ttl = 300
# Website hosted on Vercel
records = ["76.76.21.21"]
}

resource "azurerm_dns_mx_record" "collaction_org" {
name = "@"
zone_name = azurerm_dns_zone.collaction_org.name
resource_group_name = azurerm_resource_group.collaction_api.name
ttl = 300

record {
preference = 1
exchange = "ASPMX.L.GOOGLE.COM."
}

record {
preference = 5
exchange = "ALT1.ASPMX.L.GOOGLE.COM."
}

record {
preference = 5
exchange = "ALT2.ASPMX.L.GOOGLE.COM."
}

record {
preference = 10
exchange = "ALT3.ASPMX.L.GOOGLE.COM."
}

record {
preference = 10
exchange = "ALT4.ASPMX.L.GOOGLE.COM."
}

record {
preference = 10
exchange = "x3hzrrc76ur7ql23dtzahto3xlxu2tyrgsgosvkpxf5cry4yhffq.mx-verification.google.com."
}
}

resource "azurerm_dns_txt_record" "google-site-verification" {
name = "@"
zone_name = azurerm_dns_zone.collaction_org.name
resource_group_name = azurerm_resource_group.collaction_api.name
ttl = 300

record {
value = "\"google-site-verification=SW8ISEH0mS7aKfOnxzUEjgMyrNyNDX1CkWrc6OBV5Js\""
}

record {
value = "\"google-site-verification=TyCEpqnZwyWaRL1FhYY46fr7faAfDbCP16AOQwQVElw\""
}

record {
value = "\"google-site-verification=Kh1C6nh-U5B6efQFVrwGbD65rs53Ubr_14jiWqiAP9k\""
}

record {
value = "\"MS=ms78684470\""
}
}

# TODO(gm): Connect these to containers
# resource "azurerm_dns_cname_record" "api-production" {
# name = "api"
# zone_name = azurerm_dns_zone.collaction_org.name
# resource_group_name = azurerm_resource_group.collaction_api.name
# ttl = 300
# record = "collaction-api-prod-1123994322.eu-central-1.elb.amazonaws.com."
# }
#
# resource "azurerm_dns_cname_record" "api-dev" {
# name = "devapi"
# zone_name = azurerm_dns_zone.collaction_org.name
# resource_group_name = azurerm_resource_group.collaction_api.name
# ttl = 300
# record = "collaction-api-dev-183571204.eu-central-1.elb.amazonaws.com."
# }

resource "azurerm_dns_cname_record" "docs" {
name = "docs"
zone_name = azurerm_dns_zone.collaction_org.name
resource_group_name = azurerm_resource_group.collaction_api.name
ttl = 300
record = "19caebbc41-hosting.gitbook.io"
}

# TODO(gm): how to connect this to Azure Blob Storage?
# resource "azurerm_dns_a_record" "static-dev" {
# name = "static-dev"
# zone_name = azurerm_dns_zone.collaction_org.name
# resource_group_name = azurerm_resource_group.collaction_api.name
# ttl = 300
# records = [""]
# }

# resource "azurerm_dns_a_record" "static-production" {
# name = "static"
# zone_name = azurerm_dns_zone.collaction_org.name
# resource_group_name = azurerm_resource_group.collaction_api.name
# ttl = 300
# records = [""]
# }

resource "azurerm_dns_cname_record" "collaction_org_www" {
name = "www"
zone_name = azurerm_dns_zone.collaction_org.name
resource_group_name = azurerm_resource_group.collaction_api.name
ttl = 300
record = "cname.vercel-dns.com"
}
Loading