forked from epfl-si/jahia2wp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
124 lines (104 loc) · 3.66 KB
/
Makefile
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
#!make
# Default values, can be overridden either on the command line of make
# or in .env
WP_ENV ?= your-env
WP_PORT_HTTP ?= 80
WP_PORT_HTTPS ?= 443
# Used to clean vEnv with name used by Travis because it is already used for 'generate-many' functional-tests locally
# and we have to clean this vEnv correctly for the test to execute correctly
WP_TRAVIS_TEST_ENV = 'test'
check-env:
ifeq ($(wildcard .env),)
@echo "Please create your .env file first, from .env.sample"
@exit 1
else
include .env
endif
_mgmt_container = $(shell docker ps -q --filter "label=ch.epfl.jahia2wp.mgmt.env=${WP_ENV}")
_httpd_container = $(shell docker ps -q --filter "label=ch.epfl.jahia2wp.httpd.env=${WP_ENV}")
test: check-env
# The "test-raw" target is in Makefile.mgmt
docker exec --user=www-data $(_mgmt_container) make -C /srv/$$WP_ENV/jahia2wp test-raw
functional-tests: check-env
# The "functional-tests-raw" target is in Makefile.mgmt
# WP_ENV hardcoded to 'test'
docker exec --user=www-data \
-e HTTPD_CONTAINER=$(_httpd_container) \
$(_mgmt_container) make -C /srv/$$WP_ENV/jahia2wp functional-tests-raw
vars: check-env
@echo 'Environment-related vars:'
@echo ' WP_ENV=${WP_ENV}'
@echo ' _mgmt_container=${_mgmt_container}'
@echo ' _httpd_container=${_httpd_container}'
@echo ''
@echo DB-related vars:
@echo ' MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}'
@echo ' MYSQL_DB_HOST=${MYSQL_DB_HOST}'
@echo ' MYSQL_SUPER_USER=${MYSQL_SUPER_USER}'
@echo ' MYSQL_SUPER_PASSWORD=${MYSQL_SUPER_PASSWORD}'
@echo ''
@echo 'Wordpress-related vars:'
@echo ' WP_VERSION=${WP_VERSION}'
@echo ' WP_ADMIN_USER=${WP_ADMIN_USER}'
@echo ' WP_ADMIN_EMAIL=${WP_ADMIN_EMAIL}'
@echo ' WP_PORT_HTTP=${WP_PORT_HTTP}'
@echo ' WP_PORT_HTTPS=${WP_PORT_HTTPS}'
@echo ''
@echo 'WPManagement-related vars:'
@echo ' WP_PORT_PHPMA=${WP_PORT_PHPMA}'
@echo ' WP_PORT_SSHD=${WP_PORT_SSHD}'
@echo ' PLUGINS_CONFIG_BASE_PATH=${PLUGINS_CONFIG_BASE_PATH}'
@echo ''
@echo 'Jahia-related vars:'
@echo ' JAHIA_ZIP_PATH=${JAHIA_ZIP_PATH}'
@echo ' JAHIA_USER=${JAHIA_USER}'
@echo ' JAHIA_PASSWORD=${JAHIA_PASSWORD}'
@echo ' JAHIA_HOST=${JAHIA_HOST}'
pull: check-env
docker-compose pull
up: check-env
@WP_ENV=${WP_ENV} \
MYSQL_DB_HOST=${MYSQL_DB_HOST} \
MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} \
WP_PORT_HTTP=${WP_PORT_HTTP} \
WP_PORT_HTTPS=${WP_PORT_HTTPS} \
docker-compose up -d
exec: check-env
@docker exec --user www-data -it \
-e WP_ENV=${WP_ENV} \
-e MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} \
-e MYSQL_DB_HOST=${MYSQL_DB_HOST} \
$(_mgmt_container) bash -l
httpd: check-env
@docker exec -it $(_httpd_container) bash -l
down: check-env
@WP_PORT_HTTP=${WP_PORT_HTTP} \
WP_PORT_HTTPS=${WP_PORT_HTTPS} \
docker-compose down
bootstrap-local: pull
[ -f .env ] || cp .env.sample .env
[ -f etc/.bash_history ] || cp etc/.bash_history.sample etc/.bash_history
sudo chown -R `whoami`:33 .
sudo chmod -R g+w .
ifdef WP_ENV
@echo "WP_ENV already set to $(WP_ENV)"
make up
else
echo " \
export WP_ENV=$(ENV)" >> ~/.bashrc
WP_ENV=$(ENV) make up
endif
@echo ""
@echo "Done with your local env. You can now"
@if test -z "${WP_ENV}"; then echo " $ source ~/.bashrc (to update your environment with WP_ENV value)"; fi
@echo " $ make exec (to connect into your container)"
clean: down
@bin/clean.sh $(WP_ENV) ${WP_TRAVIS_TEST_ENV}
connect-OS:
@oc login --token="$$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" --insecure-skip-tls-verify=true https://pub-os-exopge.epfl.ch:443
disconnect-OS:
@oc logout
new-route: connect-OS
@bin/new-route.sh -s httpd-$(WP_ENV) -h $(site) | oc -n wwp create -f -
delete-route: connect-OS
@oc delete route httpd-$${site%%.*}