Deploy SOLID server to Heroku

Hi,

In order to share my experience dealing with some deployment tasks and two existing topics (Music Platform, Using POD server on Heroku) I’m gonna start this thread so hopefully it helps others to put their hands on and avoid wasting 2 days of headaches. Here we go…

First things first, I apologise but to be able to complete these steps a Heroku account is required(*). I’m not familiar with other services, sorry, but I’m happy to get feedback about how to achieve the same goal, publish/expose a SOLID server on the Internet, with a different service (a step by step guide preferably, so it can be reproducible).

These are the commands I’ve run in my machine (Apple M1 Max, macOS Monterey v. 12.5.1, Node.js v18.12.1). They are intended for the Community Server, but in a follow up message I’ll explain the same for Recipes (mashlib).

$ git clone https://github.com/CommunitySolidServer/CommunitySolidServer.git
$ cd CommunitySolidServer

Create a Procfile: a text file in the root directory of your application, to explicitly declare what command should be executed to start your app. The Procfile in should look like this:

web: npm start -p $PORT

If you are using Unix based system:
$ touch Procfile
$ echo "web: npm start -p \$PORT" >> Procfile

$ heroku login
$ heroku create

After this command you’ll get a message similar to

Creating app… done, ⬢ arcane-cove-33793
https://arcane-cove-33793.herokuapp.com/ | https://git.heroku.com/arcane-cove-33793.git

Then you copy the URL and use it to edit the package.json like this:

Modify package.json at line:

“start”: "node ./bin/server.js --baseUrl https://arcane-cove-33793.herokuapp.com/ -p "

$ git add .
In case: husky > pre-commit hook failed (add --no-verify to bypass)
$ git commit -am "make it better" --no-verify
$ git push heroku main

(*)Disclaimer:

Starting November 28th, 2022, free Heroku Dynos, free Heroku Postgres, and free Heroku Data for Redis® will no longer be available. Free Heroku dynos will be converted to Eco dynos and spun down. Any Heroku Scheduler jobs configured to use free dynos will fail. More info: Dyno Types | Heroku Dev Center

For Recipes

$ git clone https://github.com/CommunitySolidServer/Recipes

$ cd Recipes

$ cd mashlib

Define a Procfile, a text file in the root directory of your application, to explicitly declare what command should be executed to start your app. The Procfile in should look like this:

web: npm start -p $PORT

If you are using Unix based system:
$ touch Procfile
$ echo "web: npm start -p \$PORT" >> Procfile

$ git init
$ heroku login

$ heroku create

After this command you’ll get a message similar to

Creating app… done, ⬢ arcane-cove-33793
https://arcane-cove-33793.herokuapp.com/ | https://git.heroku.com/arcane-cove-33793.git

Then you copy the URL and use it to edit the package.json like this:

Modify package.json at line:

“start”: "npx community-solid-server -c config-mashlib.json --baseUrl https://arcane-cove-33793.herokuapp.com/ -p ",

$ heroku git:remote -a arcane-cove-33793
$ git add .
$ git commit -am "make it better"
$ git push heroku main

It might be worth noting that Heroku’s free tier is going away: Removal of Heroku Free Product Plans FAQ - Heroku Help

Also, last I knew Heroku didn’t have persistent disk storage, so you could potentially loose all data if attempting to write to the local disk (which iirc, CSS does)

Thanks for your reply and your concern, @ThisIsMissEm :slight_smile:

I already mentioned at the first entry of this thread (bottom of the message) that Heroku is not free anymore but yet is still a very useful tool for developers to publish Proof Of Concepts and other experiments. It’s OK to have a prototype running on your local machine but as soon as you want to validate with colleagues you need to deploy your ideas to Real Life and that sometimes is not trivial. I would like to hear more about alternatives to Heroku that are free to use, but anyway that wasn’t the point of this thread.

I wanted to confirm, as said in (Music Platform) that is possible to run an instance of Community Server with “mashlib” configuration and access files and content in a public way, without being logged in (Music Platform - #8 by ThisIsMissEm).

I’m not sure if I really managed it, you can have a look if you have time to this:

There’s still some work in progress but probably I’ll continue in the Music App thread (Music Platform) with final thoughts.

PS. Regarding Heroku persistent disk storage, I have no idea, sorry, I’ll need to dig a bit more on it but it’s not relevant for the prototype at this point.

Thanks again for your support!

One of the CSS team members can definitely correct me if I’m wrong, but my understanding is that CSS manipulates files on the local disk / filesystem instead of working with an Object/Blob store such as S3 and a database such as PostgreSQL.

This can mean that if Heroku restart your application, you may loose all your data as the local disk isn’t persisted. I’d highly recommend deploying to a VPS instead (e.g., on DigitalOcean) where you have a persistent disk.

See: Why are my file uploads missing/deleted from the Application ? - Heroku Help

Local Disk is just one of the backings that CSS supports; and new backings can be added by implementing the DataAccessor interface (CommunitySolidServer/DataAccessor.ts at d61bf9bf1957fb706b2be2aaa016c367d2ae92f0 · CommunitySolidServer/CommunitySolidServer · GitHub); so if you wanted Object Storage then you would need to implement that interface with the interaction pattern you wanted for your Object Store.

Currently implemented backings for the CSS include File-Based, in memory, and SPARQL endpoints and they can be found in CommunitySolidServer/src/storage/accessors at main · CommunitySolidServer/CommunitySolidServer · GitHub.

In terms of how to start the server up using these different backends - I recommend you read the documentation about custom configurations in GitHub - CommunitySolidServer/CommunitySolidServer: An open and modular implementation of the Solid specifications.

Thanks for your comments and valuable information @ThisIsMissEm and @jeswr, I’ll have a deeper look into it. I’ll definitely give DigitalOcean a try as an alternative to Heroku :slight_smile: