Skip to content

Commit

Permalink
Merge pull request #92 from grueneschweiz/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
cyrillbolliger authored Aug 12, 2020
2 parents a480c3a + 5aa24ff commit 5ebc9b4
Show file tree
Hide file tree
Showing 16 changed files with 930 additions and 941 deletions.
16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ RUN chmod +x /bin/wp-cli.phar /bin/wp
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Copy wp-config.php into container
# (dont mount it, cause it gets updated by a sed srcipt.
# mounting it therefore crashes the boot process.)
COPY wordpress/wp-config.php /var/www/html/wp-config.php

# Show php logs in stderr
RUN touch /usr/local/etc/php/conf.d/php_error.ini
RUN echo "log_errors = on" >> /usr/local/etc/php/conf.d/php_error.ini
Expand All @@ -38,18 +43,13 @@ RUN echo "error_log = /dev/stderr" >> /usr/local/etc/php/conf.d/php_error.ini
# Change uid and gid of apache to docker user uid/gid
RUN usermod -u 1000 www-data && groupmod -g 1000 www-data

# Copy some config files
COPY wordpress/.htaccess /var/www/html/.htaccess
COPY wordpress/wp-config.php /var/www/html/wp-config.php

# Create directory for wp-cli packages
RUN mkdir -p /var/www/.wp-cli/packages
RUN chmod -R 777 /var/www/.wp-cli

# Cleanup
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Install Xdebug
RUN pecl install xdebug
RUN apachectl restart

# Set working directory
WORKDIR /var/www/html
11 changes: 7 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
version: '2'
version: '3'

volumes:
database:

services:
wordpress:
depends_on:
- db
build: .
links:
- db
ports:
# MUST be on port 80, because multisite
# doesn't support ports in base url
- "80:80"
working_dir: /var/www/html
volumes:
- ./wordpress/wp-content/:/var/www/html/wp-content:cached
- ./wordpress/.htaccess:/var/www/html/.htaccess
- ./scripts/php.ini:/usr/local/etc/php/php.ini
- ./scripts/ssmtp.conf:/etc/ssmtp/ssmtp.conf
container_name: wp_docker_les_verts
Expand All @@ -27,7 +30,7 @@ services:
db:
image: mysql:5.7
volumes:
- "./.data/db:/var/lib/mysql:delegated"
- database:/var/lib/mysql:delegated
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
Expand Down
58 changes: 47 additions & 11 deletions scripts/wp-configure.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
#!/usr/bin/env bash

#===========================================
# Configure installation
#===========================================
#
# README:
# * this script should not break things on
# existing website in production
#
# PARAMETERS:
# -n treat this installation as multi site
# (network)
#===========================================

set -e

NETWORK=
while getopts "n" opt; do
case $opt in
n)
NETWORK=1
echo "WP multi site support enabled."
;;
?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done

# set time zone
$WPCLI option update timezone_string "Europe/Zurich"

Expand All @@ -24,21 +53,28 @@ $WPCLI option patch update wpseo_titles post_types-post-maintax <<< "category"

# disable comment everywhere
if [ $NETWORK ]; then
$WPCLI site option patch update disable_comments_options remove_everywhere <<< "true"
$WPCLI site option update --json disable_comments_options <<< '{"disabled_post_types":["post","page","attachment"],"remove_everywhere":true,"extra_post_types":false,"db_version":6}'
else
$WPCLI option patch update disable_comments_options remove_everywhere <<< "true"
$WPCLI option update disable_comments_options <<< '{"disabled_post_types":["post","page","attachment"],"remove_everywhere":true,"extra_post_types":false,"db_version":6}'
fi

# hide 'enable media replace' ads
$WPCLI option update emr_news 1

# configure tribe events
$WPCLI option patch update tribe_events_calendar_options embedGoogleMaps <<< "false"
$WPCLI option patch update tribe_events_calendar_options liveFiltersUpdate <<< "false"
$WPCLI option patch update tribe_events_calendar_options defaultCurrencySymbol <<< "CHF"
$WPCLI option patch update tribe_events_calendar_options reverseCurrencyPosition <<< "true"
$WPCLI option patch update tribe_events_calendar_options stylesheetOption <<< "skeleton"
$WPCLI option patch update tribe_events_calendar_options enable_month_view_cache <<< "false"
$WPCLI option patch update tribe_events_calendar_options viewOption <<< "list"
$WPCLI option patch update tribe_events_calendar_options datepickerFormat <<< "11"
$WPCLI option patch update tribe_events_calendar_options tribe_events_timezone_mode <<< "event"
$WPCLI option patch insert --json tribe_events_calendar_options did_init true
$WPCLI option patch insert tribe_events_calendar_options tribeEventsTemplate default
$WPCLI option patch insert --json tribe_events_calendar_options showComments false
$WPCLI option patch insert tribe_events_calendar_options defaultCurrencySymbol CHF
$WPCLI option patch insert --json tribe_events_calendar_options reverseCurrencyPosition true
$WPCLI option patch insert --json tribe_events_calendar_options embedGoogleMaps false
$WPCLI option patch insert tribe_events_calendar_options tribe_events_timezone_mode site
$WPCLI option patch insert --json tribe_events_calendar_options tribe_events_timezones_show_zone false
$WPCLI option patch insert tribe_events_calendar_options stylesheet_mode skeleton
$WPCLI option patch insert --json tribe_events_calendar_options tribeDisableTribeBar true
$WPCLI option patch insert --json tribe_events_calendar_options donate-link false
$WPCLI option patch insert tribe_events_calendar_options viewOption list
$WPCLI option patch insert tribe_events_calendar_options datepickerFormat "11"

# configure searchwp
$WPCLI option set --json searchwp_engines '{"default":{"label":"Default","settings":{"stemming":true,"adminengine":false},"sources":{"post.post":{"attributes":{"title":80,"content":5,"slug":60,"excerpt":40,"meta":{"*":1},"taxonomy":{"category":50,"post_tag":50}},"rules":[],"options":[]},"post.page":{"attributes":{"title":80,"content":5,"slug":60,"meta":{"*":1}},"rules":[],"options":[]},"post.tribe_events":{"attributes":{"title":80,"content":5,"slug":60,"excerpt":40,"comments":1,"meta":{"*":1}},"rules":[],"options":[]}}}}'
16 changes: 8 additions & 8 deletions scripts/wp-init-local.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
#!/bin/sh

set -e

###########################
# INSTALL DEV ENVIRONMENT #
###########################
# Install theme dependencies with composer
docker exec wp_docker_les_verts bash -c "cd /var/www/html/wp-content/themes/les-verts && composer install"

# Install wp core
docker exec wp_docker_les_verts wp core multisite-install --url=localhost --title=LesVerts --admin_user=admin --admin_password=admin --admin_email=tech+lesverts@superhuit.ch
docker exec wp_docker_les_verts wp core multisite-install --url=localhost --title=LesVERTS --admin_user=admin --admin_password=admin --admin_email=admin@gruene.ch

# Run the bootstrap script
docker cp scripts/wp-install-plugins.sh wp_docker_les_verts:/var/www/html/wp-install-plugins.sh
docker exec wp_docker_les_verts bash -c "cd /var/www/html && chmod +x wp-install-plugins.sh && WPCLI='wp --color' BASE_URL='localhost' ./wp-install-plugins.sh" || exit 1 || return 1
docker cp scripts/wp-configure.sh wp_docker_les_verts:/var/www/html/wp-configure.sh
#docker exec wp_docker_les_verts bash -c "chmod +x wp-install-plugins.sh && WPCLI='wp --color' ./wp-install-plugins.sh -nl"
docker exec wp_docker_les_verts bash -c "chmod +x wp-configure.sh && WPCLI='wp --color' ./wp-configure.sh -n"

# Create dist symlink
docker exec wp_docker_les_verts bash -c "cd /var/www/html/wp-content/themes/les-verts && ln -s styleguide/dist/static static"
docker exec wp_docker_les_verts bash -c "cd wp-content/themes/les-verts && ln -sf styleguide/dist/static static"

######################
# ENABLE IDE SUPPORT #
######################
rm -rf .wordpress
mkdir .wordpress

# download and unzip wordpress
Expand All @@ -27,8 +32,3 @@ tar xvzf .wordpress/latest.tar.gz -C .wordpress/
rm .wordpress/latest.tar.gz
mv .wordpress/wordpress/* .wordpress
rmdir .wordpress/wordpress

# copy the plugins
rm -rf .wordpress/wp-content
cp -r wordpress/wp-content .wordpress
rm -rf .wordpress/wp-content/themes/*
69 changes: 42 additions & 27 deletions scripts/wp-install-plugins.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

#===========================================
# Install & prepare everything
# Install plugins and remove unused stuff
#===========================================
#
# README:
Expand All @@ -16,17 +16,19 @@
# -l this is a multilingual setup
#===========================================

INSTALL_ACTIVATE_ARGUMENT="--activate"
ACTIVATE_NETWORK_ARGUMENT=
set -e

ACTIVATE_NETWORK=
INSTALL_ACTIVATE="--activate"
NETWORK=
MULTILANG=

while getopts "nl" opt; do
case $opt in
n)
NETWORK=1
ACTIVATE_ARGUMENT="--activate-network"
ACTIVATE_NETWORK_ARGUMENT="--network"
ACTIVATE_NETWORK="--network"
INSTALL_ACTIVATE="--activate-network"
echo "WP multi site support enabled."
;;
l)
Expand Down Expand Up @@ -84,72 +86,85 @@ fi
#============================

# Polylang
if [ $MULTILANG ];
then
$WPCLI plugin activate polylang-pro $ACTIVATE_NETWORK_ARGUMENT
# TODO: activate license key
if [ $MULTILANG ]; then
$WPCLI plugin activate polylang-pro $ACTIVATE_NETWORK
# TODO: activate license key
fi

## Advanced Custom Fields PRO
$WPCLI plugin activate advanced-custom-fields-pro $ACTIVATE_NETWORK_ARGUMENT
$WPCLI plugin activate advanced-custom-fields-pro $ACTIVATE_NETWORK
# $WPCLI eval 'acf_pro_update_license("INSERT LICENSE NUMBER HERE");'

## SVG support
$WPCLI plugin install svg-support $INSTALL_ACTIVATE_ARGUMENT
$WPCLI plugin install svg-support $INSTALL_ACTIVATE

# YAOST seo plugin
$WPCLI plugin install wordpress-seo $INSTALL_ACTIVATE_ARGUMENT
$WPCLI plugin install wordpress-seo $INSTALL_ACTIVATE

# Make yoast SEO work with acf
$WPCLI plugin install acf-content-analysis-for-yoast-seo $INSTALL_ACTIVATE_ARGUMENT
$WPCLI plugin install acf-content-analysis-for-yoast-seo $INSTALL_ACTIVATE

# Smush Image Compression
$WPCLI plugin install wp-smushit $INSTALL_ACTIVATE_ARGUMENT
$WPCLI plugin install wp-smushit $INSTALL_ACTIVATE

# Disable emojis code bloat
$WPCLI plugin install disable-emojis $INSTALL_ACTIVATE_ARGUMENT
$WPCLI plugin install disable-emojis $INSTALL_ACTIVATE

# Disable embed code bloat
$WPCLI plugin install disable-embeds $INSTALL_ACTIVATE_ARGUMENT
$WPCLI plugin install disable-embeds $INSTALL_ACTIVATE

# Wordpress importer
$WPCLI plugin install wordpress-importer $INSTALL_ACTIVATE_ARGUMENT
$WPCLI plugin install wordpress-importer

# Theme and plugin translation for polylang
$WPCLI plugin install theme-translation-for-polylang $INSTALL_ACTIVATE_ARGUMENT
if [ $MULTILANG ]; then
$WPCLI plugin install theme-translation-for-polylang $INSTALL_ACTIVATE
fi

# Disable comments system
$WPCLI plugin install disable-comments $INSTALL_ACTIVATE_ARGUMENT
$WPCLI plugin install disable-comments $INSTALL_ACTIVATE

# Events
$WPCLI plugin install the-events-calendar $INSTALL_ACTIVATE_ARGUMENT
$WPCLI plugin install the-events-calendar $INSTALL_ACTIVATE

# Duplicate posts
$WPCLI plugin install post-duplicator $INSTALL_ACTIVATE_ARGUMENT
$WPCLI plugin install post-duplicator $INSTALL_ACTIVATE

# Disable gutenberg
$WPCLI plugin install classic-editor $INSTALL_ACTIVATE_ARGUMENT
$WPCLI plugin install classic-editor $INSTALL_ACTIVATE

# SearchWP
$WPCLI plugin activate searchwp $ACTIVATE_NETWORK_ARGUMENT
$WPCLI plugin activate searchwp $ACTIVATE_NETWORK
if [ $MULTILANG ]; then
$WPCLI plugin activate searchwp-polylang $ACTIVATE_NETWORK
fi

# Enable media replace
$WPCLI plugin install enable-media-replace $INSTALL_ACTIVATE_ARGUMENT
$WPCLI plugin install enable-media-replace $INSTALL_ACTIVATE

# ACF Code Field
$WPCLI plugin install acf-code-field $INSTALL_ACTIVATE_ARGUMENT
$WPCLI plugin install acf-code-field $INSTALL_ACTIVATE

# Disable Administration Email Verification Prompt
$WPCLI plugin install disable-administration-email-verification-prompt $INSTALL_ACTIVATE

# Limit Login Attempts
$WPCLI plugin install limit-login-attempts-reloaded $INSTALL_ACTIVATE

# Maintenance Mode
$WPCLI plugin install wp-maintenance-mode

#====================
# Theme
#====================
if [ $NETWORK ]; then
$WPCLI theme enable les-verts $ACTIVATE_NETWORK_ARGUMENT
$WPCLI theme enable les-verts $ACTIVATE_NETWORK
fi

$WPCLI theme activate les-verts

#====================
# Delete useless themes & extensions
# Delete unused themes & extensions
#====================
$WPCLI theme delete twentyfifteen
$WPCLI theme delete twentysixteen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
},
{
"key": "field_5cee97780b1eb",
"label": "Content",
"name": "content",
"label": "Content",
"name": "content",
"type": "clone",
"instructions": "",
"required": 0,
Expand Down Expand Up @@ -143,16 +143,21 @@
"operator": "==",
"value": "page"
},
{
"param": "post_template",
"operator": "==",
"value": "default"
},
{
"param": "page_type",
"operator": "!=",
"value": "front_page"
}
{
"param": "post_template",
"operator": "==",
"value": "default"
},
{
"param": "page_type",
"operator": "!=",
"value": "front_page"
},
{
"param": "page_type",
"operator": "!=",
"value": "posts_page"
}
]
],
"menu_order": 10,
Expand All @@ -174,5 +179,5 @@
],
"active": 1,
"description": "",
"modified": 1559140287
"modified": 1596474993
}
Loading

0 comments on commit 5ebc9b4

Please sign in to comment.