Git Product home page Git Product logo

dragonfly-server's Introduction

Dragonfly server

Build Status

This application can be used to serve Dragonfly urls.

Limitations

  • Doesn't support the full Dragonfly feature set (for now).
  • Limited to Imagemagick.

Setup

Dependencies

Erlang

IMPORTANT: Due to a known bug in Erlang 17.3, fetching urls with an https scheme are not processed correctly and throw an exception.

Please use Erlang >= 17.4, available at https://www.erlang-solutions.com/downloads/download-erlang-otp.

Elixir

To install elixir on a Mac, brew install elixir (you may need to brew update first).

Alternatively, you can follow these instructions.

Imagemagick

To install Imagemagick with png support, run brew install jpeg libpng imagemagick.

Goon

Communication with Imagemagick is managed by Goon, a middleman needed to polyfill the incomplete Port implementation provided by Erlang (see here for more information).

Download the binary and add it to a directory available in your $PATH.

App setup

$ mix deps.get

This will install all needed packages.

Then, copy the example environment file and make the necessary adjustments.

$ cp .env.example .env

Run the app in development

$ iex -S mix

Starts the app and opens a console.

Run tests

$ mix test

General api

Images are served at the entry point defined in config.exs, set as default at /media/:payload/:filename.

Note that both params in the url scheme are needed by the application.

Admin api

The app exposes an admin api that can be used to programmatically expire an image and all its associated resources. Endpoints are:

  • GET image (shows steps necessary to generate image)
  • DELETE image (expires all caches involved in the generation of the image)

Given an image url in the form of:

http://example.com/media/12345/untitled.jpg

It can be deleted by sending a DELETE request to the following endpoint:

http://example.com/admin/media/12345/untitled.jpg

From the command line:

$ curl -XDELETE http://example.com/admin/media/12345/untitled.jpg

The expected response is a 202, which indicates that the cache expiry has been scheduled and will be performed asyncronously.

The steps necessary to generate the image can also be examined at:

http://example.com/admin/media/12345/untitled.jpg

From the command line:

$ curl http://example.com/admin/media/12345

Deploy on Heroku

The app runs only on Cedar-14 and requires the multi-buildpack as it uses a custom Elixir buildback (it includes Goon).

Buildpacks are defined in .buildpacks.

Please follow instructions at https://github.com/ddollar/heroku-buildpack-multi.

dragonfly-server's People

Contributors

cloud8421 avatar felixbuenemann avatar

Watchers

 avatar  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.