Deploying Frontity on platform.sh (middleware?)

I am running a dev server instance with platformsh at https://www.master-7rqtwti-iin5x4pvtoxre.us-4.platformsh.site/

After building the app (npx frontity build) I get a server.js file which has to be used as middleware by platfformsh to render the final result.

I am getting a 502 Bad gateway error, probably because I am missing something setting the YAML files to get server.js as a middleware.

server.js is in place https://www.master-7rqtwti-iin5x4pvtoxre.us-4.platformsh.site/server.js

Does anyone have experience with setting up middleware on platformsh (using workers or adding a third-party library)?

besides this, the project is perfectly working in local

here is the .platform.app.yaml file as a reference:

name: app
type: 'nodejs:14'
hooks:
            build: |
        npx frontity build
web:
    commands:
        start: npx frontity serve
            locations:
                    '/':
                        root: 'build'
disk: 512
0

Comments

2 comments
Date Votes
  • Hello @harvey-botero!

    The tabs in your .platform.app.yaml file look a bit off, but that may just be Discourse doing something funky.

    Other than that, Frontity looks like it defaults to port 3000, and that you need to override to use a different.

    All apps on Platform.sh can only run on port 8888, which is accessible in the $PORT environment variable. Try this .platform.app.yaml file and see if you’re still having problems.

    name: app
    
    type: 'nodejs:14'
    
    hooks:
        build: npx frontity build
    
    web:
        commands:
            start: FRONTITY_SERVE_PORT=$PORT npx frontity serve
    

    You’ll be able to see which port Frontity is trying to use in your app by either SSHing into the container and taking a look at /var/log/app.log or by running the CLI command platform logs app -p iin5x4pvtoxre -e master.

    You’ll notice I took a few keys out as well. Since you have a start.command, locations isn’t necessary. Also, you don’t need to define disk for this app. Only when you start setting aside mounts that need write access to the file system is that key required.

    Hope this helps!

    0
  • Thank you very much … it works perfectly! :slightly_smiling_face:

    0

Please sign in to leave a comment.

 

Didn't find what you were looking for?

New post