Skip to content

Commit

Permalink
build a docker image for this repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
w32zhong committed Dec 30, 2020
1 parent 7656fe3 commit e9e3bf0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM maven:3-jdk-6
# build arguments
ARG ANT=./src/apache-ant-1.8.4
ARG LUCENE=./src/lucene-solr
# move source code into container
ADD $ANT /code/ant
ADD $LUCENE /code/lucene
# setup build environment
ENV JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-amd64
ENV ANT_HOME=/code/ant
ENV PATH=$PATH:$ANT_HOME/bin
ENV CLASSPATH=/code/class
# initial source code build
WORKDIR /code/lucene
ADD build.sh /bin
RUN build.sh
CMD bash
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This repo shows how to successfully build and run Lucene versions from `v1.9` to later than `v3.4`.
The purpose of this repo is to let myself get hand dirty when learning Lucene source code.

### Setup (use `v1.9` as example)
### Setup (Use `v1.9` as Example)
1. Clone lucene-solr:
```sh
$ git clone https://gitee.com/t-k-/lucene-solr.git
Expand Down Expand Up @@ -43,3 +43,19 @@ Now, let's run the Lucene demo
$ java org.apache.lucene.demo.IndexFiles ./src/java/
$ java org.apache.lucene.demo.SearchFiles
```

### Build and Run on Docker
```sh
$ sudo docker build -t study-lucene .
$ sudo docker run -it study-lucene java org.apache.lucene.demo.SearchFiles
```

You may want to attach live source code and build in container:
```sh
$ sudo docker run -it -v `pwd`/src/lucene-solr:/code/lucene study-lucene bash
```

Index a large corpus from container?
```sh
$ sudo docker run -it -v /home/tk/nvme0n1/corpus:/corpus study-lucene java org.apache.lucene.demo.IndexFiles /corpus
```
12 changes: 12 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
TARGETS=${1-jar-core jar-demo}
set -xe

# java build (compile)
rm -rf build index
ant $TARGETS

# java build (install)
mkdir -p $CLASSPATH && rm -rf $CLASSPATH/*
cp build/*.jar $CLASSPATH
(cd $CLASSPATH && find -name '*.jar' -exec jar -xf {} \;)

0 comments on commit e9e3bf0

Please sign in to comment.