I have a Gitbook repository and I would like to serve it through Heroku. How should I setup my application for this purpose? How to tell `Gitbook serve' command to listen to Heroku's port?
Thank you.
Do not run the gitbook-cli directly on Heroku, gitbbok will use a lot of memory and pass the 512MB limit for a free dyno. The best way is to first build your book to a static website and then serve the static content with either nodejs with express static or with sinatra.
Run the following inside your gitbook folder.
gitbook build
A new folder will be created, _book and all your html files will be here. You can now create a new app on Heroku and serve your static content.
After you do gitbook build, you can serve that directory with Express by creating an app.js file like this:
var express = require('express');
var app = express();
app.use(express.static(__dirname + '/_book'));
app.listen(process.env.PORT || 3000);
Dead-easy. For more information: Static files served by node.js on heroku - is it a good idea?
1- Add gitbook-cli to your project:
npm install --save gitbook-cli
2- Add a Procfile to your project:
web: ./node_modules/gitbook-cli/bin/gitbook.js serve --port $PORT
Related
I'm trying to deploy an application through Heroku which is just an index.html page with some javascript and css.
I've connected my Github repository to it as a deployment method, but it never seems to work.
Every time I type "heroku logs", it spits back out:
"npm ERR! missing script: start" first.
From what I've searched, it tells me that I need to add "start": "somefile.js" as a starting point in package.json, but this is a very simple index.html page with javascript invoked from whenever a couple buttons are pressed.
How am I meant to get past this?
Heroku isn't really built for hosting static websites that have no dynamic server backend. If you want to do that, you should look into using a proper static file host like Amazon S3, Netlify, etc.
However -- if you DO want to do this on Heroku, you can do so by creating a really simple application (here's an article which shows you how to do it using Ruby): https://devcenter.heroku.com/articles/static-sites-ruby
Agree with #rdegges, you need some sort of http server. A basic node http server is pretty trivial to implement as well.
A full tutorial is available, but the keys steps are:
Make sure you have [node, npm, heroku CLI] installed.
In the root of your project directory, run npm init - (this will create a package.json in your root project directory)
Run npm install --save express - (this will add express as a dependency to the package.json file)
Create a file named Procfile in the root directory.
(contents: web: npm app.js)
Create a file named app.js in the root directory. (contents below)
Commit your changes, push to Heroku - git push heroku master
That should do it. Make sure all your files are in a directory called public as specified in the app.js file or change that to reflect where they actually are.
app.js:
var express = require('express');
var app = express();
app.use('/', express.static('public'));
app.listen(process.env.PORT || 8080);
Full Tutorial: https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction
I'd like to use nginx within a dokku/heroku setting with the ssl module enabled:
+ --with-http_ssl_module
What is the easiest way to achieve that? Cloning the php buildpack alone does not do the trick. How can I recompile the nginx binary? How can I rebuild a buildpack?
ok - i did it like this:
forked the buildpack
changed the nginx dependency to 1.10:
$require["heroku-sys/nginx"] = "~1.10.0";
in platform.php
then compiled and stored a new nginx package (based on the official heroku one)
stored the package somwhere public on amazon s3
added to the app environment the line export HEROKU_PHP_PLATFORM_REPOSITORIES='https://s3.region.amazonaws.com/your-bucket/packages.json'
If deploying an app, nginx will be loaded from your custom repository and installed within the docker image.
I followed the docs in the official website. The problem is I use webpack as my bundler instead of brunch. The deployment is successful. I can even access the api routes. My only problem is the assets (js,css) in the homepage is not found. Locally, I can access the home page successfully when I run mix phoenix.server.
I tried peeking at the priv/static folder in heroku (using heroku run bash) where the files are moved after being compiled and saw the asset files there. Did I miss anything? or a configuration that I should put?
Here is the remote deploy output
http://pastebin.com/1mL1YWTS
Here is my custom compile file (to override phoenix-static buldpack)
http://pastebin.com/BGHf9xBK
Here is my webpack.config.js
http://pastebin.com/Xv2E1yCE
I have used webpack with the following compile:
./node_modules/.bin/webpack -p
mix phoenix.digest
You need to call mix phoenix.digest to generate a manifest that can be used in the static path helpers. http://hexdocs.pm/phoenix/Mix.Tasks.Phoenix.Digest.html#run/1
I created a app for Angular manually, his structure and all stuff.
To run it locally I'm using http-server.
How can I deploy it to Heroku in order to inform what server to run (probably in Procfile)?
Create a Procfile just called Procfile (no extension) in the root of your app. Within that file use web: to tell heroku what to run. For example:
web: coffee server.coffee
I use a Windows machine and have a Django project that I have successfully deployed to Heroku, albeit using the development server. To use a production server Heroku seems to require 'Gunicorn' which does not run on Windows.
This is not good for testing locally before deploying. Does anyone know of any way to get around this? Perhaps some way to use a different server on Heroku?
I found a solution that may help when deploying to heroku using a Windows machine. Here is what I do:
Use the development server locally with:
python manage.py runserver
Install and add 'Gunicorn' to your installed apps in settings.py.
Add a process file in the root directory that tells heroku to use the Gunicorn server. This is a file called 'Procfile' with the following code:
web: python kalail/manage.py run_gunicorn --bind=0.0.0.0:$PORT
This way you test using the development server, while heroku uses the Gunicorn server. Make sure you set up serving static files(css/js/imgs) after this, because only the development server automatically serves static files, and the Gunicorn server will need to be configured to do so.
You can run the development server locally quite easily:
> python manage.py runserver
All you need to do is specify path to wsgi script from root directory:
$web: gunicorn hellodjango.wsgi