Skip to content

Implement caching properly for both dev and prod workflows and docker… #8

Implement caching properly for both dev and prod workflows and docker…

Implement caching properly for both dev and prod workflows and docker… #8

name: Frontend - Build and Deploy on Azure (Dev)
on:
push:
branches: [development]
paths:
- "frontend/**"
- ".github/workflows/azure-deploy-frontend-dev.yml"
workflow_dispatch:
env:
REGISTRY: mploycontainerregistry-hncsekeah2gagbgb.azurecr.io
FRONTEND_IMAGE_NAME: nextjs-frontend
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:latest
network=host
- name: Log in to Azure Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- name: Build and push image (with ACR cache)
uses: docker/build-push-action@v6
with:
context: ./frontend
file: ./frontend/Dockerfile.dev
push: true
tags: |
${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE_NAME }}:development
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE_NAME }}:buildcache,mode=max
deploy:
needs: build-and-push
runs-on: ubuntu-latest
environment: development
steps:
- name: Azure login
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy to Azure Container Apps (Dev)
uses: azure/container-apps-deploy-action@v2
with:
registryUrl: ${{ env.REGISTRY }}
registryUsername: ${{ secrets.ACR_USERNAME }}
registryPassword: ${{ secrets.ACR_PASSWORD }}
containerAppName: mploy-frontend-dev
resourceGroup: ${{ secrets.AZURE_RESOURCE_GROUP_DEV }}
imageToDeploy: ${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE_NAME }}:development
targetPort: 3000
environmentVariables: |
NOTION_API_KEY="${{ secrets.NOTION_API_KEY }}"
NOTION_DATABASE_ID="${{ secrets.NOTION_DATABASE_ID }}"
MONGODB_URI="${{ secrets.MONGODB_URI }}"
NODE_ENV="development"