@EverydayTinkerer, we recently migrated our deployment from AWS to Azure, following the guides provided by @tomdickson and Erik Guzman. Here is our current deployment code. I hope this is helpful for you and the community.
App Service
Dockerfile
FROM node:18-alpine
ARG DATABASE_URL
RUN apk update && apk add bash
RUN apk add --no-cache git openssh
WORKDIR /app
COPY api api
COPY .nvmrc .
COPY graphql.config.js .
COPY package.json .
COPY redwood.toml .
COPY yarn.lock .
COPY scripts scripts
RUN yarn install
RUN yarn rw prisma migrate deploy
RUN yarn rw prisma generate
RUN npx @redwoodjs/cli-data-migrate
RUN yarn rw build api
RUN echo "yarn rw build api done"
RUN rm -rf ./api/src
WORKDIR /app/api
EXPOSE 8911
ENTRYPOINT [ "yarn", "rw", "serve", "api", "--port", "8911" ]
Github Action
name: PROD Deploy backend to azure container app
on:
push:
tags:
- v**
jobs:
build:
runs-on: ubuntu-latest-md
concurrency: prod-backend-deployment
steps:
- uses: actions/checkout@v4
- uses: azure/docker-login@v1
with:
login-server: example.azurecr.io
username: ${{ secrets.USERNAME_AZURE_CONTAINER_REGISTRY }}
password: ${{ secrets.PASSWORD_AZURE_CONTAINER_REGISTRY }}
- run: |
docker build \
--build-arg "DATABASE_URL=${{ secrets.DIRECT_DB_URL }}" \
. -t example.azurecr.io/example:${{ github.sha }}
docker push example.azurecr.io/example:${{ github.sha }}
- name: Log into Azure CLI with service principal
uses: Azure/login@v1.4.6
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Authenticate with Azure and add environment variables
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- uses: azure/appservice-settings@v1
with:
app-name: 'example'
app-settings-json: '[
{ "name": "WEBSITES_PORT", "value": "8911" },
{ "name": "WEBSITE_WEBDEPLOY_USE_SCM", "value": "true" },
{ "name": "API_URL", "value": "https://example.azurewebsites.net" },
{ "name": "BASE_URL", "value": "https://example.app" },
{ "name": "DATABASE_URL", "value": "${{ secrets.DB_URL }}" },
{ "name": "LOG_LEVEL", "value": "info"}]'
id: settings
- name: Docker Login to Azure Container Registry
uses: azure/docker-login@v1
with:
login-server: example.azurecr.io
username: ${{ secrets.USERNAME_AZURE_CONTAINER_REGISTRY }}
password: ${{ secrets.PASSWORD_AZURE_CONTAINER_REGISTRY }}
- uses: azure/webapps-deploy@v2
with:
app-name: 'example'
images: 'example.azurecr.io/example:${{ github.sha }}'
Static Web app
name: PROD Deploy frontend to azure static web app
on:
push:
tags:
- v**
jobs:
build_and_deploy_frontend:
runs-on: ubuntu-latest
name: Build and Deploy Job
environment:
name: production-frontend
url: https://example.app
concurrency: production-frontend-deployment
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: build and deploy
id: builddeploy
env: # Add environment variables here
API_URL: https://example.azurewebsites.net
BASE_URL: https://example.app
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.STATIC_WEB_APP_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: 'upload'
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: '/' # App source code path
# api_location: 'api/dist' # Api source code path - optional
output_location: 'web/dist' # Built app content directory - optional
app_build_command: yarn rw build web
###### End of Repository/Build Configurations ######
staticwebapp.config.json
{
"navigationFallback": {
"rewrite": "/index.html",
"exclude": ["*.{svg,png,jpg,gif}", "*.{css,scss}", "*.js"]
},
"routes": [
{
"route": "/data/info.json",
"headers": {
"cache-control": "no-store"
}
}
]
}