Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,34 @@ Install the required PHP via composer:
```sh
composer install
```

### Docker Compose development

The existing Alpha-backed setup uses addshore-alpha:

```sh
docker compose -f docker-compose.alpha.yml up -d
```

Open Cradle at <http://localhost:8087/>.

To test against a local MediaWiki instead, start its stack from its checkout:

```sh
docker compose -p cradle-shex-mw up -d
```

Then start Cradle from this checkout:

```sh
docker compose up -d
```

Cradle uses the local wiki at <http://site1.localhost:8001/>. If that host does
not resolve, add `127.0.0.1 site1.localhost` to your hosts file. This MediaWiki
stack uses a fake API; OAuth-backed writes are not configured.

Cradle's source files, Composer dependencies, and generated frontend resources
are mounted from this checkout, so edits are available without rebuilding the
image. Run `composer install` first to populate dependencies and generated
resources.
18 changes: 18 additions & 0 deletions docker-compose.alpha.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3.3'
services:
cradle:
build: .
volumes:
- ./public_html/api.php:/var/www/html/cradle/public_html/api.php:ro
- ./public_html/config.js.template:/var/www/html/cradle/public_html/config.js.template:ro
- ./public_html/index.html:/var/www/html/cradle/public_html/index.html:ro
- ./public_html/vue.js:/var/www/html/cradle/public_html/vue.js:ro
- ./public_html/vue_components:/var/www/html/cradle/public_html/vue_components:ro
- ./public_html/resources:/var/www/html/cradle/public_html/resources:ro
- ./vendor:/var/www/html/cradle/vendor:ro
- ./docker/config-docker-compose-alpha.js:/var/www/html/cradle/public_html/config.js:ro
ports:
- 8087:80
environment:
CRADLE_WIKIBASE_BASE_URL: https://addshore-alpha.wiki.opencura.com
CRADLE_BASE_URL: http://localhost:8087
14 changes: 11 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ services:
cradle:
build: .
volumes:
- ./docker/config-docker-compose.js:/var/www/html/cradle/public_html/config.js
- ./public_html:/var/www/html/cradle/public_html
- ./vendor:/var/www/html/cradle/vendor
- ./public_html/api.php:/var/www/html/cradle/public_html/api.php:ro
- ./public_html/config.js.template:/var/www/html/cradle/public_html/config.js.template:ro
- ./public_html/index.html:/var/www/html/cradle/public_html/index.html:ro
- ./public_html/vue.js:/var/www/html/cradle/public_html/vue.js:ro
- ./public_html/vue_components:/var/www/html/cradle/public_html/vue_components:ro
- ./public_html/resources:/var/www/html/cradle/public_html/resources:ro
- ./vendor:/var/www/html/cradle/vendor:ro
- ./docker/config-docker-compose.js:/var/www/html/cradle/public_html/config.js:ro
ports:
- 8087:80
environment:
CRADLE_WIKIBASE_BASE_URL: http://site1.localhost:8001
CRADLE_BASE_URL: http://localhost:8087
15 changes: 15 additions & 0 deletions docker/config-docker-compose-alpha.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

const wikibaseBaseUrl = 'https://addshore-alpha.wiki.opencura.com';
const cradleBaseUrl = 'http://localhost:8087';

let config = {
"source_page": 'Project:Cradle',
"wikibase_url": `${wikibaseBaseUrl}/wiki/`,
"api": `${wikibaseBaseUrl}/w/api.php`,
"wikibase_api": `${wikibaseBaseUrl}/w/api.php`,
"oauth_url": `${wikibaseBaseUrl}/w/index.php?title=Special:OAuth`,
"cradle_url": `${cradleBaseUrl}/`,
"cradle_api": `${cradleBaseUrl}/api.php`,
"vue_components_base_url": `${cradleBaseUrl}/resources/vue/`
} ;
20 changes: 11 additions & 9 deletions docker/config-docker-compose.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
'use strict';

// Hardcoded addshore-alpha API for development..
const wikibaseBaseUrl = 'http://site1.localhost:8001';
const cradleBaseUrl = 'http://localhost:8087';

let config = {
"source_page":'Project:Cradle',
"wikibase_url":'https://addshore-alpha.wiki.opencura.com/wiki/',
"api":'https://addshore-alpha.wiki.opencura.com/w/api.php',
"wikibase_api":'https://addshore-alpha.wiki.opencura.com/w/api.php',
"oauth_url":'https://addshore-alpha.wiki.opencura.com/w/index.php?title=Special:OAuth',
"cradle_url":'http://localhost:8087/cradle/',
"cradle_api":'http://localhost:8087/api.php',
"vue_components_base_url": 'http://localhost:8087/resources/vue/'
"source_page": 'Project:Cradle',
"wikibase_url": `${wikibaseBaseUrl}/wiki/`,
"api": `${wikibaseBaseUrl}/w/api.php`,
"wikibase_api": `${wikibaseBaseUrl}/w/api.php`,
"oauth_url": `${wikibaseBaseUrl}/w/index.php?title=Special:OAuth`,
"cradle_url": `${cradleBaseUrl}/`,
"cradle_api": `${cradleBaseUrl}/api.php`,
"vue_components_base_url": `${cradleBaseUrl}/resources/vue/`
} ;
15 changes: 15 additions & 0 deletions public_html/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ function get_config() {
'cradle_api' => "https://${s}/tools/cradle/api.php",
'vue_components_base_url' => "https://${s}/tools/cradle/resources/vue/",
];
$wikibaseBaseUrl = getenv('CRADLE_WIKIBASE_BASE_URL');
if ( $wikibaseBaseUrl !== false && $wikibaseBaseUrl !== '' ) {
$wikibaseBaseUrl = rtrim( $wikibaseBaseUrl, '/' );
$j['wikibase_url'] = "${wikibaseBaseUrl}/wiki/";
$j['api'] = "${wikibaseBaseUrl}/w/api.php";
$j['wikibase_api'] = "${wikibaseBaseUrl}/w/api.php";
$j['oauth_url'] = "${wikibaseBaseUrl}/w/index.php?title=Special:OAuth";
}
$cradleBaseUrl = getenv('CRADLE_BASE_URL');
if ( $cradleBaseUrl !== false && $cradleBaseUrl !== '' ) {
$cradleBaseUrl = rtrim( $cradleBaseUrl, '/' );
$j['cradle_url'] = "${cradleBaseUrl}/";
$j['cradle_api'] = "${cradleBaseUrl}/api.php";
$j['vue_components_base_url'] = "${cradleBaseUrl}/resources/vue/";
}
$j = json_decode( json_encode( $j ) );// Convert to object
return $j ;
}
Expand Down
Loading