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

Dockerfile #75

Merged
merged 2 commits into from
Jul 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Dockerfile
index/*
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ set(LOG_LEVEL_TRACE 5)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DLOGLEVEL=${LOG_LEVEL_DEBUG}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DLOGLEVEL=${LOG_LEVEL_DEBUG}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DLOGLEVEL=${LOG_LEVEL_DEBUG}")
set(CMAKE_REQUIRED_FLAGS "-fsanitize=thread")

################################
# GTEST
Expand All @@ -70,7 +69,7 @@ include_directories(SYSTEM ${STXXL_INCLUDE_DIRS})

message(STATUS ---)
message(STATUS "CXX_FLAGS are : " ${CMAKE_CXX_FLAGS})
message(STATUS "CXX_FLAGS_RELEASE are : " ${CMAKE_CXX_FLAGS_DEBUG})
message(STATUS "CXX_FLAGS_RELEASE are : " ${CMAKE_CXX_FLAGS_RELEASE})
message(STATUS "CXX_FLAGS_DEBUG are : " ${CMAKE_CXX_FLAGS_DEBUG})
message(STATUS "IMPORTANT: Make sure you have selected the desired CMAKE_BUILD_TYPE")
message(STATUS ---)
Expand Down
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM ubuntu:18.04 as base
MAINTAINER Niklas Schnelle <schnelle@informatik.uni-freiburg.de>
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV LC_CTYPE C.UTF-8

FROM base as builder
RUN apt-get update && apt-get install -y build-essential cmake libsparsehash-dev
RUN mkdir -p /app/build
COPY . /app/
WORKDIR /app/build/
RUN cmake -DCMAKE_BUILD_TYPE=Release .. && make -j 10

FROM base as runtime
RUN mkdir /app /index /input
WORKDIR /app
ENV PATH=/app/:$PATH
COPY --from=builder /app/build/*Main /app/src/web/* /app/

EXPOSE 7001
VOLUME ["/input", "/index"]

ENV INDEX_PREFIX index
# Need the shell to get the INDEX_PREFIX envirionment variable
ENTRYPOINT ["/bin/sh", "-c", "ServerMain -i \"/index/${INDEX_PREFIX}\" -p 7001 \"$@\"", "--"]
CMD ["-t", "-a", "-l"]

# docker build -t qlever-<name> .
# # When running with user namespaces you may need to make the index folder accessible
# # to e.g. the "nobody" user
# chmod -R o+rw ./index
# # For an existing index copy it into the ./index folder and make sure to either name it
# # index.X or
# # set -e INDEX_PREFIX=prefix during docker run
# # To build an index run a bash inside the container as follows
# docker run -it --rm -v "<path_to_input>:/input" -v "$(pwd)/index:/index" qlever-<name> bash
# # Then inside that shell IndexBuilder is in the path and can be used like
# # described in the README.md with the files in /input
# # To run a server use
# docker run -d -p 9001:9001 -v "$(pwd)/index:/index" --name qlever-<name> qlever-<name>

111 changes: 86 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,43 +34,103 @@ Thus, old queries no longer work and need to be adjusted as described in this RE


# How to use
There are two ways to use QLever on Linux systems.

* Variant **a** is to use `docker` for building and running it *(recommended)*
* Variant **b** is to use QLever directly on the host

## 0. Requirements:
## Get the code
This requires `git` to be installed

a) Checkout this project:

git clone --recursive https://github.com/Buchhold/QLever.git

Don't forget `--recursive` so that submodules will be updated.
For old versions of git, that do not support this parameter, you can do:

git clone https://github.com/Buchhold/QLever.git
cd QLever
git submodule init
git submodule update

## Running QLever inside `docker`
### 0a. Requirements:
A 64 bit host system (32 bit systems can't deal with `mmap` on > 4 GB files or
allocate enough RAM for larger KBs)

* docker 17.05 or newer (needs multi-stage builds)

### 1a. Build the container

Inside the the repositories root folder run

docker build -t qlever-<name> .

where `<name>` is a name chosen by convention to match the dataset or variant
you're building for.

### 2a. Create or reuse an index

When running with user namespaces you may need to make the index folder accessible
to e.g. the "nobody" user

chmod -R o+rw ./index

For an existing index copy it into the ./index folder and make sure to either
name it so that all files start with `index` or set `-e INDEX_PREFIX=<prefix>`
during docker run where `<prefix>` is the part of the index file names before
the first `.`.

Make sure you use a 64bit Linux with:
To build a new index run a bash inside the container as follows

* git
* g++ 4.8 or higher
docker run -it --rm \
-v "<absolute_path_to_input>:/input" \
-v "$(pwd)/index:/index" --entrypoint "bash" qlever-<name>

Then inside the container follow the instructions for [creating an
index](#2-creating-an-index) where the path to the index inside the container
is now `/index`.
(*Note: you don't actually need `./` as the executables are in the
`$PATH`*)

### 3. Running the QLever container

To run a QLever container use the following command, replacing `<name>` with
the name chosen during `docker build`.

docker run -it -p 7001:7001 -v "$(pwd)/index:/index" --name qlever-<name> qlever-<name> <ServerMain args>

where `<ServerMain args>` are arguments (except for port and index prefix)
which are always included. If none are supplied `-t -a -l` is used. If you want
the container to run in the background and restart automatically replace `-it`
with `-d --restart=unless-stopped`

## Running QLever on a Linux host
### 0b. Requirements:

Make sure you use a 64 bit Linux with:

* g++ 5.x or higher
* CMake 2.8.4 or higher
* google-sparsehash
* libsparsehash-dev (google-sparsehash)
* python3 + python3-yaml (for End-to-End Tests)

Other compilers (and OS) are not supported, yet.
So far no major problems are known.
Support for more platforms would be a highly appreciated contribution.

You also have to have google sparsehash installed.
You also have to have google sparsehash installed. On Ubuntu 16.04 and newer
the `libsparsehash-dev` package works.

If this isn't the case on your system, run:

git clone https://github.com/sparsehash/sparsehash.git
cd sparsehash
./configure && make && sudo make install

## 1. Build:
### 1b. Build and run on the host:

a) Checkout this project:

git clone https://github.com/Buchhold/QLever.git --recursive

Don't forget --recursive so that submodules will be updated.
For old versions of git, that do not support this parameter, you can do:

git clone https://github.com/Buchhold/QLever.git
cd QLever
git submodule init
git submodule update


b) Go to a folder where you want to build the binaries. Usually this is done
Expand All @@ -87,7 +147,7 @@ d) Run ctest. All tests should pass:

ctest

### 1.1 Running End-to-End Tests
#### 1.1 Running End-to-End Tests

QLever includes a simple mechanism for testing the entire system from
from building an index to running queries in a single command.
Expand All @@ -112,15 +172,16 @@ If you want to skip creation of the index run

## 2. Creating an Index:

**IMPORTANT:
THERE HAS TO BE SUFFICIENT DISK SPACE UNDER THE PATH YOU CHOOSE FOR YOUR
INDEX**

IMPORTANT:
THERE HAS TO BE SUFFICIENT DISK SPACE UNDER THE PATH YOU CHOOSE FOR YOUR INDEX!
FOR NOW - ALL FILES HAVE TO BE UTF-8 ENCODED!
*ALL FILES HAVE TO BE UTF-8 ENCODED!*

You can use the files described and linked later in this document:
"How to obtain data to play around with"
You can use the files described and linked later in this document:
(How to obtain data to play around with)[#how-to-obtain-data-to-play-around-with]

a) from an NTriples file (currently no blank nodes allowed):
a) from an NTriples file:

Note that the string passed to -i is the base name of various index files produced.

Expand Down
2 changes: 2 additions & 0 deletions index/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore