Skip to content

Commit

Permalink
Merge branch 'master' into docker-compose-environment
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquincasares authored Jul 13, 2017
2 parents 129c2f9 + f648769 commit 01c939a
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ bin/
.settings/
.project
build/
packages/
*.deb
*.rpm

# frontend dev stuffs.
reaper_ui/bower_components/
Expand Down
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Using mvn:
VERSION := $(shell mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v '\[')
VERSION := `mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v '\['`

# Using python:
#VERSION := $(shell python -c "import xml.etree.ElementTree as ET; print(ET.parse(open('pom.xml')).getroot().find('{http://maven.apache.org/POM/4.0.0}version').text)")
# VERSION := `python -c "import xml.etree.ElementTree as ET; print(ET.parse(open('pom.xml')).getroot().find('{http://maven.apache.org/POM/4.0.0}version').text)"`

package:
mvn package

prepare:
echo "$(VERSION)..."
mkdir -p build/usr/share/cassandra-reaper
mkdir -p build/usr/local/bin
mkdir -p build/etc/init.d
Expand All @@ -19,14 +20,14 @@ prepare:
chmod 755 build/etc/init.d/cassandra-reaper

deb: prepare
rm -f reaper_*.deb
rm -f reaper*.deb
fpm -s dir -t deb -n reaper -v $(VERSION) --pre-install debian/preinstall.sh -C build .

rpm: prepare
rm -f reaper_*.rpm
rm -f reaper*.rpm
fpm -s dir -t rpm -n reaper -v $(VERSION) --pre-install debian/preinstall.sh -C build .

all: package deb
all: package deb rpm

clean:
rm -rf reaper_*.deb reaper_*.rpm
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,30 @@ use the provided CLI tool in *bin/spreaper* to call the service.

Run the tool with *-h* or *--help* option to see usage instructions.

Notice that you can also build a Debian package from this project by using *debuild*, for example:
`debuild -uc -us -b`
### Debian and RPM Packages

#### Make

Debian and RPM packages can be built from this project using Make, for example:

```bash
make all
```

#### Docker

A [Docker](https://docs.docker.com/engine/installation/) build environment is
also provided to build the entire project and can be run by using
[Docker Compose](https://docs.docker.com/compose/install/):

```bash
docker-compose -f docker-build/docker-compose.yml build \
&& docker-compose -f docker-build/docker-compose.yml run build
```

The final packages will be located within:

```./packages/```


Configuration
Expand Down Expand Up @@ -381,7 +403,7 @@ After modifying the `resource/cassandra-reaper.yaml` config file, Reaper can be
```java -jar target/cassandra-reaper-X.X.X.jar server resource/cassandra-reaper.yaml```
Once started, the UI can be accessed through : `http://127.0.0.1:8080/webui/`
Once started, the UI can be accessed through : http://127.0.0.1:8080/webui/
Reaper can also be accessed using the REST API exposed on port 8080, or using the command line tool `bin/spreaper`
Expand Down
37 changes: 37 additions & 0 deletions docker-build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM ubuntu:16.04

# use a common app path, copied from python-onbuild:latest
ENV WORKDIR /usr/src/app
RUN mkdir -p ${WORKDIR}
WORKDIR ${WORKDIR}

# install dependencies
RUN apt-get update \
&& apt-get install -y \
curl \
&& curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh \
&& bash nodesource_setup.sh \
&& apt-get update \
&& apt-get install -y \
build-essential \
git \
maven \
nodejs \
openjdk-8-jdk \
rpm \
ruby-dev \
&& mvn --version \
&& gem install fpm \
&& npm install -g bower

# cache maven dependencies, useful during Dockerfile testing
COPY pom.xml /tmp
COPY reaper_ui/*.json reaper_ui/*.js /tmp/reaper_ui/
WORKDIR /tmp
RUN mvn clean package \
&& mvn clean package -Pbuild-ui
WORKDIR ${WORKDIR}

# Add entrypoint script
COPY docker-build/docker-entrypoint.sh ${WORKDIR}
ENTRYPOINT ["/usr/src/app/docker-entrypoint.sh"]
10 changes: 10 additions & 0 deletions docker-build/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '2.1'

services:
build:
build:
context: ..
dockerfile: docker-build/Dockerfile
volumes:
- ..:/usr/src/app/cassandra-reaper
- ../packages:/usr/src/app/packages
16 changes: 16 additions & 0 deletions docker-build/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -ex

# build jar
# build web UI
# build Debian and RPM packages
# copy built packages into a mounted volume
cd ${WORKDIR}/cassandra-reaper
mvn clean package -Pbuild-ui \
&& make all \
&& mv *.deb *.rpm ${WORKDIR}/packages \
&& cp target/cassandra-*SNAPSHOT.jar ${WORKDIR}/packages

# execute any provided command
$@
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@
<executable>bower</executable>
<workingDirectory>reaper_ui</workingDirectory>
<arguments>
<argument>--allow-root</argument>
<argument>install</argument>
</arguments>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion reaper_ui/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
],
"devDependencies": {
"jquery": "~2.1.3",
"startbootstrap-sb-admin-2": "git://github.com/BlackrockDigital/startbootstrap-sb-admin-2#v1.0.5",
"startbootstrap-sb-admin-2": "https://github.com/BlackrockDigital/startbootstrap-sb-admin-2.git#v1.0.5",
"rxjs": "~2.4.6",
"moment": "~2.9.0"
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/spotify/reaper/core/Cluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Cluster {

public static String toSymbolicName(String s) {
assert s != null : "cannot turn null into symbolic name";
return s.toLowerCase().replaceAll("[^a-z0-9_]", "");
return s.toLowerCase().replaceAll("[^a-z0-9_\\-\\.]", "");
}

public Cluster(String name, String partitioner, Set<String> seedHosts) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class NodesStatus {
public final List<GossipInfo> endpointStates;
private static Pattern endpointNamePattern = Pattern.compile("^([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})", Pattern.MULTILINE);
private static Pattern endpointStatusPattern = Pattern.compile("(STATUS):([0-9]*):(\\w+)");
private static Pattern endpointDcPattern = Pattern.compile("(DC):([0-9]*):(\\w+)");
private static Pattern endpointRackPattern = Pattern.compile("(RACK):([0-9]*):(\\w+)");
private static Pattern endpointDcPattern = Pattern.compile("(DC):([0-9]*):([0-9a-zA-Z-\\.]+)");
private static Pattern endpointRackPattern = Pattern.compile("(RACK):([0-9]*):([0-9a-zA-Z-\\.]+)");
private static Pattern endpointLoadPattern = Pattern.compile("(LOAD):([0-9]*):([0-9eE.]+)");
private static Pattern endpointReleasePattern = Pattern.compile("(RELEASE_VERSION):([0-9]*):([0-9.]+)");
private static Pattern endpointSeverityPattern = Pattern.compile("(SEVERITY):([0-9]*):([0-9.]+)");
Expand Down

0 comments on commit 01c939a

Please sign in to comment.