diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..80bae15 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,94 @@ +FROM ubuntu:trusty + +#Adapted from https://github.com/18F/docker-elasticsearch + +# To run: +# $: docker build -t esfbopen . + +# docker run -p 9200:9200 -p 9300:9300 esfbopen \ + # && --rm \ + # && --name es-test \ + # && -v /home/fbopen:/data + +# To ssh into docker cont. -> +# $: docker exec -i -t bash + +MAINTAINER Colin Craig + +RUN \ + apt-get update \ + -qq \ + && apt-get install \ + -qq \ + --yes \ + --no-install-recommends \ + --no-install-suggests \ + curl \ + python-software-properties \ + software-properties-common \ + +# Clean up packages. + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + + +# Add Java. +RUN \ + echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections \ + && add-apt-repository -y ppa:webupd8team/java \ + && apt-get update \ + -qq \ + && apt-get install \ + -qq \ + -y oracle-java7-installer=7u80+7u60arm-0~webupd8~1 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /var/cache/oracle-jdk7-installer + +# Define commonly used JAVA_HOME variable +ENV JAVA_HOME /usr/lib/jvm/java-7-oracle + +# Install Elasticsearch. +ENV ES_PKG_NAME elasticsearch-1.7.1 +RUN \ + cd / \ + && wget https://download.elasticsearch.org/elasticsearch/elasticsearch/${ES_PKG_NAME}.tar.gz \ + --no-verbose \ + && tar xvzf $ES_PKG_NAME.tar.gz \ + && rm -f $ES_PKG_NAME.tar.gz \ + && mv /$ES_PKG_NAME /elasticsearch + +# Set up default config. +ADD elasticsearch/elasticsearch__dev.yml /elasticsearch/elasticsearch.yml + +# mapper-attachments plugin. +ENV MA_VERSION=2.7.0 +RUN /elasticsearch/bin/plugin \ + install elasticsearch/elasticsearch-mapper-attachments/${MA_VERSION} \ + --silent + +# elasticsearch-cloud-aws plugin. +ENV CA_VERSION=2.7.0 +RUN /elasticsearch/bin/plugin install \ + elasticsearch/elasticsearch-cloud-aws/${CA_VERSION} \ + --silent + + +# Create the Elasticsearch user. +RUN groupadd -r elasticsearch \ + && useradd -r -g elasticsearch elasticsearch + +# Use a reasonable heap size. +# https://www.elastic.co/guide/en/elasticsearch/guide/current/heap-sizing.html +ENV ES_HEAP_SIZE=1g + +# Mount for persistent data. +VOLUME ["/data"] +WORKDIR /data + +# Expose Elasticsearch ports. +EXPOSE 9200 9300 + +# Entry commands. +#ENTRYPOINT ["/"] +CMD ["/elasticsearch/bin/elasticsearch"] diff --git a/README.md b/README.md index 3d52003..1dcd118 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,14 @@ To clean out any new files created from that script, as well as uninstall Elasti $ ./initial-dev-uninstall.sh ``` +### Quickstart (Requires Docker) (experimental) + +```sh +$ cd fbopen +$ ./fbo-docker-setup.sh +``` + + ### How to get started (manually) * Clone this repo. * This repo has an external dependency on another git repo, which needs to be populated at first, so `cd` to the repo and run: `git submodule update --init --recursive`. diff --git a/fbo-docker-setup.sh b/fbo-docker-setup.sh new file mode 100755 index 0000000..26c54e7 --- /dev/null +++ b/fbo-docker-setup.sh @@ -0,0 +1,71 @@ +# http://stackoverflow.com/a/3931779/94154 +command_exists () { + type "$1" &> /dev/null ; +} + +# Build our Docker ES image. +docker build -t es-fbopen . + +# Run Docker ES image. +# Run as Daemon, expose ports 9200:9300, sync /home/fbopen dir to /data +docker run -d -it -p 9200:9200 -p 9300:9300 -v /home/fbopen:/data esfbopen + +# Forward Docker containter ES ports to Host localhost 9200-9300 range. +VBoxManage controlvm $(docker-machine active) natpf1 "name,tcp,127.0.0.1,9200,,9300" + +# Do git stuff. +git submodule update --init --recursive +npm i -g mocha elasticdump json + +# API +#echo "Creating api/config.js from sample." +#cp api/config-sample_dev.js api/config.js +mkdir -p log/ +touch log/api.log + +# init index with mappings and settings on ES Image. +curl -XPUT -v $(docker-machine ip $(docker-machine active)):9200/fbopen0 --data-binary elasticsearch/init.json + +if command_exists node ; then + echo +else + echo "It looks like node.js is not installed. Please install it." + exit 1 +fi + +cd api +npm install +cd .. + +echo "Starting node API server" +osascript<