Hosting on Heroku

#1

Hi there :wave:t3:

I managed to deploy vapid on Heroku and migrate my data from SQLite to Postgres and plan a step by step guide about this but, there’s still one main issue with it: File Storage.

Is there, by any chance, something already implemented to be able to upload files on an S3 bucket? Because of the nature of Heroku (or now.sh), it’s always a fresh copy of the app which is booted up, so the file uploads are disappearing.

Another, waaaayyy less gracious would be to save files into the DB (but I don’t want to do this).


Deploy on Heroku

First thing first you have to create an app on Heroku. Free dyno is fine. You must also add a postgresql free add-on.

Now you have to edit the package.json and insert code into the vapid section.

{
    "name": "YOURSITENAME",
    "vapid": {
        "site": "YOURSITEID",
        "dialiect": "postgresql",
        "use_env_variable": "DATABASE_URL"
    },
    "scripts": {
        "start": "vapid start .",
        "now-build": "vapid start ."
    },
    "dependencies": {
        "@vapid/cli": "^0.5.1",
        "pg": "^7.10.0"
    }
}

You may have noticed I added pg as a dependency. It’s for PostgreSQL. It seems Vapid check if we install it manually when we are using something else than the SQLite. So we have to put this to prevent any deployment issue.

:warning: If someone has some clue about how to avoid this step, I’m taking it.

You can now deploy your app.

Migrate your data

You may have already put content into vapid and want to “transfer” it to your new host. I used Postico as Postgresql client and DB Browser for SQLITE for … well, you know.

Open your SQLite database and export sections and records table in separate CSV files.
Open your Postgresql database and go for importing it on each table (you’ll have to match columns but that’s easy).

How to find your connection info for Heroku

Connect to your project, then browse to the resources tab.
Then click on your Postgres add-on
Go to settings
Click the credential button. Here they are! :partying_face:

#2

@clawfire Thanks for putting this guide together—it looks great! Whenever you’re ready, let’s link to it from the repo’s Wiki.

Re: storage, unfortunately there isn’t anything implemented or in the works. IMO, this is one of the biggest pains using Heroku and other ephemeral hosts. I was hoping that one of them would eventually offer something akin to Amazon’s EFS, where the mounted file system is a virtual connection to S3.

That said, I’m open to pull requests or discussions about finding a solution. Or promoting a similar hosting service, if we can find one that’s no ephemeral, which maybe is DigitalOcean?

#3

I try installing it on a Gandi Simple Hosting service right now (thanks to easter Monday). I’ll put a guide together when I’ll have something working.

The issue with EC2 or Heroku will not be solved anytime soon. For them, it’s not an issue, it’s the design of their architecture. Heroku officially give you code for your app to know how to upload to S3 from their instance, but I don’t want to submit a patch that will only support that I mean … It has to be modular or just don’t be (IMO).

For the guide on installing on Heroku, I’m working on a clearer version with tools suggestions and screenshots :slight_smile: I’ll let you know when it’s ready. Probably tomorrow afternoon :wink:

#4

Hy @scott, I put some screenshots and more details + links to some apps I used here on my Medium. If you want to link it, I didn’t find how to edit the wiki nor do a PR with a wiki edit (if it’s even possible :smiley:)

#5

@clawfire Nice, thank you! I can add it to the Wiki for you.

#6

Awesome thanks. I’m talking with Gandi also in order to test more their solution. It solve the upload issue I have with Heroku but the pricing model is more expensive than Vapid hosted services.