This project is designed and built for the Cape Cod Commission of Barnstable County, Massachusetts and provides a public portal for communities of Cape Cod to assess, compare, and plan various strategies in response to the three major coastal hazards: storm surge, erosion, and sea level rise.
It is divided into 2 main projects:
ccc/chip_api
- a GraphQL API written in Elixir and using the Phoenix web framework and the Absinthe GraphQL libraryccc/chip_app
- a Single-page App written in Elm and using the OpenLayers and Turf.js libraries for mapping and geospatial analysis
Architecture Decision Records can be found in ccc/docs/architecture
and document the major architectural choices made throughout this project.
# Navigate to the project directory
cd cape-cod-coastal-planner/
# Checkout the dev branch
git checkout -b xxxXXXX dev
# Create a feature branch off the dev branch
naming convention of feature branch `this-feature`
# Navigate to chip_api/config
create `dev.secret.exs` & `test.secret.exs`
# Navigate to chip_api/startup.sh
uncomment `mix ecto.setup` line (Only for development)
# Run & destroy all services locally with docker
`docker-compose up --build` (create docker-compose services)
`docker-compose down -v` (destroy docker-compose services)
#Prior to rebasing feature-branch against dev branch
navigate to `chip_api/startup.sh` and comment `mix ecto.setup` line again
Pushing to dev or master branches will trigger our pipeline:
- CircleCI or Azure Devlops will pull our recent code from the specified branch
- Then rebuild, tag, and push the Front and API containers with our latest code to ACR
- Azure Webhooks watch our tagged containers on ACR
- On-push, will ping Keel
- Keel rebuilds pods with the correctly tagged images on Kubernetes
# Resource Group
CCC-AKSGroup
# Kubernetes Service
CCC-AKS-01
# Node Resource Group
MC_CCC-AKSGroup_CCC-AKS-01_eastus
To build and push local images to Azure Container Registry
# Log in to Azure Container Registry (ACR) ccccontainers
az acr login -n ccccontainers
# Build local images from Dockerfile directories and tag with ACR login server name
# NOTE: Increment tag version number for each additional build
docker build ./chip_app -t ccccontainers.azurecr.io/cccp-front:latest
docker build ./chip_api -t ccccontainers.azurecr.io/cccp-api:latest
# Push images to ACR, use :latest for default tag
docker push ccccontainers.azurecr.io/cccp-front:latest
docker push ccccontainers.azurecr.io/cccp-api:latest
# To remove local images and build cache
docker system prune -a
To deploy to Azure Kubernetes Cluster (AKS) CCC-AKS-01
# Log in to Azure
az login
# Connect to cluster
az aks get-credentials --resource-group CCC-AKSGroup --name CCC-AKS-01
# View status of pods, services, deployments, and recplicasets
kubectl get pods
kubectl get services
kubectl get deployments
# Deploy new Kubernetes config to AKS Cluster
# This is in Sharepoint
kubectl apply -f kubernetes-deployment.yml
# Enter an interactive terminal into a pod id
kubectl exec -it cccpapi-1234567 -- /bin/bash
# Install Keel on AKS to rebuild pods when pinged
helm upgrade --install keel --namespace=keel keel/keel --set service.enabled="true"
# To delete all services, deployments, pods, replicasets, volumes
kubectl delete daemonsets,replicasets,services,deployments,pods,rc --all
# To delete a persistent volume and claim
kubectl delete pvc pgdata-claim
To view the CCC-AKS-DEV-01 Cluster:
# Log in
az login
# Start local webapp to view CCC-AKS-DEV-01
#
az aks browse --resource-group CCC-AKSGroup --name CCC-AKS-01
- Set up database and persistent volume claim (cccpdb)
- Set up API (cccpapi) (NOTE: this step is necessary to seed (a.k.a. build) the database)
- Seed database from API (exec mix ecto.setup)
- Delete API [NOTE: steps 4 & 5 are necessary because you need a database for the API to properly f(x), otherwise you have a dysfunctional API]
- Re-build API
- Build front-end (cccpfront)
- Set up cccpapi dev & uat
- Set up cccpfrontdev, then uat 1 @ a time
- Install ingress
- Install cert-manager (delete purge if existing prior)
- Create cluster issuer (letsencrypt-prod & specific namespace)
- Create a certificate object w/ secrets (namespace specific - www, uat & dev)
- Create ingress w/ hosts & secrets
- Then rebuild, tag, and push the Front and API containers with our latest code to ACR