Code Monkey home page Code Monkey logo

heroku-buildpack-d's Introduction

Heroku Buildpack: D

A heroku buildpack for the D programing language using dub to build applications.

Quickstart

Pablo De Napoli has written a boilerplate repo with a simple Deploy to Heroku button.

Usage

Example usage:

$ ls
dub.sdl source .d-compiler

$ heroku create --buildpack http://github.com/MartinNowak/heroku-buildpack-d.git

$ git push heroku master
...
-----> Heroku receiving push
-----> Fetching custom git buildpack... done
-----> D app detected
-----> Using dmd-2.078.0
-----> Building application with dub

Usage with Vibe.d

The buildpack will infer a default Procfile for you, that should be sufficient for many cases.

default_process_types:
  web: ./your-app-name --port $PORT

Use readOption or std.getopt to bind your HTTP server to the port choosen by Heroku. Here is dub's vibe.d template (dub init myapp --type=vibe.d) modified accordingly.

import vibe.vibe;

void main()
{
    auto settings = new HTTPServerSettings;
    settings.port = 8080;
    // <!-- NEW NEW NEW
    // listen on external interface by default
    settings.bindAddresses = ["0.0.0.0"];
    // read port from command line
    readOption("port|p", &settings.port, "Sets the port used for serving HTTP.");
    // optionally read bind address from command line
    readOption("bind-address|bind", &settings.bindAddresses[0], "Sets the address used for serving HTTP.");
    // NEW NEW NEW -->

    auto listener = listenHTTP(settings, &hello);
    runApplication();
}

void hello(HTTPServerRequest req, HTTPServerResponse res)
{
    res.writeBody("Hello, World!");
}

You can add a custom Procfile to your repo if you need more or different arguments.

web: ./your-app-name --port $PORT -v --my-arg

And finally see Deploy on Heroku - Dlang Tour for more details.

Selecting a D compiler

By default the latest dmd compiler is used. It is also possible to use gdc or ldc and to choose a specific compiler versions by adding a .d-compiler file to your project or by setting the DC environment variable in Heroku. Use dmd, ldc, or gdc to select the latest or dmd-2.068.2, ldc-0.16.0, or gdc-4.9.2 to select a specific version of a compiler.

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.