Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to upload a simple html and javascript file structure to heroku?

I'm trying to deploy an open source project of mine to heroku, it is by necessity very simple with just static html and javascript. But do they not support static sites? I'd rather not make it a Sinatra project if I don't plan on ever using anything but html and javascript.

~/sites/d4-site $ heroku create --stack cedar Creating quiet-ice-4769... done, stack is cedar http://quiet-ice-4769.herokuapp.com/ | [email protected]:quiet-ice-4769.git Git remote heroku added   ~/sites/d4-site $ git remote -v heroku  [email protected]:quiet-ice-4769.git (fetch) heroku  [email protected]:quiet-ice-4769.git (push)   ~/sites/d4-site $ git push heroku master Counting objects: 53, done. Delta compression using up to 2 threads. Compressing objects: 100% (49/49), done. Writing objects: 100% (53/53), 206.08 KiB, done. Total 53 (delta 4), reused 0 (delta 0)  -----> Heroku receiving push -----> Removing .DS_Store files  !     Heroku push rejected, no Cedar-supported app detected 
like image 241
Jeremy Smith Avatar asked May 11 '12 12:05

Jeremy Smith


People also ask

Can you upload files to Heroku?

Simple File Upload can be attached to a Heroku application via the CLI: A list of all plans available can be found here. After you install Simple File Upload, your application will be configured to fully integrate with the add-on. The easiest way to get started is to access the Dashboard for customized instructions.


2 Answers

A simple way is to masquerade the HTML app as a PHP App. Heroku properly identifies PHP apps.

  1. Rename your index.html file to home.html.
  2. Create an index.php file and include your entry html file. If your HTML entry file is named home.html as recommended, your index.php should look like:

    <?php include_once("home.html"); ?>

  3. In your command line on the machine you are pushing from, type:

    git add .
    git commit -m 'your commit message'
    git push heroku master

Heroku should properly detect your app now as a php app:

-----> PHP app detected -----> Bundling Apache version 2.2.22 -----> Bundling PHP version 5.3.10 -----> Discovering process types        Procfile declares types -> (none)        Default types for PHP   -> web  -----> Compiled slug size: 9.9MB -----> Launching... done, v3 ... 

Mad Thanks to lemiffe for his blog post: http://www.lemiffe.com/how-to-deploy-a-static-page-to-heroku-the-easy-way/

like image 110
pkanane Avatar answered Sep 21 '22 17:09

pkanane


Here is a more elegant method: Just add a file called package.json which tells Heroku to use harp as your server:

{   "name": "my-static-site",   "version": "1.0.0",   "description": "This will load any static html site",   "scripts": {     "start": "harp server --port $PORT"   },   "dependencies": {     "harp": "*"   } } 

and then deploy to Heroku. Done!

Further information: https://harpjs.com/docs/deployment/heroku

like image 36
Harlan T Wood Avatar answered Sep 19 '22 17:09

Harlan T Wood