From cccae695a477a89e61ac38350d221ce9d76bdb47 Mon Sep 17 00:00:00 2001 From: maxlath Date: Thu, 16 Jul 2020 16:35:42 +0200 Subject: [PATCH] Adds docker-oxigraph --- README.md | 4 ++ docker/Dockerfile | 13 +++++++ docker/README.md | 65 +++++++++++++++++++++++++++++++++ docker/publish_docker_images.sh | 11 ++++++ 4 files changed, 93 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/README.md create mode 100755 docker/publish_docker_images.sh diff --git a/README.md b/README.md index 05170a3e..c0a62bfc 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ You need to have [a recent stable version of Rust and Cargo installed](https://w If it's done, executing `cargo build --release` in the root directory of this repository should compile the full server after having downloaded its dependencies. It will create a fat binary in `target/release/oxigraph_server`. +Alternatively, you can use the [Docker image](./docker#readme). + ### Usage Run `./oxigraph_server` to start the server. It listen by default on `localhost:7878`. @@ -60,6 +62,8 @@ You need to have [a recent stable version of Rust and Cargo installed](https://w If it's done, executing `cargo build --release` in the root directory of this repository should compile the full server after having downloaded its dependencies. It will create a fat binary in `target/release/oxigraph_wikibase`. +Alternatively, you can use the [Docker image](./docker#readme). + ### Usage To start a server that is synchronized with [test.wikidata.org](https://test.wikidata.org) you should run: diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..bddbec47 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,13 @@ +FROM rust:1.44 as builder + +RUN apt-get update && \ + apt-get install clang -y && \ + git clone https://github.com/oxigraph/oxigraph --depth 1 && \ + cd oxigraph && \ + cargo build --release + +FROM debian:buster-slim + +COPY --from=builder /oxigraph/target/release/oxigraph_server /usr/local/bin/oxigraph_server + +ENTRYPOINT [ "/usr/local/bin/oxigraph_server" ] diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000..423513b2 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,65 @@ +# docker-oxigraph + +[Oxigraph](https://github.com/oxigraph/oxigraph) in a [Docker container](https://www.docker.com/resources/what-container). + +[![DockerHub Badge Oxigraph](https://dockeri.co/image/oxigraph/oxigraph)](https://hub.docker.com/r/oxigraph/oxigraph/) +[![DockerHub Badge Oxigraph-Wikibase](https://dockeri.co/image/oxigraph/oxigraph-wikibase)](https://hub.docker.com/r/oxigraph/oxigraph-wikibase/) + + +## Summary + + + + + +- [Display help menu](#display-help-menu) +- [Run the web server](#run-the-web-server) +- [Run the web server for Wikibase](#run-the-web-server-for-wikibase) +- [Build local image](#build-local-image) + - [server image](#server-image) + - [Wikibase server image](#wikibase-server-image) + + + +## Display the help menu +```sh +docker run --rm oxigraph/oxigraph --help +``` + +## Run the web server +Expose the server on port `7878` of the host machine, and save data on the local `./data` folder +```sh +docker run --init --rm -v $PWD/data:/data -p 7878:7878 oxigraph/oxigraph -b 0.0.0.0:7878 -f /data +``` + +You can then access it from your machine on port `7878`: +```sh +# Open the GUI in a browser +firefox http://localhost:7878 + +# Post some data +curl http://localhost:7878 -H 'Content-Type: application/x-turtle' -d@./data.ttl + +# Make a query +curl -H 'Accept: application/sparql-results+json' 'http://localhost:7878/query?query=SELECT%20*%20%7B%20%3Fs%20%3Fp%20%3Fo%20%7D%20LIMIT%2010' +``` + +## Run the web server for Wikibase +```sh +docker run --init --rm -v $PWD/wikibase_data:/wikibase_data -p 7878:7878 oxigraph/oxigraph-wikibase -b 0.0.0.0:7878 -f /wikibase_data --mediawiki-api http://some.wikibase.instance/w/api.php --mediawiki-base-url http://some.wikibase.instance/wiki/ +``` + +:warning: the Wikibase instance needs to be accessible from within the container. The clean way to do that could be to have both your wikibase and oxigraph in the same [`docker-compose.yml`](https://docs.docker.com/compose/). + +## Build local image + +### server image +```sh +# Build with no build context, just the Dockerfile +cat Dockerfile | docker build -t oxigraph - +``` +### Wikibase server image +```sh +# Same, simply replacing the entrypoint +cat Dockerfile | sed s/oxigraph_server/oxigraph_wikibase/ | docker build -t oxigraph-wikibase - +``` diff --git a/docker/publish_docker_images.sh b/docker/publish_docker_images.sh new file mode 100755 index 00000000..00dcb208 --- /dev/null +++ b/docker/publish_docker_images.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +if [[ -z ./Dockerfile ]] ; then + echo 'this script should be run the docker directory' + exit 1 +fi + +cat Dockerfile | docker build -t oxigraph/oxigraph - +cat Dockerfile | sed s/oxigraph_server/oxigraph_wikibase/g | docker build -t oxigraph/oxigraph-wikibase - + +docker push oxigraph/oxigraph:latest +docker push oxigraph/oxigraph-wikibase:latest