Skip to content
This repository has been archived by the owner on Dec 8, 2017. It is now read-only.

Dev docker setup #193

Open
wants to merge 5 commits into
base: cloud_foundry
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <containerid> bash

MAINTAINER Colin Craig <[email protected]>

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"]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
71 changes: 71 additions & 0 deletions fbo-docker-setup.sh
Original file line number Diff line number Diff line change
@@ -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<<EOF
tell application "System Events"
tell process "Terminal" to keystroke "t" using command down
end
tell application "Terminal"
activate
do script with command "(cd $FBOPEN_ROOT/api && node app.js)" in window 1
end tell
EOF

cp sample-www/config-sample_dev.js sample-www/config.js

echo "Starting sample-www server"
osascript<<EOF
tell application "System Events"
tell process "Terminal" to keystroke "t" using command down
end
tell application "Terminal"
activate
do script with command "(cd $FBOPEN_ROOT/sample-www && python -m SimpleHTTPServer)" in window 1
end tell
EOF

# Loaders
## bids.state.gov
#npm install loaders/bids.state.gov/
cd loaders/bids.state.gov
npm install
(cd ../common/ && npm install)
./bids-nightly.sh
cd ../..