Error deploying with Dockerfile / Azure App Services / DevOps

default discord avatar
Kyr
6 months ago
9

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
    danielmlr
    6 months ago

    Trying aswell, no luck as of now.

  • default discord avatar
    Kyr
    6 months 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



    @danielmlr FYI

  • default discord avatar
    etmartinkazoo
    5 months ago

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

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.