Giter Site home page Giter Site logo

heroku-buildpack-lua's Introduction

Heroku buildpack: Lua

This is a Heroku buildpack for Lua apps.

It comes bundled with Lua 5.1 and LuaRocks 2.2.0.

Read a tutorial at http://leafo.net/posts/lua_on_heroku.html.

Usage

Create an app with the buildpack:

$ heroku create --buildpack http://github.com/leafo/heroku-buildpack-lua.git

Dependencies

In order to describe the dependencies of you application you must create a rockspec for it.

The first file found that matches *.rockpsec in the root directory will be used. Don't put multiple ones in the root directory otherwise it might get confused.

The buildpack only looks at the dependency information. Meaning you don't have to follow the entire rockspec specification. Minimally, your rockspec could look something like this:

-- my_app.rockspec
dependencies = {
  "xavante >= 2.2.1",
  "https://rocks.moonscript.org/manifests/leafo/moonscript-0.2.6-1.src.rock",
  "cosmo"
}

As shown above, if you want to include external rockspec or rock files by URL you can place them in the dependencies table. (This is not supported by LuaRocks, only by this buildpack).

This file must exist, even if you have no dependencies. The rockspec is parsed in prepare.moon.

The buildpack installs the dependencies to packages/ and Lua to bin/lua.

The bin/ directory is added to the PATH on initial install so you can run Lua directly.

Additionally, LUA_PATH and LUA_CPATH environment variables are set to point to where the dependencies are installed so you can require them with no extra work.

Example App

Use Xavante for a quick web server:

-- web.lua
require "xavante"

port = ...

xavante.HTTP {
  server = { host = "*", port = tonumber(port) },
  defaultHost = {
    rules = {
      {
        match = ".",
        with = function(req, res)
          res.headers["Content-type"] = "text/html"
          res.content = "hello world, the time is: " .. os.date()
          return res
        end
      }
    }
  }
}

xavante.start()

Tell Heroku to spawn your web server by creating a file called Procfile:

web:     lua web.lua $PORT

After pushing, if the web server doesn't start automatically, tell Heroku to start it:

$ heroku scale web=1

heroku-buildpack-lua's People

Contributors

leafo avatar ddollar avatar vdel26 avatar mmcgrana avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.