How to deploy Payload on GCloud using Docker & Cloud Run

default discord avatar
Mark | Omniux
2 months ago
21

Hey folks, I wrote a blog post on how to deploy PayloadCMS from start to finish using Docker & Google Cloud Run. You can read about it all here -

https://www.omniux.io/blog/deploying-a-payload-cms-instance-with-docker-and-google-cloud-run

#google-cloud #docker #cloud #gcp

  • default discord avatar
    Step
    2 months ago

    hello @Mark | Omniux , I have followed your article to deploy paylod in Cloud Run, but I get the error:

    non-zero status:1

    Attached is a picture of the error and my Dockerfile configuration.

    error.jpg
    dockerfile.png
  • default discord avatar
    Mark | Omniux
    2 months ago

    What happens when you build locally without docker? Does it build ok?

  • default discord avatar
    Step
    2 months ago

    @Mark | Omniux I already corrected that error, now I have an error related to the yaml file. I get the following error:

    Repository "us.gcr.io" not fund

    . Attached is a picture of the error t of the configuration of my YAML file.

    error.jpg
    yaml.jpg
  • default discord avatar
    iamlinkus
    2 months ago

    Have you actually created that repository?



    in your docker you’re saying that you have created a repository and named it “us.gcr.io” (which is a strange name for a repository, since this would usually be your project name or smth)

  • default discord avatar
    Mark | Omniux
    2 months ago

    us.gcr.io was the repository that was generated automatically for me when I added Container Registry to my project. Since then we've switched to Artifact Registry. @Step have you added Artifact Repository? It will have created a special location for your docker images



    Actually, I see now that I have a mistake in my code. us.gcr.io is the name of the repository from another one of my projects (that's my bad). I'll update the blog post to cover the creation of the Artifact Registry,



    When you add a new Registry, give it any name like 'docker-registry'. Then use this name of your registry in place of us.gcr.io



    I've updated the blog post. That should make it a bit clearer!

  • default discord avatar
    Step
    2 months ago

    hi @Mark | Omniux , I have not added Artifact Registry or Artifact Repository, I just based on your blog to do the deployment in Cloud Run.

  • default discord avatar
    Mark | Omniux
    2 months ago

    Ah, you'll need to enable all 4 services mentioned in the Getting Started section in order to deploy on Google Cloud Run;



    With your Google project all setup, you'll be greeted with a welcome screen with a ton of services. This can all get pretty overwhelming because Google offers lots of individual services (over 70 at the time of writing!), but for now, we're going to focus on 4 services;
    
    
    Cloud Build
    Cloud Run
    Container Registry
    Cloud Storage
  • default discord avatar
    Step
    2 months ago

    @Mark | Omniux I'm going to implement it, any error I'll ask for your help ^^



    @Mark | Omniux The service has been successfully implemented, but when I navigate to the url that provides the service, I get the following error:

    service unavailable
    Cloud.png
    Service.jpg
  • default discord avatar
    iamlinkus
    2 months ago

    What’s the port in service settings? It should be 3000 (default is 8080 if I remember correctly)

  • default discord avatar
    Step
    2 months ago

    @iamlinkus If port 3000 is configured, the deployment is done correctly, but at the url that generates the deployed project I get the error:

    Service Unavailable
  • default discord avatar
    Mark | Omniux
    2 months ago

    What do your Cloud Log files say?

  • default discord avatar
    Step
    2 months ago

    @Mark | Omniux In the Log files it shows an error related to GraphQL, which I don't do by myself but is incorporated in the node_modules file of Payload.

    errorgraph.png
    Captura.png
  • default discord avatar
    iamlinkus
    2 months ago

    try adding this to the package.json:



      "overrides": {
        "graphql@>15.7.0 <16.7.0": "^15.8.0"
      },


    I think I had that error and this fixed it. There's was a problem with the version of graphql that payload used by default. Although this was a couple of versions down, so I'll have to look over the commit history of payload and see if the team has updated that dep and maybe with the latest payload the error shouldn't occur.

  • default discord avatar
    eloahsam
    3 weeks ago

    @Mark | Omniux i checked out your article , another simpler way would just be to create a dockerfile and add it to the repo root and go to cloudrun and create service then select "


    Continuously deploy new revisions from a source repository" then choose the repo from github and for buildtype select "Dockerfile" etc



    maybe add this as an alternative to using the cloudbuild.yaml which is platform specific

  • default discord avatar
    Mark | Omniux
    3 weeks ago

    That's a valid solution. I should probably add that this setup is good for Monorepo projects. I have the code my my NextJS app and my PayloadCMS in the same repo but in seperate folders. So specifying cloudbuild files and steps can add an extra layer of control (and scalability)

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.