Skip to content

Commit e43668e

Browse files
Topi Paavilainenmixman
authored andcommitted
dockerized
1 parent 303dc76 commit e43668e

33 files changed

+383
-634
lines changed

.travis.yml

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,13 @@
1+
sudo: required
12
language: python
23
python:
34
- "2.7"
45

5-
addons:
6-
postgresql: "9.3"
6+
services:
7+
- docker
78

8-
install:
9-
- sudo apt-get update -y &&
10-
sudo apt-get install -y
11-
build-essential htop
12-
python-dev python-pip python-virtualenv
13-
libxml2-dev libxslt1-dev
14-
libcurl4-openssl-dev libssl-dev zlib1g-dev libpcre3-dev
15-
libldap2-dev libsasl2-dev
16-
libjpeg-dev
17-
libfreetype6-dev
18-
libpq-dev
19-
npm
20-
memcached
21-
- npm install
22-
- pip install -r requirements.txt
9+
before_install:
10+
- docker build -t fum .
11+
- docker build -t fum-test docker/test/
2312

24-
- mkdir -p media/portraits/full media/portraits/thumb media/portraits/badge
25-
- psql -c 'create database fum;' -U postgres
26-
- cp local_settings.py.template local_settings.py
27-
- sed -i local_settings.py
28-
-e "s/^SECRET_KEY =.*$/SECRET_KEY = 'test'/"
29-
-e "s/company/futurice/g"
30-
-e "s/Company/Futurice/g"
31-
-e 's/example\.com/futurice.com/g'
32-
33-
script: python manage.py test --settings=fum.settings.test --noinput fum
13+
script: docker run fum-test

Dockerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
FROM ubuntu:16.04
2+
MAINTAINER Topi Paavilainen <[email protected]>
3+
4+
### APT-GET ###
5+
6+
RUN apt-get update
7+
RUN apt-get install -y \
8+
build-essential htop \
9+
python-dev python-pip \
10+
libxml2-dev libxslt1-dev \
11+
libcurl4-openssl-dev libssl-dev zlib1g-dev libpcre3-dev \
12+
libldap2-dev libsasl2-dev \
13+
libjpeg-dev \
14+
libfreetype6-dev \
15+
libpq-dev \
16+
npm \
17+
memcached \
18+
openjdk-8-jdk \
19+
nginx \
20+
supervisor
21+
22+
RUN ln -s /usr/bin/nodejs /usr/bin/node
23+
24+
RUN apt-get install -y wget unzip
25+
RUN wget -q http://archive.apache.org/dist/lucene/solr/3.6.2/apache-solr-3.6.2.zip
26+
RUN unzip apache-solr-3.6.2.zip
27+
28+
WORKDIR /opt/app
29+
30+
### DEPENDENCIES ###
31+
COPY package.json /opt/
32+
RUN cd /opt/ && npm install
33+
RUN ln -s /opt/node_modules/less/bin/lessc /usr/bin/
34+
35+
COPY requirements.txt /opt/app/
36+
RUN apt-get install -y libffi-dev && pip install -r requirements.txt
37+
38+
COPY . /opt/app/
39+
40+
RUN mkdir -p media/portraits/full media/portraits/thumb media/portraits/badge
41+
42+
RUN mkdir /opt/static/ && mkdir /opt/media/
43+
44+
USER root
45+
ENV DJANGO_SETTINGS_MODULE fum.settings.base
46+
ENV SECRET_KEY default_insecure_secret
47+
48+
EXPOSE 8000
49+
COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
50+
ADD docker/nginx.conf /etc/nginx/nginx.conf
51+
52+
CMD ["bash", "docker/start.sh"]

README.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,35 @@ sed -e "s/^SECRET_KEY =.*$/SECRET_KEY = 'test'/" \
2121
# set USE_TLS=False if some LDAP connections don't work
2222
# Change IT_TEAM to an existing group you're part of to get SUDO permission
2323
```
24+
Run using Docker
25+
================
26+
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.
27+
Set `USE_TLS` and `CHANGES_SOCKET_ENABLED` in `settings/base.py` to False.
2428

25-
Run using Vagrant
26-
=================
27-
Enter your LDAP username in `vagrant/REMOTE_USER`, e.g.:
28-
```bash
29-
echo username >vagrant/REMOTE_USER
29+
Build the docker image:
30+
```
31+
docker build -t fum-docker futurice-ldap-user-manager/
3032
```
3133

32-
```bash
33-
vagrant up
34+
Run:
35+
```
36+
docker run -p 8080:8000 fum-docker
37+
```
38+
39+
Now FUM should be running locally and can be viewed on `localhost:8080`
40+
41+
To search with Solr+Haystack:
42+
````
43+
docker exec <fum container name> ./manage.py update_index
44+
````
45+
46+
Running tests:
3447
```
35-
[localhost:8000](http://localhost:8000)
48+
docker exec <fum container name> ./manage.py test --settings=fum.settings.test_live
49+
```
50+
FUM should be running while running tests.
51+
52+
3653

3754
Develop locally using Procboy
3855
=============================

Vagrantfile

Lines changed: 0 additions & 21 deletions
This file was deleted.

assetgen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ generate:
5959
- fum/common/static/css/main.less
6060
- fum/common/static/css/imgareaselect-animated.css
6161

62-
output.directory: static
62+
output.directory: /opt/static
6363
output.hashed: true
6464
output.manifest: assets.json
6565

docker/dev_nginx.conf

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
user www-data;
2+
worker_processes 1;
3+
4+
error_log /var/log/nginx/error.log warn;
5+
pid /var/run/nginx.pid;
6+
7+
events {
8+
worker_connections 1024;
9+
}
10+
11+
http {
12+
include /etc/nginx/mime.types;
13+
default_type application/octet-stream;
14+
15+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
16+
'$status $body_bytes_sent "$http_referer" '
17+
'"$http_user_agent" "$http_x_forwarded_for"';
18+
19+
access_log /var/log/nginx/access.log main;
20+
sendfile off;
21+
keepalive_timeout 65;
22+
client_max_body_size 100M;
23+
server {
24+
server_name localhost docker.dev;
25+
listen 8000;
26+
client_max_body_size 100M;
27+
access_log off;
28+
sendfile off;
29+
expires 0;
30+
31+
location / {
32+
client_max_body_size 100M;
33+
34+
proxy_pass http://127.0.0.1:8001;
35+
proxy_set_header Host $host:8000;
36+
proxy_set_header X-Forwarded-Host $server_name;
37+
proxy_set_header X-Forwarded-Port 8000;
38+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
39+
proxy_set_header X-Real-IP $remote_addr;
40+
proxy_redirect off;
41+
}
42+
}
43+
}
44+
daemon off;

docker/nginx.conf

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
user www-data;
2+
worker_processes 1;
3+
4+
error_log /var/log/nginx/error.log warn;
5+
pid /var/run/nginx.pid;
6+
7+
events {
8+
worker_connections 1024;
9+
}
10+
11+
http {
12+
include /etc/nginx/mime.types;
13+
default_type application/octet-stream;
14+
15+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
16+
'$status $body_bytes_sent "$http_referer" '
17+
'"$http_user_agent" "$http_x_forwarded_for"';
18+
19+
access_log /var/log/nginx/access.log main;
20+
sendfile off;
21+
keepalive_timeout 65;
22+
client_max_body_size 100M;
23+
server {
24+
server_name localhost;
25+
listen 8000;
26+
client_max_body_size 100M;
27+
access_log off;
28+
sendfile on;
29+
expires 0;
30+
31+
location /static {
32+
alias /opt/static;
33+
}
34+
35+
location / {
36+
client_max_body_size 100M;
37+
38+
uwsgi_pass 127.0.0.1:3031;
39+
40+
include uwsgi_params;
41+
42+
uwsgi_param Host $host;
43+
uwsgi_param X-Forwarded-Host $server_name;
44+
uwsgi_param X-Real-IP $remote_addr;
45+
}
46+
}
47+
}
48+
daemon off;

docker/start.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
./manage.py build_solr_schema > /tmp/schema.xml
4+
cp /tmp/schema.xml /apache-solr-3.6.2/example/solr/conf/
5+
cp /apache-solr-3.6.2/example/solr/conf/stopwords.txt /apache-solr-3.6.2/example/solr/conf/stopwords_en.txt
6+
export PATH=$PATH:/apache-solr-3.6.2/example/solr/conf/
7+
8+
assetgen --profile dev assetgen.yaml --force
9+
./manage.py collectstatic --noinput
10+
./manage.py migrate --noinput
11+
12+
# development: be logged in as specified REMOTE_USER
13+
replaceinfile() {
14+
find $1 -type f -exec sed -i "s~$2~$3~g" {} \;
15+
}
16+
if [[ -n "$REMOTE_USER" ]]; then
17+
replaceinfile "/etc/supervisor/conf.d/supervisord.conf" "#devuser" "environment=REMOTE_USER=\"$REMOTE_USER\""
18+
fi
19+
# DEBUG
20+
if [[ "$DEBUG" == "true" ]]; then
21+
FUM_CMD="command=./manage.py runserver --nostatic 8001"
22+
cp docker/dev_nginx.conf /etc/nginx/nginx.conf
23+
else
24+
FUM_CMD="command=/usr/local/bin/uwsgi -s 127.0.0.1:3031 --wsgi-file uwsgi.py"
25+
fi
26+
replaceinfile "/etc/supervisor/conf.d/supervisord.conf" "#fumcmd" "$FUM_CMD"
27+
28+
/usr/bin/supervisord -c /etc/supervisor/supervisord.conf

docker/supervisord.conf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[supervisord]
2+
nodaemon=true
3+
4+
[program:fum]
5+
#fumcmd
6+
directory=/opt/app/
7+
startsecs=5
8+
#devuser
9+
10+
[program:nginx]
11+
command=/usr/sbin/nginx -c /etc/nginx/nginx.conf
12+
13+
[program:solr]
14+
command=java -jar start.jar
15+
directory=/apache-solr-3.6.2/example/
16+
environment=PATH=$PATH:/apache-solr-3.6.2/example/solr/conf/

docker/test/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM fum
2+
3+
RUN cp local_settings.py.template local_settings.py
4+
RUN sed -i local_settings.py \
5+
-e "s/^SECRET_KEY =.*$/SECRET_KEY = 'test'/" \
6+
-e "s/company/futurice/g" \
7+
-e "s/Company/Futurice/g" \
8+
-e 's/example\.com/futurice.com/g'
9+
10+
CMD python manage.py test --settings=fum.settings.test --noinput fum

0 commit comments

Comments
 (0)