Can anyone share how they setup their CI/CD pipeline with payload

default discord avatar
roac
8 months ago
2

I'm deploying my first production ready project in a few days. Would love to better optimise my current pipeline

  • default discord avatar
    mrofas200
    8 months ago

    Did you made project dockerized?

  • default discord avatar
    Kyr
    8 months ago

    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 time

    so 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/2288

    to talk about improving the Payload documentation in regards to production deployments and CI/CD.

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.