Skip to content

Commit ebdc65b

Browse files
authored
Merge pull request #1 from creativecommons/with-components
configure environment for components
2 parents 790225e + dccaf4c commit ebdc65b

File tree

6 files changed

+244
-20
lines changed

6 files changed

+244
-20
lines changed

README.md

+52-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# creativecommons.org-environment
22

3-
WordPress implementation of creativecommons.org
4-
5-
(May expand into sibling apps, likely not)
3+
Local development environment for creativecommons.org
64

75

86
## Docker containers
97

108
The [`docker-compose.yml`](docker-comose.yml) file defines the following
119
containers:
1210

13-
1. cc-wordpress-web ([localhost:8080](http://localhost:8080/))
11+
1. cc-web ([localhost:8080](http://localhost:8080/))
1412
2. cc-wordpress-db
1513
3. cc-composer
1614
4. cc-phpmyadmin ([localhost:8003](http://localhost:8003/))
@@ -19,6 +17,19 @@ containers:
1917

2018
## Setup
2119

20+
1. Ensure the following repositories are cloned adjancent to this repository:
21+
```
22+
PARENT_DIR
23+
├── cc-legal-tools-data
24+
├── creativecommons.org-environment
25+
├── chooser
26+
├── faq
27+
└── mp
28+
```
29+
- [creativecommons/cc-legal-tools-data][gh-cc-legal-tools-data]
30+
- [creativecommons/chooser][gh-chooser]
31+
- [creativecommons/faq][gh-faq]
32+
- [creativecommons/mp][gh-mp]
2233
1. Create the `.env` file:
2334
```shell
2435
cp .env.example .env
@@ -30,12 +41,42 @@ containers:
3041
docker compose up
3142
```
3243
4. Wait for build and initialization to complete
33-
5. Install WordPress initially through the GUI. (TODO: Script help here)
44+
5. Install WordPress initially through the GUI.
45+
- **TODO:** Script help here
46+
47+
[gh-cc-legal-tools-data]: https://github.com/creativecommons/cc-legal-tools-data
48+
[gh-chooser]: https://github.com/creativecommons/chooser
49+
[gh-faq]: https://github.com/creativecommons/faq
50+
[gh-mp]: https://github.com/creativecommons/mp
51+
52+
53+
## Dev component URLs
54+
55+
| Component | URL |
56+
| ---------------- | ----------------------------- |
57+
| Chooser | [`/choose`][dev-choose] |
58+
| FAQ | [`/faq`][dev-faq] |
59+
| Licenses | [`/licenses`][dev-licenses] |
60+
| Platform Toolkit | [`/platform/toolkit`][dev-mp] |
61+
| Public Domain | [`/publicdomain`][dev-public] |
62+
| WordPress | [`/` (default)][dev-wp] |
63+
64+
[dev-choose]: http://localhost:8080/choose
65+
[dev-faq]: http://localhost:8080/faq
66+
[dev-licenses]: http://localhost:8080/licenses
67+
[dev-mp]: http://localhost:8080/platform/toolkit
68+
[dev-public]: http://localhost:8080/publicdomain
69+
[dev-wp]: http://localhost:8080/
70+
71+
72+
## Plugins
3473
74+
| Name | Version |
75+
| -------------------------------------------------------- | -------- |
76+
| [Advanced Custom Fields][adv-custom-fields] | `^1.6` |
77+
| [Advanced Custom Fields: Menu Chooser][acf-menu-chooser] | `v1.1.0` |
78+
| [Classic Editor][classic-editor] | `^6.1` |
3579
36-
## Plugins
37-
| name | version |
38-
| --- | --- |
39-
| [Advanced Custom Fields](https://wordpress.org/plugins/advanced-custom-fields/) | ^1.6 |
40-
| [Advanced Custom Fields: Menu Chooser](https://github.com/reyhoun/acf-menu-chooser) | v1.1.0 |
41-
| [Classic Editor](https://wordpress.org/plugins/classic-editor/) | ^6.1 |
80+
[adv-custom-fields]: https://wordpress.org/plugins/advanced-custom-fields/
81+
[acf-menu-chooser]: https://github.com/reyhoun/acf-menu-chooser
82+
[classic-editor]: https://wordpress.org/plugins/classic-editor/
File renamed without changes.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
ServerName localhost:8003
2+
<VirtualHost *:80>
3+
ErrorLog ${APACHE_LOG_DIR}/error.log
4+
CustomLog ${APACHE_LOG_DIR}/access.log combined
5+
6+
DocumentRoot /var/www/html
7+
</VirtualHost>
8+
9+
# vim: ft=apache ts=4 sw=4 sts=4 sr et
+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
ServerName localhost:8080
2+
3+
<VirtualHost *:80>
4+
ErrorLog ${APACHE_LOG_DIR}/error.log
5+
CustomLog ${APACHE_LOG_DIR}/access.log combined
6+
7+
RewriteEngine On
8+
9+
###########################################################################
10+
# Set conservative/secure defaults
11+
<Directory />
12+
AllowOverride None
13+
DirectoryIndex index.html
14+
Options -Indexes
15+
</Directory>
16+
# Git
17+
<DirectoryMatch "/\.git">
18+
Require all denied
19+
</DirectoryMatch>
20+
# Subversion
21+
<DirectoryMatch "/\.svn">
22+
Require all denied
23+
</DirectoryMatch>
24+
# Deny access to accidental uploads of macOS-specific directories and files
25+
# .DS_Store
26+
<FilesMatch "^(\._)?\.[Dd][Ss]_[Ss]tore">
27+
Require all denied
28+
</FilesMatch>
29+
# resource forks
30+
<DirectoryMatch "/__MACOSX">
31+
Require all denied
32+
</DirectoryMatch>
33+
34+
###########################################################################
35+
# CC Legal Tools
36+
# Directory Aliases
37+
Alias /status /var/www/git/cc-legal-tools-data/docs/status
38+
Alias /rdf /var/www/git/cc-legal-tools-data/docs/rdf
39+
Alias /publicdomain /var/www/git/cc-legal-tools-data/docs/publicdomain
40+
Alias /licenses /var/www/git/cc-legal-tools-data/docs/licenses
41+
Alias /cc-legal-tools /var/www/git/cc-legal-tools-data/docs/cc-legal-tools
42+
# File Aliases
43+
Alias /schema.rdf /var/www/git/cc-legal-tools-data/docs/rdf/schema.rdf
44+
Alias /ns.html /var/www/git/cc-legal-tools-data/docs/rdf/ns.html
45+
Alias /ns /var/www/git/cc-legal-tools-data/docs/rdf/ns.html
46+
<Directory /var/www/git/cc-legal-tools-data/docs>
47+
# Disable .htaccess (for security and performance)
48+
AllowOverride None
49+
# Also serve HTML files without .html extension
50+
RewriteCond %{REQUEST_FILENAME}.html -f
51+
RewriteRule !.*\.html$ %{REQUEST_FILENAME}.html [L]
52+
# Redirect .../index.php to .../
53+
RewriteCond %{REQUEST_FILENAME} "index\.php$" [NC]
54+
RewriteCond %{REQUEST_FILENAME} !-f
55+
RewriteRule (.*/)index\.php$ $1 [L,NC,R=301]
56+
# Deny access to PHP files (content should be only static files)
57+
RewriteRule .*\.php$ "-" [F,L]
58+
# Correct mimetype for .../rdf files
59+
RewriteRule (.*/rdf$) $1 [T=application/rdf+xml]
60+
</Directory>
61+
62+
###########################################################################
63+
# Chooser
64+
Alias /choose /var/www/git/chooser/docs
65+
<Directory /var/www/git/chooser/docs>
66+
# Disable .htaccess (for security and performance)
67+
AllowOverride None
68+
# Redirect .../index.php to .../
69+
RewriteCond %{REQUEST_FILENAME} "index\.php$" [NC]
70+
RewriteCond %{REQUEST_FILENAME} !-f
71+
RewriteRule (.*/)index\.php$ $1 [L,NC,R=301]
72+
# Deny access to PHP files (content should be only static files)
73+
RewriteRule .*\.php "-" [F,L]
74+
</Directory>
75+
RedirectPermanent /chooser /choose
76+
77+
###########################################################################
78+
# FAQ
79+
Alias /faq /var/www/git/faq/faq
80+
<Directory /var/www/git/faq/faq>
81+
# Disable .htaccess (for security and performance)
82+
AllowOverride None
83+
# Redirect .../index.php to .../
84+
RewriteCond %{REQUEST_FILENAME} "index\.php$" [NC]
85+
RewriteCond %{REQUEST_FILENAME} !-f
86+
RewriteRule (.*/)index\.php$ $1 [L,NC,R=301]
87+
# Deny access to PHP files (content should be only static files)
88+
RewriteRule .*\.php "-" [F,L]
89+
</Directory>
90+
91+
###########################################################################
92+
# Platform Toolkit
93+
Alias /platform/toolkit /var/www/git/mp/docs
94+
<Directory /var/www/git/mp/docs>
95+
# Disable .htaccess (for security and performance)
96+
AllowOverride None
97+
# Redirect .../index.php to .../
98+
RewriteCond %{REQUEST_FILENAME} "index\.php$" [NC]
99+
RewriteCond %{REQUEST_FILENAME} !-f
100+
RewriteRule (.*/)index\.php$ $1 [L,NC,R=301]
101+
# Deny access to PHP files (content should be only static files)
102+
RewriteRule .*\.php "-" [F,L]
103+
</Directory>
104+
105+
###########################################################################
106+
# WordPress/Default
107+
RewriteRule ^/licenses/$ /about/cclicenses/
108+
RewriteRule ^/publicdomain/$ /about/cclicenses/
109+
DocumentRoot /var/www/html
110+
<Directory /var/www/html>
111+
# Expected configuration for WordPress
112+
# (see conf-available/docker-php.conf)
113+
AllowOverride All
114+
DirectoryIndex index.php index.html
115+
116+
# WP-API
117+
RewriteRule ^(/wp-json/.*)$ /index.php$1 [L]
118+
119+
# Permalinks (for dirs/files not found)
120+
# https://codex.wordpress.org/Using_Permalinks
121+
# Directory Conditions
122+
RewriteCond %{REQUEST_FILENAME} !-d
123+
RewriteCond %{REQUEST_URI} !^/rdf
124+
RewriteCond %{REQUEST_URI} !^/publicdomain
125+
RewriteCond %{REQUEST_URI} !^/platform/toolkit
126+
RewriteCond %{REQUEST_URI} !^/licenses
127+
RewriteCond %{REQUEST_URI} !^/faq
128+
RewriteCond %{REQUEST_URI} !^/choose
129+
RewriteCond %{REQUEST_URI} !^/cc-legal-tools
130+
# File Conditions
131+
RewriteCond %{REQUEST_FILENAME} !-f
132+
RewriteCond %{REQUEST_URI} !^/schema.rdf$
133+
RewriteCond %{REQUEST_URI} !^/ns.html$
134+
RewriteCond %{REQUEST_URI} !^/ns$
135+
# Rule
136+
RewriteRule . /index.php [L]
137+
138+
</Directory>
139+
140+
</VirtualHost>
141+
142+
# vim: ft=apache ts=4 sw=4 sts=4 sr et

docker-compose.yml

+41-9
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@ version: '2.4'
44

55
services:
66

7-
wordpress:
8-
container_name: cc-wordpress-web
7+
web:
8+
command: >
9+
bash -c '
10+
while !</dev/tcp/database/3306
11+
do
12+
echo -n "Waiting on database..."
13+
sleep 1
14+
done 2>/dev/null
15+
apache2-foreground'
16+
container_name: cc-web
917
depends_on:
1018
- database
1119
environment:
@@ -24,13 +32,34 @@ services:
2432
WORDPRESS_DB_name: wordpress
2533
WORDPRESS_USER: root
2634
# https://hub.docker.com/_/wordpress
35+
# https://github.com/docker-library/repo-info/blob/master/repos/wordpress/remote/latest.md
36+
# https://github.com/docker-library/repo-info/blob/master/repos/wordpress/local/latest.md
2737
image: wordpress:${WP_VERSION:?err}
2838
networks:
2939
- backend
3040
ports:
3141
- '8080:80'
32-
restart: always
42+
restart: on-failure
3343
volumes:
44+
# Apache2 web server configuration
45+
- ./config/web-sites-available:/etc/apache2/sites-available:ro
46+
# CC Legal Tools
47+
# - (assumes the cc-legal-tools-data repository has been cloned next to
48+
# this repository)
49+
- ../cc-legal-tools-data:/var/www/git/cc-legal-tools-data:ro
50+
# Chooser
51+
# - (assumes the chooser repository has been cloned next to this
52+
# repository) this repository)
53+
- ../chooser:/var/www/git/chooser:ro
54+
# FAQ
55+
# - (assumes the faq repository has been cloned next to this repository)
56+
# this repository)
57+
- ../faq:/var/www/git/faq:ro
58+
# Platform Toolkit
59+
# - (assumes the mp repository has been cloned next to this repository)
60+
# this repository)
61+
- ../mp:/var/www/git/mp:ro
62+
# WordPress
3463
- wp_data:/var/www/html
3564

3665
database:
@@ -43,7 +72,7 @@ services:
4372
image: mariadb
4473
networks:
4574
- backend
46-
restart: always
75+
restart: on-failure
4776
volumes:
4877
- db_data:/var/lib/mysql
4978

@@ -59,27 +88,30 @@ services:
5988
- backend
6089
ports:
6190
- '8003:80'
91+
volumes:
92+
# Apache2 web server configuration
93+
- ./config/phpmyadmin-sites-available:/etc/apache2/sites-available:ro
6294

6395
composer:
6496
command: 'true'
6597
container_name: cc-composer
6698
depends_on:
6799
- database
68-
- wordpress
100+
- web
69101
# https://hub.docker.com/_/composer
70102
image: composer
71103
user: xfs
72104
volumes:
73-
- ./docker/configs/composer.json:/var/www/html/composer.json
74-
- ./docker/configs/composer.lock:/var/www/html/composer.lock
105+
- ./config/composer/composer.json:/var/www/html/composer.json
106+
- ./config/composer/composer.lock:/var/www/html/composer.lock
75107
- wp_data:/var/www/html
76108
working_dir: /var/www/html/
77109

78110
wordpress-cli:
79111
container_name: cc-wpcli
80112
depends_on:
81113
- database
82-
- wordpress
114+
- web
83115
environment:
84116
WORDPRESS_DB_HOST: database:3306
85117
WORDPRESS_DB_NAME: wordpress
@@ -99,4 +131,4 @@ volumes:
99131
wp_data:
100132

101133
networks:
102-
backend:
134+
backend:

0 commit comments

Comments
 (0)