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.

Problems deploying V3 to VPS

default discord avatar
portablejimlast year
14

I have been struggling to get a v2 install working in a deployed state.


Repo:

https://github.com/portablejim/dpc-sermons-payload/tree/v3

Site:

https://dpcsermons.pjim.me/

Database: local postgres.



I can run

pnpm run build

and have it succeed on my local machine. When I run it on the VPS it (the build step) runs out of heap space (1gb ram, 4gb swap). So I thought I can copy the build dir (.next) over and run

pnpm run start

to run it, but it does not seem to be working.



* I have Nginx providing the SSL, copying the config from

https://github.com/leerob/next-self-host/blob/main/deploy.sh#L115

* The docker image fails to build on my local machine (even copying a docker file from another thread and trying to build the website template)


* When using the NextJS

output: 'standalone'

option, I get


A locale object was not found for the provided string ["enUS"].
SyntaxError: Unexpected token '<', "<html>
<h"... is not valid JSON
    at JSON.parse (<anonymous>)
    at parseJSONFromBytes (node:internal/deps/undici/undici:5682:19)

, . I also noticed some local machine paths encoded into server.js.


* When the admin UI does load, it does not let me save anything (seemly not changed when adjusting

PAYLOAD_PUBLIC_SERVER_URL

and

NEXT_PUBLIC_SERVER_URL

Is the only solution getting a bigger VPS? Or is there a way to build it locally and then deploy it?

  • default discord avatar
    philipisawesomelast year

    You can build with github actions & container, for free

  • default discord avatar
    portablejimlast year

    But it seems to require a db connection to build, so would github actions work?

  • default discord avatar
    philipisawesomelast year

    You can provide an env for that, but I don't see the benefit of enabling db at build time



    So I just render the pages on visit instead

  • default discord avatar
    portablejimlast year

    When buying a bigger server (now with 2GB ram):


    root@192-53-169-51:/home/web/dpc-sermons-payload# pnpm run build
    
    > dpc-sermons-payload3@1.0.0 build /home/web/dpc-sermons-payload
    > cross-env NODE_OPTIONS=--no-deprecation next build
    
      ▲ Next.js 15.0.0
      - Environments: .env.production, .env
      - Experiments (use with caution):
        · turbo
    
       Creating an optimized production build ...
    <w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Unable to snapshot resolve dependencies
    <w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Unable to snapshot resolve dependencies
    root@192-53-169-51:/home/web/dpc-sermons-payload# pnpm run start
    
    > dpc-sermons-payload3@1.0.0 start /home/web/dpc-sermons-payload
    > cross-env NODE_OPTIONS=--no-deprecation next start
    
      ▲ Next.js 15.0.0
      - Local:        http://localhost:3000
    
     ✓ Starting...
    Error: Could not find a production build in the '.next' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id
        at setupFsCheck (/home/web/dpc-sermons-payload/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/server/lib/router-utils/filesystem.js:149:19)
        at async initialize (/home/web/dpc-sermons-payload/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/server/lib/router-server.js:65:23)
        at async Server.<anonymous> (/home/web/dpc-sermons-payload/node_modules/.pnpm/next@15.0.0_react-dom@19.0.0-rc-65a56d0e-20241020_react@19.0.0-rc-65a56d0e-20241020__react@19_7kfqem4pd6aim6nxuy4v6dxrry/node_modules/next/dist/server/lib/start-server.js:266:36)
     ELIFECYCLE  Command failed with exit code 1.
  • default discord avatar
    philipisawesomelast year

    "Unable to snapshot resolve dependencies" not sure about that error sorry



    That's weird it didn't find a build



    looks like some kind of cache problem

  • default discord avatar
    s.laamlast year

    steps generated by AI



    Here are some steps to troubleshoot:



    Try clearing the cache and node modules:


    rm -rf .next
    rm -rf node_modules
    pnpm install

    Check if you have enough disk space on the server:


    df -h

    Verify your Node.js version is compatible with Next.js 15:


    node -v

    from nextjs docs :


    [Breaking] The minimum required Node.js version has been updated to 18.18.0

    Try building with more verbose output:


    pnpm run build --debug

    Check if there are any permission issues:


    ls -la .next
  • default discord avatar
    portablejimlast year

    Enough disk space. Node v23. no errors displayed with debug. Still same error.

  • default discord avatar
    s.laamlast year

    try deleting lockfile as well and re-install dependencies


    change node version from 23 to 22



    this worked with some people in the comments here



    https://github.com/vercel/next.js/issues/47394


    ⚠ "next start" does not work with "output: standalone" configuration. Use "node .next/standalone/server.js" instead.
  • default discord avatar
    portablejimlast year

    Downgrading to node 22 got me to the point of being able to build it on the larger VPS. Still not fully working due to my own bugs.

  • default discord avatar
    trangcongthanhlast year

    I deployed my payload v3 app to $6 DigitalOcean droplet and Its running well about 2 months now.



    My app stack:


    - Node 20


    - Docker


    - next@15


    - payload@3.beta.121


    - postgresql


    - treafix



    Step by step to build my app:


    - Use docker to up an empty database.


    - Run migration if needed


    - Build the app to docker image


    - Push the image to ghcr.io


    - Login to VPS


    - Pull the image and up both database and app.



    If you don’t want to run a database when building the app, just force the page render on request by using

    export const dynamic = ‘force-dynamic’

    .



    When I have time, I'll setup github action and a runner in my local machine to make it auto deploy.

  • default discord avatar
    portablejimlast year

    Thanks.



    I have now seemly got it working with building it on my local machine (and running it on the smaller VPS). The errors I were encountering at points were my own errors - the site requires an api fetch request to itself to complete for page load, which obviously gets mad if not right.



    And for those wondering, yes the

    PUBLIC_SERVER_URL

    vars are set to the public url.



    One aspect of the problems was being sure to also listen on IPv6 in the webserver config (which probably caused the return of the HTML - the standard webserver setup page)



    The saving problems are limited to fields of an object (which probably means it's my code)

  • default discord avatar
    philipisawesomelast year

    The suggestion to give it an empty db defeats the purpose of generating html at build time--it would have no data to build the pages from

  • default discord avatar
    trangcongthanhlast year

    Yes. Forgot to mention that problem. Every time up and run newer image, I just invalidate all the cache 🫣

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.