Navigation Menu

Skip to content

Commit

Permalink
add a Dockerfile for development
Browse files Browse the repository at this point in the history
  • Loading branch information
gregwebs committed Nov 13, 2013
1 parent 6168dd9 commit c3719b1
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 5 deletions.
29 changes: 29 additions & 0 deletions Dockerfile
@@ -0,0 +1,29 @@
from ubuntu:12.10
maintainer Greg Weber

RUN apt-get update
RUN apt-get install -y haskell-platform

RUN cabal update && install Cabal cabal-install

# Postgres
RUN apt-get install -y postgresql postgresql-contrib

# Sqlite
RUN apt-get install -y sqlite3 libsqlite3-dev

# Redis
RUN apt-get install -y redis-server

# MongoDB
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
RUN echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" >> /etc/apt/sources.list.d/10gen.list
RUN mkdir -p /data/db

RUN apt-get update
RUN apt-get install -y mongodb-10gen || echo "upstart error expected"

# MySQL
RUN apt-get install -y mysql-server || echo "need to run mysql --configure"

# RUN cd /home/persistent && cabal sandbox init && cabal install
27 changes: 25 additions & 2 deletions README.md
@@ -1,7 +1,30 @@
A Haskell "ORM". Supports PostgreSql, Sqlite, and MongoDB.

## Learn more: http://yesodweb.com/book/persistent

A Haskell datastore. Datastores are often referred to as "ORM"s. While 'O' traditionally means object, the concept can be generalized as:

avoidance of boilerplate serialization

In addition , the ORM concept is a way to make what is usually an un-typed driver type-safe.
In dynamic languages rather than compile time errors, safety comes from creating specific dynamic errors rather than sending non-sense queries to the database.

Persistent's goal is to catch every possible error at compile-time, and it comes close to that.

# Backend agnostic

Supports PostgreSql, Sqlite, MySQL, MongoDB, and Redis.

Persistent is designed to be adaptable to any datastore, and to allow multiple datastores to be used simultaneously.
The serialization layer should be adaptable to any datastore.

Providing a universal query layer will always be limiting.
A major limitation for SQL databases is that the persistent library does not directly provide joins.
However, you can use [Esqueleto](http://hackage.haskell.org/package/esqueleto) with Persistent's serialization to write type-safe SQL queries.
Key-value stores such as Redis can be used with persistent, but only fill out the key-value portion of the API (PersistStore) rather than the query portion (PersistQuery).

Persistent provides several hooks to create backend-specific functionality.
One can always fall back to using the raw database driver or other lower-level or less type-safe libraries and can utilize Persistent for un-serializing the database response to a Haskell record.


## Install from source

Install the Haskell Platform first. Clone this repo and run:
Expand Down
30 changes: 27 additions & 3 deletions development.md
Expand Up @@ -12,9 +12,33 @@ Now run with

cabal build && dist/build/test/test

## Different backends

# Backends

By default the sqlite backend is tested.
To test other backends, use the CPP options. To test mongoDB use add this CPP option or uncomment this in the cabal file:
To test other backends, you can give a flag described in persisten-test.

cabal configure -fmongodb --enable-tests


## Installing backends

You can develop just against your preferred backend and the community should help sort out issues with others.

However, we have a Dockerfile that you can use to install all the databases.

sudo docker build .

To run this you need to fill in the brackets on this step:

sudo docker run -v <absolute-path-to-persisten>:/home/persistent -t -i <image-hash-from-docker-build> /bin/bash

This only works on Linux, but you can use Linux on Mac or Windows through Virtualbox.

After building you still need to start up the databases in the background (other than sqlite) that you are testing.
For example:

mongod --smallfiles &

-- cpp-options: -DWITH_MONGODB
Docker does not support upstart since it is designed to run a single process, in this case /bin/bash which you can launch other processes with.
In the future we can setup Angel to run all the databases.

0 comments on commit c3719b1

Please sign in to comment.