-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
46 lines (40 loc) · 2.2 KB
/
setup.sh
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
#!/bin/bash
echo "================================================================="
echo "Source vars"
echo "================================================================="
source .envrc
echo "================================================================="
echo "Checks"
echo "================================================================="
if ! mysql -u "${WORDPRESS_DB_USER}" -p"${WORDPRESS_DB_PASSWORD}" -e '' 2> /dev/null; then
echo "Can't connect to mysql."
exit 1
fi
if ! mysql -u "${WORDPRESS_DB_USER}" -p"${WORDPRESS_DB_PASSWORD}" -e 'use pallospace' 2> /dev/null; then
echo "Create db ${WORDPRESS_DB_NAME}"
mysql -u "${WORDPRESS_DB_USER}" -p"${WORDPRESS_DB_PASSWORD}" -e "CREATE DATABASE ${WORDPRESS_DB_NAME};"
fi
echo "================================================================="
echo "Build images"
echo "================================================================="
docker build . -f docker/Dockerfile.wordpress --tag pallospace:latest
docker build . -f docker/Dockerfile.cli --tag wpcli:latest
echo "================================================================="
echo "Init Wordpress"
echo "================================================================="
docker run --rm --name wpcli \
-v $PWD/html:/var/www/html \
-e PROJECT_NAME="${PROJECT_NAME}" -e URL_PS="${URL_PS}" -e FORCE_SSL_ADMIN="${FORCE_SSL_ADMIN}" \
-e WORDPRESS_ADMIN_USER="${WORDPRESS_ADMIN_USER}" -e WORDPRESS_ADMIN_PASSWORD="${WORDPRESS_ADMIN_PASSWORD}" -e WORDPRESS_ADMIN_EMAIL="${WORDPRESS_ADMIN_EMAIL}" \
-e WORDPRESS_DB_NAME="${WORDPRESS_DB_NAME}" -e WORDPRESS_DB_USER="${WORDPRESS_DB_USER}" -e WORDPRESS_DB_PASSWORD="${WORDPRESS_DB_PASSWORD}" -e WORDPRESS_DB_HOST="${WORDPRESS_DB_HOST}" \
-e WORDPRESS_PLUGINS_TO_INSTALL="${WORDPRESS_PLUGINS_TO_INSTALL}" -e WORDPRESS_THEME_TO_INSTALL="${WORDPRESS_THEME_TO_INSTALL}" \
-e WP_CLI_CACHE_DIR="${WP_CLI_CACHE_DIR}" \
wpcli:latest
echo "================================================================="
echo "Launch Wordpress"
echo "================================================================="
docker rm -f pallospace 2> /dev/null
docker run -d --name pallospace \
-p 8080:80 \
-v $PWD/html:/var/www/html \
pallospace:latest