Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Error deploying with Dockerfile / Azure App Services / DevOps

default discord avatar
hades2000822 years ago
3

I've got a DevOps pipeline configured to deploy Payload to a Linux Azure App Service.



The deployment completes successfully and I can see the application files on the app-service, including

node_modules

,

dist

and

build

folders.



I get the error

error: cannot find module 'express'

when the app service tries to run

npm run serve

.



If I add the environment variable

SCM_DO_BUILD_DURING_DEPLOYMENT=true

to the app service I then get a different error,

error: cannot find module '..'

from

cross-env

.



Any ideas?



Ok, so it seems to be an issue with Azure App Service deployments.



There are two issues I’m having.



1. Because I’m building in DevOps and then using ZipDeploy, the

PAYLOAD_PUBLIC

environment variables from the App Service aren’t available to the admin. This is impacting being able to load the admin at all because I’m using such a variable for the server url.



2. App Service deployments seem to break the symlinks that

npm install

creates in the

node_modules/.bin

folder. This means that I can’t re-run the

npm run build

command as part of the App Service start command.



3. Setting the public env vars in the build script on DevOps has no effect.



4.

npm rebuild

on the app service fails due to permissions errors



Has anyone managed to get Payload working on Azure App Service at all?

  • default discord avatar
    danielovida2 years ago

    Trying aswell, no luck as of now.

  • default discord avatar
    hades2000822 years ago
    https://tenor.com/view/fml-sylvester-cat-annoyed-head-bang-gif-13045781

    I've made progress.... I'm using DevOps to build & publish the docker image to Azure Container Registry and booting the app service from the created docker image.



    This has bypassed all of the symlink nonsense but now when I go to

    /admin

    I get the following error in my browser console:



    Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons: 1. You might have mismatching versions of React and the renderer (such as React DOM) 2. You might be breaking the Rules of Hooks 3. You might have more than one copy of React in the same app See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.


    Error deploying with Dockerfile



    I think I finally solved it... Adding the following to my package.json fixed the react error. It seems that the default dependencies that Payload comes with have some differing versions of react dependencies within them 😦



    "overrides": {
      "react": "18.2.0"
    }


    Error deploying with Dockerfile / Azure App Services / DevOps



    @279998686669570049

    FYI

  • default discord avatar
    etmartinkazoo2 years ago

    Interesting I am having the same issue on the latest version in my dev environment out of the blue...

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.