Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow configuration of wdqs frontend via deploy/config #829

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ deploy/log
deploy/.env
deploy/config/LocalSettings.php
deploy/config/wikibase-php.ini
deploy/config/wdqs-frontend-config.json

deploy-lts/config/wdqs-frontend-config.json

test/log
test/mwlog
Expand Down
21 changes: 11 additions & 10 deletions build/wdqs-frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ LABEL org.opencontainers.image.source="https://github.com/wmde/wikibase-release-
WORKDIR /usr/share/nginx/html

COPY --from=builder /tmp/wikidata-query-gui/build /usr/share/nginx/html
RUN echo "" > style.css
COPY frontend-config.json /usr/share/nginx/html/custom-config.json

COPY entrypoint.sh /entrypoint.sh
COPY custom-config.json /templates/custom-config.json
COPY default.conf /templates/default.conf

ENV LANGUAGE=en\
BRAND_TITLE=DockerWikibaseQueryService\
WIKIBASE_HOST="wikibase"\
WDQS_HOST="wdqs"\
WDQS_PORT="9999"\
COPYRIGHT_URL=undefined

COPY nginx-default.conf.template /templates/nginx-default.conf.template

RUN mkdir -p /config

ENV LANGUAGE=en \
WIKIBASE_HOST="wikibase" \
WDQS_HOST="wdqs" \
WDQS_PORT="9999"

ENTRYPOINT ["/entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]
12 changes: 10 additions & 2 deletions build/wdqs-frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ If QuickStatements and Wikibase are running on the same IP address, a reverse pr
| Variable | Default | Description |
| --------------- | ---------------------------- | ---------------------------------------- |
| `LANGUAGE` | "en" | Language to use in the UI |
| `BRAND_TITLE` | "DockerWikibaseQueryService" | Name to display on the UI |
| `WIKIBASE_HOST` | "wikibase" | Hostname of the Wikibase host (required) |
| `WDQS_HOST` | "wdqs" | Hostname of the WDQS host |
| `WDQS_PORT` | "9999" | Port of the WDQS host |
| `COPYRIGHT_URL` | "undefined" | URL for the copyright notice |

## Example

Expand Down Expand Up @@ -206,6 +204,16 @@ We provide several tags that relate to the versioning semantics.
| _MAJOR_._MINOR_._PATCH_ | 3.1.7 | Tags the latest image with this major, minor and patch version. Gets overwritten whenever a new version is released with this major, minor and patch version. This only happens for new builds triggered by base image changes. |
| _MAJOR_._MINOR_._PATCH_\_build*BUILD-TIMESTAMP* | 3.1.7_build20240530103941 | Tag that never gets overwritten. Every image will have this tag with a unique build timestamp. Can be used to reference images explicitly for reproducibility. |

## Internal filesystem layout

Hooking into the internal filesystem can extend the functionality of this image.

| File | Description |
| -------------------------------------------- | ------------------------------------------ |
| `/config/wdqs-frontend-config.json` | Configuration file for the WDQS frontend. |
| `/templates/nginx-default.conf.template` | Nginx config template. |


## Source

This image is built from this [Dockerfile](https://github.com/wmde/wikibase-release-pipeline/blob/main/build/wdqs-frontend/Dockerfile).
Expand Down
12 changes: 10 additions & 2 deletions build/wdqs-frontend/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@ fi

set -eu

# Take config from user config dir if present
if [ -e "/config/wdqs-frontend-config.json" ]; then
cp /config/wdqs-frontend-config.json /usr/share/nginx/html/custom-config.json

# Otherwise, make our stock config visible to the user for customization
else
cp /usr/share/nginx/html/custom-config.json /config/wdqs-frontend-config.json
fi

export DOLLAR='$'
envsubst < /templates/custom-config.json > /usr/share/nginx/html/custom-config.json
envsubst < /templates/default.conf > /etc/nginx/conf.d/default.conf
envsubst < /templates/nginx-default.conf.template > /etc/nginx/conf.d/default.conf

exec "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
}
},
"brand": {
"title": "$BRAND_TITLE",
"title": "WBS Query Service",
"logo": "logo.svg",
"favicon": "favicon.ico",
"copyrightUrl": "$COPYRIGHT_URL",
"copyrightUrl": "",
"index": "./index.html"
}
}
4 changes: 3 additions & 1 deletion deploy-lts/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,12 @@ services:
restart: unless-stopped

wdqs-frontend:
image: wikibase/wdqs-frontend:1
image: wikibase/wdqs-frontend:2
depends_on:
- wdqs-proxy
restart: unless-stopped
volumes:
- ./config:/config
labels:
- "traefik.enable=true"
- "traefik.http.routers.wdqs-frontend.rule=Host(`${WDQS_FRONTEND_PUBLIC_HOST}`)"
Expand Down
4 changes: 3 additions & 1 deletion deploy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,12 @@ services:
restart: unless-stopped

wdqs-frontend:
image: wikibase/wdqs-frontend:1
image: wikibase/wdqs-frontend:2
depends_on:
- wdqs-proxy
restart: unless-stopped
volumes:
- ./config:/config
labels:
- "traefik.enable=true"
- "traefik.http.routers.wdqs-frontend.rule=Host(`${WDQS_FRONTEND_PUBLIC_HOST}`)"
Expand Down
Loading