Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 7 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,13 @@
sudo: required
language: python
python:
- "2.7"

addons:
postgresql: "9.3"
services:
- docker

install:
- sudo apt-get update -y &&
sudo apt-get install -y
build-essential htop
python-dev python-pip python-virtualenv
libxml2-dev libxslt1-dev
libcurl4-openssl-dev libssl-dev zlib1g-dev libpcre3-dev
libldap2-dev libsasl2-dev
libjpeg-dev
libfreetype6-dev
libpq-dev
npm
memcached
- npm install
- pip install -r requirements.txt
before_install:
- docker build -t fum .
- docker build -t fum-test docker/test/

- mkdir -p media/portraits/full media/portraits/thumb media/portraits/badge
- psql -c 'create database fum;' -U postgres
- cp local_settings.py.template local_settings.py
- sed -i local_settings.py
-e "s/^SECRET_KEY =.*$/SECRET_KEY = 'test'/"
-e "s/company/futurice/g"
-e "s/Company/Futurice/g"
-e 's/example\.com/futurice.com/g'

script: python manage.py test --settings=fum.settings.test --noinput fum
script: docker run fum-test
51 changes: 51 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM ubuntu:16.04
MAINTAINER Topi Paavilainen <topi.paavilainen@futurice.com>

### APT-GET ###

RUN apt-get update
RUN apt-get install -y \
build-essential htop \
python-dev python-pip \
libxml2-dev libxslt1-dev \
libcurl4-openssl-dev libssl-dev zlib1g-dev libpcre3-dev \
libldap2-dev libsasl2-dev \
libjpeg-dev \
libfreetype6-dev \
libpq-dev \
npm \
memcached \
openjdk-8-jdk \
nginx \
supervisor

RUN ln -s /usr/bin/nodejs /usr/bin/node

RUN apt-get install -y wget unzip
RUN wget -q http://archive.apache.org/dist/lucene/solr/3.6.2/apache-solr-3.6.2.zip
RUN unzip apache-solr-3.6.2.zip

WORKDIR /opt/app

### DEPENDENCIES ###
COPY package.json /opt/
RUN cd /opt/ && npm install
RUN ln -s /opt/node_modules/less/bin/lessc /usr/bin/

COPY requirements.txt /opt/app/
RUN apt-get install -y libffi-dev && pip install -r requirements.txt

COPY . /opt/app/

RUN mkdir -p /opt/media/portraits/full /opt/media/portraits/thumb /opt/media/portraits/badge
RUN mkdir /opt/static

USER root
ENV DJANGO_SETTINGS_MODULE fum.settings.base
ENV SECRET_KEY default_insecure_secret

EXPOSE 8000
COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
ADD docker/nginx.conf /etc/nginx/nginx.conf

CMD ["bash", "docker/start.sh"]
33 changes: 25 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,35 @@ sed -e "s/^SECRET_KEY =.*$/SECRET_KEY = 'test'/" \
# set USE_TLS=False if some LDAP connections don't work
# Change IT_TEAM to an existing group you're part of to get SUDO permission
```
Run using Docker
================
First build & run your local 389 ldap-server on docker. Insert your 389-servers IP address to `local_settings.py > LDAP_CONNECTION > uri`. 389-server should be running while building FUM.
Set `USE_TLS` and `CHANGES_SOCKET_ENABLED` in `settings/base.py` to False.

Run using Vagrant
=================
Enter your LDAP username in `vagrant/REMOTE_USER`, e.g.:
```bash
echo username >vagrant/REMOTE_USER
Build the docker image:
```
docker build -t fum-docker futurice-ldap-user-manager/
```

```bash
vagrant up
Run:
```
docker run -p 8080:8000 fum-docker
```

Now FUM should be running locally and can be viewed on `localhost:8080`

To search with Solr+Haystack:
````
docker exec <fum container name> ./manage.py update_index
````

Running tests:
```
[localhost:8000](http://localhost:8000)
docker exec <fum container name> ./manage.py test --settings=fum.settings.test_live
```
FUM should be running while running tests.



Develop locally using Procboy
=============================
Expand Down
21 changes: 0 additions & 21 deletions Vagrantfile

This file was deleted.

2 changes: 1 addition & 1 deletion assetgen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ generate:
- fum/common/static/css/main.less
- fum/common/static/css/imgareaselect-animated.css

output.directory: static
output.directory: /opt/static
output.hashed: true
output.manifest: assets.json

Expand Down
44 changes: 44 additions & 0 deletions docker/dev_nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
user www-data;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;
sendfile off;
keepalive_timeout 65;
client_max_body_size 100M;
server {
server_name localhost docker.dev;
listen 8000;
client_max_body_size 100M;
access_log off;
sendfile off;
expires 0;

location / {
client_max_body_size 100M;

proxy_pass http://127.0.0.1:8001;
proxy_set_header Host $host:8000;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Port 8000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect off;
}
}
}
daemon off;
48 changes: 48 additions & 0 deletions docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
user www-data;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;
sendfile off;
keepalive_timeout 65;
client_max_body_size 100M;
server {
server_name localhost;
listen 8000;
client_max_body_size 100M;
access_log off;
sendfile on;
expires 0;

location /static {
alias /opt/static;
}

location / {
client_max_body_size 100M;

uwsgi_pass 127.0.0.1:3031;

include uwsgi_params;

uwsgi_param Host $host;
uwsgi_param X-Forwarded-Host $server_name;
uwsgi_param X-Real-IP $remote_addr;
}
}
}
daemon off;
28 changes: 28 additions & 0 deletions docker/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

./manage.py build_solr_schema > /tmp/schema.xml
cp /tmp/schema.xml /apache-solr-3.6.2/example/solr/conf/
cp /apache-solr-3.6.2/example/solr/conf/stopwords.txt /apache-solr-3.6.2/example/solr/conf/stopwords_en.txt
export PATH=$PATH:/apache-solr-3.6.2/example/solr/conf/

assetgen --profile dev assetgen.yaml --force
./manage.py collectstatic --noinput
./manage.py migrate --noinput

# development: be logged in as specified REMOTE_USER
replaceinfile() {
find $1 -type f -exec sed -i "s~$2~$3~g" {} \;
}
if [[ -n "$REMOTE_USER" ]]; then
replaceinfile "/etc/supervisor/conf.d/supervisord.conf" "#devuser" "environment=REMOTE_USER=\"$REMOTE_USER\""
fi
# DEBUG
if [[ "$DEBUG" == "true" ]]; then
FUM_CMD="command=./manage.py runserver --nostatic 8001"
cp docker/dev_nginx.conf /etc/nginx/nginx.conf
else
FUM_CMD="command=/usr/local/bin/uwsgi -s 127.0.0.1:3031 --wsgi-file uwsgi.py"
fi
replaceinfile "/etc/supervisor/conf.d/supervisord.conf" "#fumcmd" "$FUM_CMD"

/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
16 changes: 16 additions & 0 deletions docker/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[supervisord]
nodaemon=true

[program:fum]
#fumcmd
directory=/opt/app/
startsecs=5
#devuser

[program:nginx]
command=/usr/sbin/nginx -c /etc/nginx/nginx.conf

[program:solr]
command=java -jar start.jar
directory=/apache-solr-3.6.2/example/
environment=PATH=$PATH:/apache-solr-3.6.2/example/solr/conf/
10 changes: 10 additions & 0 deletions docker/test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM fum

RUN cp local_settings.py.template local_settings.py
RUN sed -i local_settings.py \
-e "s/^SECRET_KEY =.*$/SECRET_KEY = 'test'/" \
-e "s/company/futurice/g" \
-e "s/Company/Futurice/g" \
-e 's/example\.com/futurice.com/g'

CMD python manage.py test --settings=fum.settings.test --noinput fum
Loading