I'm deploying my first production ready project in a few days. Would love to better optimise my current pipeline
Did you made project dockerized?
In my most recent deployment, I used DevOps Pipelines deploying to Azure App Services with a MongoDB Atlas instance from the Azure Marketplace.
I created a new Dockerfile for each environment (dev, qa, uat, production).
In each Dockerfile, I added a line before the npm install
ENV PAYLOAD_PUBLIC_SERVER_URL=https://myserver.com
(different URL in each reflecting the environment's URL.
In my Payload Config, I use the environment variable to set the
serverUrl
property.
Note: This could also have been achieved using.env.<environment-name>
files and a single Dockerfile.
In my DevOps
azure-pipelines.yml
file I use variables to determine which Dockerfile to use depending on which git branch triggered the pipeline.
I build and publish the relevant Dockerfile to an Azure Container Registry.
The Azure App Services were created as Docker app services and are deployed from the Azure Container Registry, re-deploying via webhook whenever the associated docker image is updated.
I found this was the only way to get it working in Azure App Services due to the fact that the
PAYLOAD_PUBLIC_*
variables need to be present at
build timeso they are passed to the admin app, and a bug in Kudu ZipDeploy that breaks
node_modules/.bin
symlinks preventing any kind of
npm build
on the app service itself. (
npm rebuild
also doesn't work on app services due to file permissions)
I've opened a discussion at
https://github.com/payloadcms/payload/discussions/2288to talk about improving the Payload documentation in regards to production deployments and CI/CD.
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.