Skip to content

Commit

Permalink
Merge pull request #210 from hasgeek/docker
Browse files Browse the repository at this point in the history
Docker based development enviroment
  • Loading branch information
jace committed Jul 29, 2015
2 parents b69e0c3 + 59e671f commit e368b58
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM ubuntu:14.04

# Configure apt

RUN echo 'deb http://us.archive.ubuntu.com/ubuntu/ precise universe' >> /etc/apt/sources.list
RUN apt-get -y update

RUN apt-get install -y build-essential git curl
RUN apt-get install -y python python-dev python-setuptools
RUN apt-get install -y software-properties-common python-software-properties
RUN apt-get install -y libpq-dev libffi-dev libxml2-dev libxslt1-dev
RUN apt-get install -y pandoc
RUN apt-get install -y nodejs
RUN easy_install-2.7 pip

# add our requirements
ADD requirements.txt /code/hasjob/requirements.txt

# run pip install
RUN pip2.7 install -r /code/hasjob/requirements.txt

RUN pip2.7 uninstall dnspython3 -y
RUN git clone https://github.com/rthalley/dnspython && cd dnspython && python setup.py install && cd .. && rm -rf dnspython

# copy over our code
ADD . /code/hasjob

WORKDIR /code/hasjob/

EXPOSE 5000
EXPOSE 5432
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,34 @@ To run the server in development mode:

$ python runserver.py

### Install and run with Docker

You can alternatively run Hasjob with Docker.

* Install [Docker](https://docs.docker.com/installation/) and [Compose](https://docs.docker.com/compose/install/)

* Next, rename the `instance/development.docker.py` to `instance/development.py`

* Build the images

```
$ docker-compose build
```
* Initialize the database
```
$ docker-compose run web sh
web$ python manage.py db create
web$ exit
```
* Start the server
```
$ docker-compose up
```
* You can edit the server name and Lastuser settings in the `docker-compose.yml` file
If you encounter a problem setting up, please look at existing issue reports
on GitHub before filing a new issue. This code is the same version used in
production so there is a very good chance you did something wrong and there
Expand Down
24 changes: 24 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
web:
build: .
command: python /code/hasjob/runserver.py &
volumes:
- .:/code/hasjob
environment:
SERVER_NAME: hasjob.docker.dev
LASTUSER_SERVER: https://auth.hasgeek.com
LASTUSER_CLIENT_ID: client-key-here
LASTUSER_CLIENT_SECRET: client-secret-here
links:
- pg
- redis
ports:
- "5000:5000"
- "5432:5432"
- "6379:6379"
pg:
image: postgres
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
redis:
image: redis
14 changes: 14 additions & 0 deletions instance/development.docker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
import os
CACHE_TYPE = 'redis'
CACHE_REDIS_HOST = 'redis'
#: Database backend
SQLALCHEMY_DATABASE_URI = 'postgres://postgres:postgres@pg/postgres'
REDIS_URL = 'redis://redis:6379/0'
SERVER_NAME = (os.environ.get('SERVER_NAME') or 'hasjob.docker.dev') + ':5000'
#: LastUser server
LASTUSER_SERVER = os.environ.get('LASTUSER_SERVER') or 'https://auth.hasgeek.com'
#: LastUser client id
LASTUSER_CLIENT_ID = os.environ.get('LASTUSER_CLIENT_ID') or ''
#: LastUser client secret
LASTUSER_CLIENT_SECRET = os.environ.get('LASTUSER_CLIENT_SECRET') or ''

0 comments on commit e368b58

Please sign in to comment.