forked from wmde/wikibase-release-pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
240 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
FROM ubuntu:xenial as fetcher | ||
|
||
RUN apt-get update && \ | ||
apt-get install --yes --no-install-recommends git=1:2.* ca-certificates=201* && \ | ||
apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
||
COPY artifacts/quickstatements.tar.gz artifacts/quickstatements.tar.gz | ||
RUN tar xzf artifacts/quickstatements.tar.gz | ||
|
||
FROM composer:1 as composer | ||
|
||
COPY --from=fetcher /quickstatements /quickstatements | ||
|
||
WORKDIR /quickstatements | ||
RUN composer install --no-dev | ||
|
||
FROM php:7.2-apache | ||
|
||
# Install envsubst | ||
RUN apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends gettext-base=0.19.* jq=1.5* && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
COPY --from=composer /quickstatements /var/www/html/quickstatements | ||
COPY --from=fetcher /magnustools /var/www/html/magnustools | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
|
||
COPY config.json /templates/config.json | ||
COPY oauth.ini /templates/oauth.ini | ||
COPY php.ini /templates/php.ini | ||
|
||
ENV APACHE_DOCUMENT_ROOT /var/www/html/quickstatements/public_html | ||
RUN sed -ri -e "s!/var/www/html!${APACHE_DOCUMENT_ROOT}!g" /etc/apache2/sites-available/*.conf | ||
RUN sed -ri -e "s!/var/www/!${APACHE_DOCUMENT_ROOT}!g" /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf | ||
|
||
ENV MW_SITE_NAME=wikibase-docker\ | ||
MW_SITE_LANG=en\ | ||
PHP_TIMEZONE=UTC | ||
|
||
RUN install -d -owww-data /var/log/quickstatements | ||
|
||
ENTRYPOINT ["/bin/bash"] | ||
CMD ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Quickstatements docker image | ||
|
||
Quickstatements2 as seen at [https://github.com/magnusmanske/quickstatements](https://github.com/magnusmanske/quickstatements) | ||
|
||
### Environment variables | ||
|
||
Variable | Default | Description | ||
-------------------------- | -------- | ----------- | ||
`WIKIBASE_SCHEME_AND_HOST` | NONE | Host and port of wikibase instance as seen by QS container | ||
`WB_PUBLIC_HOST_AND_PORT` | NONE | Host and port of wikibase as seen by the user's browser | ||
`QS_PUBLIC_HOST_AND_PORT` | NONE | Host and port of QS as seen by the user's browser | ||
`OAUTH_CONSUMER_KEY` | NONE | OAuth consumer key (obtained from wikibase) | ||
`OAUTH_CONSUMER_SECRET` | NONE | OAuth consumer key (obtained from wikibase) | ||
`PHP_TIMEZONE` | UTC | setting of php.ini date.timezone | ||
|
||
### Filesystem layout | ||
|
||
Directory | Description | ||
--------------------------------- | ------------------------------------------------------------------------------ | ||
`/var/www/html/quickstatements` | Base quickstatements directory | ||
`/var/www/html/quickstatements/public_html` | The Apache Root folder | ||
`/var/www/html/magnustools` | Base magnustools directory | ||
|
||
File | Description | ||
------------------------- | ------------------------------------------------------------------------------ | ||
`/templates/config.json` | Template for Quickstatements' config.json (substituted to `/var/www/html/quickstatements/public_html/config.json` at runtime) | ||
`/templates/oauth.ini` | Template for Quickstatements' oauth.ini (substituted to `/var/www/html/quickstatements/oauth.ini` at runtime) | ||
`/templates/php.ini` | php config (default provided sets date.timezone to prevent php complaining substituted to `/usr/local/etc/php/conf.d/php.ini` at runtime) | ||
|
||
|
||
### How to setup and use | ||
|
||
#### Set up quickstatements | ||
In order for quickstatements to communicate with wikibase it needs to know where your instance is and how it can find it. | ||
This must be done by setting the ENV variable `WIKIBASE_SCHEME_AND_HOST`. n.b. This should reflect how this container when running | ||
sees the wikibase container. For example the docker container alias like wikibase.svc. | ||
|
||
The user's browser will also be redirected to the Wikibase instance and finally back to quickstatements. The address | ||
the user sees for the Wikibase may be different from how the running container sees it. For example: it may be running | ||
on localhost on a specific port. e.g. http://localhost:8181. This should be passed to the quickstatements container as | ||
WB_PUBLIC_HOST_AND_PORT | ||
|
||
One must also know how this container will be visible to the user as well so it can ask the wikibase to redirect the | ||
user back here. This should be passed as `QS_PUBLIC_HOST_AND_PORT` | ||
|
||
You can pass the consumer and secret token you got from the wikibase to this container as the environment variables | ||
`OAUTH_CONSUMER_KEY` and `OAUTH_CONSUMER_SECRET`. If you don't, docker-compose automatically handles this. | ||
|
||
You can now test it works by navigating to http://\<your quickstatements host\> and logging in using the button top right. | ||
|
||
You should be redirected to the wiki where you can authorize this Quickstatements to act on your behalf | ||
|
||
Finally you should be redirected back to Quickstatements and you should appear logged in. | ||
|
||
Use Quickstatements as normal with the Run button. Currently "Run in background" is not supported by this image. | ||
|
||
#### Troubleshooting | ||
If you see an error such as mw-oauth exception when trying to log in check that you have passed the right consumer token | ||
and secret token to quickstatements. | ||
|
||
If you have changed the value of $wgSecretKey $wgOAuthSecretKey since you made the consumer you'll need to make another new consumer or | ||
reissue the secret token for the old one. | ||
|
||
### Development | ||
|
||
These images are build from the master branch of the quickstatements and magnustools repos. | ||
|
||
For this reason the images may sometimes break due to upstream changes and need fixing. | ||
|
||
Additional images for new releases do not need to be created. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"site" : "${MW_SITE_NAME}" , | ||
"bot_config_file" : "/var/www/html/bot.ini" , | ||
"logfile" : "/var/log/quickstatements/tool.log" , | ||
"sites" : { | ||
"${MW_SITE_NAME}" : { | ||
"oauth" : { | ||
"language":"${MW_SITE_LANG}" , | ||
"project":"${MW_SITE_NAME}" , | ||
"ini_file":"/quickstatements/data/oauth.ini" , | ||
"publicMwOAuthUrl":"${WB_PUBLIC_SCHEME_HOST_AND_PORT}/w/index.php?title=Special:OAuth" , | ||
"mwOAuthUrl":"${WIKIBASE_SCHEME_AND_HOST}/w/index.php?title=Special:OAuth" , | ||
"mwOAuthIW":"mw" | ||
} , | ||
"server" : "${WB_PUBLIC_HOST_AND_PORT}" , | ||
"api" : "${WIKIBASE_SCHEME_AND_HOST}/w/api.php" , | ||
"pageBase" : "${WB_PUBLIC_SCHEME_HOST_AND_PORT}/wiki/" , | ||
"toolBase" : "${QS_PUBLIC_SCHEME_HOST_AND_PORT}/" , | ||
"types" : { | ||
"P" : { "type":"property" , "ns":"${WB_PROPERTY_NAMESPACE}" , "ns_prefix":"${WB_PROPERTY_PREFIX}" } , | ||
"Q" : { "type":"item" , "ns":"${WB_ITEM_NAMESPACE}" , "ns_prefix":"${WB_ITEM_PREFIX}" } | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Test if required environment variables have been set | ||
REQUIRED_VARIABLES=(QS_PUBLIC_SCHEME_HOST_AND_PORT WB_PUBLIC_SCHEME_HOST_AND_PORT WIKIBASE_SCHEME_AND_HOST WB_PROPERTY_NAMESPACE WB_PROPERTY_PREFIX WB_ITEM_NAMESPACE WB_ITEM_PREFIX) | ||
for i in "${REQUIRED_VARIABLES[@]}"; do | ||
if ! [[ -v "$i" ]]; then | ||
echo "$i is required but isn't set. You should pass it to docker. See: https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file"; | ||
exit 1; | ||
fi | ||
done | ||
|
||
if [[ -v "$OAUTH_CONSUMER_KEY" && "$OAUTH_CONSUMER_SECRET" ]]; then | ||
envsubst < /templates/oauth.ini > /quickstatements/data/oauth.ini; | ||
fi | ||
|
||
envsubst < /templates/config.json > /var/www/html/quickstatements/public_html/config.json | ||
envsubst < /templates/php.ini > /usr/local/etc/php/conf.d/php.ini | ||
|
||
docker-php-entrypoint apache2-foreground |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
; HTTP User-Agent header | ||
agent = 'Wikibase Docker QuickStatements' | ||
; assigned by Special:OAuthConsumerRegistration (request modelled after https://www.wikidata.org/wiki/Special:OAuthListConsumers/view/77b4ae5506dd7dbb0bb07f80e3ae3ca9) | ||
consumerKey = '${OAUTH_CONSUMER_KEY}' | ||
consumerSecret = '${OAUTH_CONSUMER_SECRET}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
date.timezone = "${PHP_TIMEZONE}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
ROOT="$(pwd)" | ||
TARBALL=quickstatements.tar.gz | ||
TARBALL_PATH="$ROOT/artifacts/$TARBALL" | ||
|
||
# clone and clean quickstatements | ||
TEMP_GIT_DIR=$(mktemp -d) | ||
QS_GIT_DIR="$TEMP_GIT_DIR/quickstatements" | ||
UPDATE_SUBMODULE=1 bash "$ROOT"/build/clone_repo.sh "$QUICKSTATEMENTS_COMMIT_HASH" "$ROOT/git_cache/services/quickstatements.git" quickstatements "$QS_GIT_DIR" master | ||
bash "$ROOT"/build/clean_repo.sh "$QS_GIT_DIR" | ||
|
||
# clone and clean magnustools | ||
MAGNUSTOOLS_GIT_DIR="$TEMP_GIT_DIR/magnustools" | ||
UPDATE_SUBMODULE=0 bash "$ROOT"/build/clone_repo.sh "$MAGNUSTOOLS_COMMIT_HASH" "$ROOT/git_cache/services/magnustools.git" magnustools "$MAGNUSTOOLS_GIT_DIR" master | ||
bash "$ROOT"/build/clean_repo.sh "$MAGNUSTOOLS_GIT_DIR" | ||
|
||
cd "$TEMP_GIT_DIR" | ||
GZIP=-9 tar -C "$TEMP_GIT_DIR" -zcvf "$TARBALL_PATH" magnustools quickstatements | ||
cd - | ||
|
||
if [ -n "$GITHUB_ENV" ]; then | ||
echo "TARBALL_PATH=$TARBALL_PATH" >> "$GITHUB_ENV" | ||
else | ||
export TARBALL_PATH | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
set -ex | ||
|
||
mkdir -p Docker/build/QuickStatements/artifacts | ||
cp "$TARBALL_PATH" Docker/build/QuickStatements/artifacts/ | ||
|
||
docker build --pull Docker/build/QuickStatements/ -t "$1" | ||
docker save "$1" | gzip -9f > artifacts/"$1".docker.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters