├── .gitignore ├── conf ├── settings.xml └── tomcat-users.xml ├── Dockerfile.index ├── Dockerfile.server ├── Makefile ├── launch.sh ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *swp 2 | 3 | -------------------------------------------------------------------------------- /conf/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | CliffTomcatServer 4 | cliff 5 | beer 6 | 7 | -------------------------------------------------------------------------------- /Dockerfile.index: -------------------------------------------------------------------------------- 1 | FROM maven:3.5.3-jdk-7 2 | 3 | RUN git clone https://github.com/Berico-Technologies/CLAVIN.git && \ 4 | cd CLAVIN && \ 5 | wget http://download.geonames.org/export/dump/allCountries.zip && \ 6 | unzip allCountries.zip && \ 7 | mvn compile && \ 8 | MAVEN_OPTS="-Xmx4g" mvn exec:java -Dexec.mainClass="com.bericotech.clavin.index.IndexDirectoryBuilder" 9 | 10 | CMD ["/bin/bash"] 11 | -------------------------------------------------------------------------------- /Dockerfile.server: -------------------------------------------------------------------------------- 1 | FROM tomcat:7.0 2 | 3 | ARG CLIFF_VERSION=2.3.0 4 | 5 | RUN sed -i "s/httpredir.debian.org/`curl -s -D - http://httpredir.debian.org/demo/debian/ | awk '/^Link:/ { print $2 }' | sed -e 's@;@\1@g'`/" /etc/apt/sources.list && \ 6 | apt-get clean && apt-get update && \ 7 | apt-get install -y git openjdk-7-jdk openjdk-7-doc openjdk-7-jre-lib maven 8 | 9 | RUN wget https://github.com/mitmedialab/CLIFF/releases/download/v$CLIFF_VERSION/CLIFF-$CLIFF_VERSION.war -O /usr/local/tomcat/webapps/CLIFF-$CLIFF_VERSION.war 10 | 11 | COPY conf/tomcat-users.xml ./conf/tomcat-users.xml 12 | COPY conf/settings.xml ./conf/settings.xml 13 | 14 | EXPOSE 8080 15 | 16 | VOLUME /etc/cliff2/IndexDirectory 17 | 18 | CMD $CATALINA_HOME/bin/catalina.sh run 19 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | HOST_INDEX_LOCATION := /etc/cliff2/IndexDirectory 2 | CLIFF_VERSION := 2.3.0 3 | CLIFF_PORT := 8080 4 | 5 | .PHONY: default 6 | default: description 7 | 8 | description: 9 | @echo "Available commands:" 10 | @echo " * buildindex" 11 | @echo " * buildserver" 12 | @echo " * run" 13 | 14 | .PHONY: buildindex 15 | buildindex: 16 | docker build -t cliff_index -f ./Dockerfile.index . 17 | docker run -t cliff_index /bin/true 18 | docker cp `docker ps -q -n=1`:/CLAVIN/IndexDirectory $(HOST_INDEX_LOCATION) 19 | 20 | .PHONY: buildserver 21 | buildserver: 22 | docker build --build-arg CLIFF_VERSION=$(CLIFF_VERSION) -t cliff:$(CLIFF_VERSION) -f ./Dockerfile.server . 23 | 24 | .PHONY: run 25 | run: 26 | docker run -d -p $(CLIFF_PORT):8080 -v $(HOST_INDEX_LOCATION):/etc/cliff2/IndexDirectory cliff:$(CLIFF_VERSION) 27 | -------------------------------------------------------------------------------- /launch.sh: -------------------------------------------------------------------------------- 1 | cd conf; rm tomcat-users.xml; wget https://raw.githubusercontent.com/ahalterman/CLIFF-up/master/tomcat-users.xml 2 | $CATALINA_HOME/bin/startup.sh 3 | 4 | cd; wget https://github.com/c4fcm/CLIFF/releases/download/v2.1.1/CLIFF-2.1.1.war 5 | mv CLIFF-2.1.1.war /usr/local/tomcat/webapps/ 6 | 7 | apt-get install -y git openjdk-7-jdk openjdk-7-doc openjdk-7-jre-lib maven 8 | cd; git clone https://github.com/Berico-Technologies/CLAVIN.git 9 | cd CLAVIN; wget http://download.geonames.org/export/dump/allCountries.zip; 10 | / unzip allCountries.zip; rm allCountries.zip 11 | mvn compile 12 | MAVEN_OPTS="-Xmx4g" mvn exec:java -Dexec.mainClass="com.bericotech.clavin.index.IndexDirectoryBuilder" 13 | 14 | 15 | mkdir /etc/cliff2 16 | echo "\n\n" 17 | echo "THIS IS THE SPOT WHERE THE INDEX DIR GETS COPIED" 18 | echo "\n\n" 19 | cp -r IndexDirectory /etc/cliff2/IndexDirectory 20 | 21 | cd; cd .m2 22 | rm settings.xml; wget https://raw.githubusercontent.com/ahalterman/CLIFF-up/master/settings.xml 23 | 24 | $CATALINA_HOME/bin/shutdown.sh 25 | $CATALINA_HOME/bin/catalina.sh run 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 John Beieler 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cliff-docker 2 | 3 | A Docker image for the [CLIFF](http://cliff.mediameter.org/) geolocation software. 4 | 5 | Use 6 | --- 7 | 8 | **Note: CLAVIN, and by extension CLIFF, is very memory hungry due to the 9 | geonames index. To properly run, a minimum of 4GB of RAM is necessary. Any less 10 | and you'll experience errors.** 11 | 12 | This docker image uses a build and release workflow. The Lucene index is built 13 | using the `build_server` image. The index is then copied to the host and can be 14 | mounted as a volume to the actual CLIFF server container. 15 | 16 | Build the index with: 17 | ``` 18 | make buildindex 19 | ``` 20 | This step builds the index and copies it to the host using the 21 | `HOST_INDEX_LOCATION` variable. The default location is 22 | `/etc/cliff2/IndexDirectory`. 23 | 24 | Build the server with: 25 | ``` 26 | make buildserver 27 | ``` 28 | The CLIFF version is defined by `CLIFF_VERSION` and defaults to `2.3.0`. 29 | 30 | Run the server with: 31 | ``` 32 | make run 33 | ``` 34 | This command mounts the index from the host to a Docker volume and starts the 35 | container, running cliff on the port defined by `CLIFF_PORT`. The default is 36 | `8080`. 37 | 38 | The API endpoint for CLIFF is `/CLIFF-2.3.0/parse/text`. 39 | 40 | Acknowledgements 41 | ----------------- 42 | 43 | This pulls heavily from Andy Halterman's [CLIFF-up](https://github.com/ahalterman/CLIFF-up) 44 | Vagrant box. You can see his repo for more examples of how to make use of 45 | CLIFF. 46 | -------------------------------------------------------------------------------- /conf/tomcat-users.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 30 | 35 | 42 | --------------------------------------------------------------------------------