Skip to content

Commit

Permalink
Add wovnphp-drupal7
Browse files Browse the repository at this point in the history
  • Loading branch information
iwai-wovn committed Nov 21, 2020
1 parent 253b934 commit b7b0cbb
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 0 deletions.
57 changes: 57 additions & 0 deletions wovnphp-drupal7/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

DRUPAL_LANG_JA ?= yes

DRUPAL_USER ?= admin
DRUPAL_PASS ?= admin
DRUSH ?= docker-compose run --rm drush drush
DRUPAL_INIT ?= docker-compose run --rm drupal /bin/bash /usr/local/bin/docker-cmd.sh
DRUPAL_SED ?= docker-compose run --rm drupal /bin/sed -i""

SITE_MAIL ?= [email protected]
ACCOUNT_MAIL ?= $(SITE_MAIL)

MYSQL_ROOT_PASSWORD = password
MYSQL_DATABASE = drupal
MYSQL_USER = user
MYSQL_PASSWORD = password

WOVNPHP_HTACCESS ?= no

.PHONY: all
all: clean install

.PHONY: clean
clean: clean-wovnphp
-chmod -f -R +rw public
rm -rf public
rm -rf data/mysql/*

.PHONY: install
install: install-drupal install-wovnphp

include ../common/common.mk
include ../common/wovnphp.mk

.PHONY: install-drupal
install-drupal:
mkdir -p public
$(DRUPAL_INIT)
sleep 10 # Wait for database
# TODO: Need mail setting of php
$(DRUSH) site-install standard -y --account-name=$(DRUPAL_USER) --account-pass=$(DRUPAL_PASS) --site-mail="$(SITE_MAIL)" --account-mail="$(ACCOUNT_MAIL)" \
--db-su=root --db-su-pw=$(MYSQL_ROOT_PASSWORD) --db-url="mysql://$(MYSQL_USER):$(MYSQL_PASSWORD)@mysql/$(MYSQL_DATABASE)" install_configure_form.update_status_module='array(FALSE,FALSE)'
ifeq ($(DRUPAL_LANG_JA),yes)
$(DRUSH) dl drush_language --destination=/root/.drush
$(DRUSH) cache-clear drush
$(DRUSH) -y pm-enable locale
$(DRUSH) language-add ja
$(DRUSH) language-default ja
$(DRUSH) -y pm-disable locale
$(DRUSH) -y pm-enable l10n_update
$(DRUSH) l10n-update-refresh
$(DRUSH) l10n-update
endif
$(DRUSH) -y pm-enable pathauto
$(DRUSH) -y pm-enable ctools
$(DRUSH) -y pm-enable webform
$(DRUPAL_SED) -e "0,/<?php/ s/<?php/<?php\nrequire_once \$$_SERVER['DOCUMENT_ROOT'].\'\/WOVN.php\/src\/wovn_interceptor.php\'\);\n/" index.php
Empty file.
31 changes: 31 additions & 0 deletions wovnphp-drupal7/docker-cmd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# -*- tab-width: 2 -*-
set -euo pipefail

if [[ "${1-}" == apache2* ]] || [ "${1-}" == php-fpm ] || [ -z "${1-}" ]; then
if [ ! -e index.php ] && [ ! -e core ]; then
# if the directory exists and Drupal doesn't appear to be installed AND the permissions of it are root:root,
# let's chown it (likely a Docker-created directory)
if [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "www-data:www-data" .
fi

echo >&2 "Drupal not found in $PWD - copying now..."
if [ -n "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
fi

tar --create --file - --directory /var/www/html --owner "www-data" --group "www-data" . | tar --extract --file - --no-overwrite-dir
echo >&2 "Complete! Drupal has been successfully copied to $PWD"
fi
[ -z "${1-}" ] && exit 0;
fi

echo $@

# first arg is `-f` or `--some-option`
if [ "${1#-}" != "${1-}" ]; then
set -- apache2-foreground "$@"
fi

exec "$@"
43 changes: 43 additions & 0 deletions wovnphp-drupal7/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: '2.1'
services:
drupal:
image: drupal:7-apache
ports:
- 8080:80
working_dir: /var/www/public
volumes:
- ./docker-cmd.sh:/usr/local/bin/docker-cmd.sh
- ./httpd.conf:/etc/apache2/sites-available/000-default.conf
- ./public:/var/www/public
command: ["docker-cmd.sh", "apache2-foreground"]
depends_on:
- mysql

mysql:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: drupal
MYSQL_USER: user
MYSQL_PASSWORD: password
volumes:
- ./data/mysql:/var/lib/mysql

drush:
image: drupaldocker/drush:8
environment:
- "PHP_OPTIONS=-d sendmail_path=/bin/true"
working_dir: /var/www/public
volumes:
- cache:/root/.drush
- ./public:/var/www/public

ngrok:
environment:
- "NGROK_PORT=drupal:80"
extends:
file: ../common/docker-services.yml
service: ngrok

volumes:
cache:
13 changes: 13 additions & 0 deletions wovnphp-drupal7/httpd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VirtualHost *:80>
#ServerName www.example.com

ServerAdmin webmaster@localhost
DocumentRoot /var/www/public

#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
29 changes: 29 additions & 0 deletions wovnphp-drupal7/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

docker-compose run --rm drush \
drush site-install standard -y --account-name=admin --account-pass=admin \
--db-su=root --db-su-pw=password --db-url="mysql://user:password@mysql/drupal"

docker-compose run --rm drush drush dl drush_language --destination=/root/.drush
docker-compose run --rm drush drush cache-clear drush

docker-compose run --rm drush drush -y pm-enable locale
docker-compose run --rm drush drush language-add ja
docker-compose run --rm drush drush language-default ja

docker-compose run --rm drush drush -y pm-disable locale
docker-compose run --rm drush drush -y pm-enable l10n_update
docker-compose run --rm drush drush l10n-update-refresh
docker-compose run --rm drush drush l10n-update


docker-compose run --rm drush drush -y pm-enable pathauto
docker-compose run --rm drush drush -y pm-enable ctools
docker-compose run --rm drush drush -y pm-enable webform

curl -Ls https://github.com/WOVNio/WOVN.php/archive/master.zip -o WOVN.php.zip

unzip -q WOVN.php.zip \
&& mv WOVN.php-master public/WOVN.php \
&& cp public/WOVN.php/wovn.ini.sample public/wovn.ini \
&& cp public/WOVN.php/wovn_index_sample.php public/wovn_index.php

0 comments on commit b7b0cbb

Please sign in to comment.