forked from policycompass/policycompass
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
167 lines (134 loc) · 6.97 KB
/
Makefile
File metadata and controls
167 lines (134 loc) · 6.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
all: update_repros test_install frontend_install postgres_init services_install fcmmanager_install select_nginx_config
PYTHON_EXECUTABLE=$(shell which python3.4)
CATALINA_EXECUTABLE=/usr/share/tomcat7/bin/catalina.sh
ELASTICSEARCH_EXECUTABLE=/usr/share/elasticsearch/bin/elasticsearch
ELASTICSEARCH_INCLUDES=/usr/share/elasticsearch/bin/elasticsearch.in.sh
# should a postgres be started and where is the postgres executable
POSTGRES_DEDICATED=true
ifeq ($(wildcard /usr/lib/postgresql/9.4),)
POSTGRES_BIN_PATH=/usr/lib/postgresql/9.3/bin
else
POSTGRES_BIN_PATH=/usr/lib/postgresql/9.4/bin
endif
POSTGRES_EXECUTABLE=$(POSTGRES_BIN_PATH)/postgres
# python executable used by node-gyp
GYPPYTHON_EXECUTABLE=$(shell which python2)
ADHOCRACY3_COMMIT="438023372d0f225dc8dbf8a7e2d3f5b763d818d8"
# support different config files for different environments
ifeq ($(shell hostname),poco-test)
CONFIG_TYPE ?= stage
endif
ifeq ($(shell hostname),poco-live)
CONFIG_TYPE ?= prod
endif
CONFIG_TYPE ?= dev
#
# Install dependencies from ubtunut sources (needs to be run with root)
#
install_deps: install_deps_ubuntu install_elasticsearch_ubuntu /usr/bin/node
# list of packages for ubuntu 14.04 lts
UBUNTU_PACKAGES= maven tomcat7 libxml2 libxslt1.1 libzip2 python3 python3-pil python3-pip \
python-virtualenv python3-ipdb python3-pep8 pyflakes sqlite build-essential zlibc \
curl file git ruby ruby-dev nodejs npm openjdk-7-jdk phantomjs supervisor nginx \
postgresql ruby-compass
/usr/bin/node:
ln -sfT /usr/bin/nodejs /usr/bin/node
install_deps_ubuntu:
apt-get -y update
apt-get -y install $(UBUNTU_PACKAGES)
/etc/apt/sources.list.d/elasticsearch.list:
curl "https://packages.elasticsearch.org/GPG-KEY-elasticsearch" | apt-key add -
echo "deb http://packages.elasticsearch.org/elasticsearch/1.4/debian stable main" > /etc/apt/sources.list.d/elasticsearch.list
apt-get -y update
install_elasticsearch_ubuntu: /etc/apt/sources.list.d/elasticsearch.list
apt-get -y install elasticsearch
#
# Install policy compass development environment into user account
#
# recursivly checkout all submodules master branches
update_repros:
git submodule update --init
git submodule foreach git checkout master
git submodule foreach git pull
git submodule foreach 'git config remote.origin.pushurl $$(git config --get remote.origin.url | sed "s#https://github.com/#git@github.com:#")'
bin/python3.4:
virtualenv --python=$(PYTHON_EXECUTABLE) .
bin/wheel: bin/python3.4
./bin/pip3.4 install -I wheel
cache/wheels: bin/wheel
./bin/pip3.4 wheel --wheel-dir=./cache/wheels -r requirements.txt
test_install: cache/wheels bin/wheel bin/python3.4
./bin/pip3.4 install --upgrade wheel
./bin/pip3.4 install --no-index --find-links=./cache/wheels -r requirements.txt
frontend_install:
cd policycompass-frontend && npm install --python=$(GYPPYTHON_EXECUTABLE)
cd policycompass-frontend && node_modules/.bin/bower --config.interactive=false prune
cd policycompass-frontend && node_modules/.bin/bower --config.interactive=false install
cd policycompass-frontend && compass compile -e production
ln -sfT ../../etc/policycompass/$(CONFIG_TYPE)/frontend-config.js policycompass-frontend/app/config.js
echo '{"PC_SERVICES_URL": "http://localhost:8000", "FCM_SERVICES_URL": "http://localhost:10080", "ELASTIC_SEARCH_URL": "http://localhost:9200"}' > policycompass-frontend/development.json
policycompass-services/bin/python3.4:
virtualenv --python=$(PYTHON_EXECUTABLE) policycompass-services
services_install: policycompass-services/bin/python3.4
ln -sfT $(ELASTICSEARCH_EXECUTABLE) bin/elasticsearch
ln -sfT $(ELASTICSEARCH_INCLUDES) bin/elasticsearch.in.sh
policycompass-services/bin/pip3.4 install --upgrade wheel
policycompass-services/bin/pip3.4 install --download-cache cache/downloads -r policycompass-services/requirements.txt
ln -sfT ../../etc/policycompass/$(CONFIG_TYPE)/services-settings.py policycompass-services/config/settings.py
cd policycompass-services && bin/python3.4 manage.py migrate
cd policycompass-services && bin/python3.4 manage.py loaddata datasets metrics indicators events common references visualizations
cd policycompass-services && bin/python3.4 manage.py collectstatic --noinput
adhocracy3:
git clone https://github.com/liqd/adhocracy3.git
adhocracy3_git: adhocracy3
cd adhocracy3 &&\
git fetch -a &&\
git checkout $(ADHOCRACY3_COMMIT) &&\
git submodule update --init
adhocracy3/bin/python3.4: adhocracy3
virtualenv --python=$(PYTHON_EXECUTABLE) adhocracy3
adhocracy3/bin/buildout: adhocracy3 adhocracy3/bin/python3.4 adhocracy3_git
mkdir -p adhocracy3/eggs # needed since buildout sometimes fails to create egg
cd adhocracy3 && ./bin/python3.4 ./bootstrap.py --buildout-version 2.4.4 --setuptools-version=18.3.2
adhocracy3_install: adhocracy3/bin/buildout
cd adhocracy3 && bin/buildout -c buildout-pcompass.cfg
ln -sfT ../../etc/adhocracy/$(CONFIG_TYPE)/development.ini adhocracy3/etc/development.ini
ln -sfT ../../etc/adhocracy/$(CONFIG_TYPE)/frontend_development.ini adhocracy3/etc/frontend_development.ini
adhocracy3_setup_resources:
cd adhocracy3 && bin/import_resources etc/development.ini ../etc/adhocracy/resources.json
bin/lein:
mkdir -p bin
wget https://raw.githubusercontent.com/technomancy/leiningen/2.5.1/bin/lein -O bin/lein
chmod +x bin/lein
postgres_init:
ln -sfT $(POSTGRES_EXECUTABLE) bin/postgres
ifeq ($(POSTGRES_DEDICATED), true)
if [ ! -f var/lib/postgres/PG_VERSION ]; then \
$(POSTGRES_BIN_PATH)/initdb var/lib/postgres &&\
$(POSTGRES_BIN_PATH)/pg_ctl start -D var/lib/postgres -o "-c config_file=etc/postgres/postgresql.conf -c unix_socket_directories=''" &&\
sleep 2 &&\
createuser -h localhost -p 5433 --no-superuser --no-createrole --no-createdb pcompass &&\
createdb -h localhost -p 5433 -e pcompass -E UTF-8 --owner=pcompass &&\
$(POSTGRES_BIN_PATH)/pg_ctl stop -D var/lib/postgres;\
fi
else
psql -c "create user pcompass with unencrypted password 'pcompass';" -U postgres
psql -c "create database pcompass owner pcompass;" -U postgres
endif
export CATALINA_HOME := $(CURDIR)/var/lib/tomcat
ifeq ($(POSTGRES_DEDICATED), true)
export POSTGRES_URI := postgresql://localhost:5433/pcompass
else
export POSTGRES_URI := postgresql://localhost:5432/pcompass
endif
fcmmanager_install:
ln -sfT $(CATALINA_EXECUTABLE) ./bin/catalina.sh
sed 's#postgresql://localhost:5432/pcompass#$(POSTGRES_URI)#' policycompass-fcmmanager/src/main/resources/hibernate.cfg.template.xml > policycompass-fcmmanager/src/main/resources/hibernate.cfg.xml
cd policycompass-fcmmanager && mvn clean install
fcmmanager_loaddata:
curl http://localhost:10080/api/v1/fcmmanager/loaddata
elasticsearch_rebuildindex:
curl -XPOST 'http://localhost:8000/api/v1/searchmanager/rebuildindex'
select_nginx_config:
ln -sfT ./nginx/$(CONFIG_TYPE)/nginx.conf etc/nginx.conf
.PHONY: test_install frontend_install adhocracy3_git adhocracy3_install postgres_init fcmmanager_install fcmmanager_loaddata all install_deps install_elasticsearch_ubuntu install_deps_ubuntu elasticsearch_rebuildindex select_nginx_config