-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attempt building debian, jar, and rpm packages using Dockerfiles #46
Changes from all commits
693cce9
02127cf
29d6d73
294ddbb
6cac1cd
2c087d6
bba357b
16a33be
2fc1b8e
c17b8ca
615cd81
d11a122
ebf37c9
18f0df2
f03f1cb
398101e
1c0406b
0d8f7c5
7c026bf
6312bda
e571a21
dc77d4c
e27ddb3
0ffaa7c
ab6b1fc
9c057d9
3d37f35
7e75c56
4ebf674
57c1030
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# editor files | ||
*.iml | ||
*~ | ||
.idea/ | ||
.DS_Store | ||
|
||
# docker files | ||
docker/production-reaper/*.jar | ||
docker/production-reaper/*.yaml | ||
docker-compose.yml | ||
|
||
# build paths | ||
packages/ | ||
target/ | ||
*.deb | ||
*.jar | ||
*.rpm |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,7 @@ bin/ | |
.settings/ | ||
.project | ||
build/ | ||
docker/production-reaper/*.yaml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed. Other lines are implemented in #134 . |
||
*.deb | ||
*.jar | ||
*.rpm |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
# 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 '\['` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implemented in #134 . |
||
|
||
# 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: | ||
# needs to once at least once to pre-download dependencies | ||
echo $(VERSION) | ||
|
||
mkdir -p build/usr/share/cassandra-reaper | ||
mkdir -p build/usr/local/bin | ||
mkdir -p build/etc/init.d | ||
|
@@ -26,7 +29,7 @@ rpm: prepare | |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ The current version supports running Apache Cassandra cluster repairs in a segme | |
opportunistically running multiple parallel repairs at the same time on different nodes | ||
within the cluster. Basic repair scheduling functionality is also supported. | ||
|
||
Reaper comes with a GUI, which if you're running in local mode can be at http://localhost:8080/webui/ | ||
Reaper comes with a GUI, which if you're running in local mode can be at http://localhost:8080/webui/index.html | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug has already been fixed. |
||
|
||
Please see the [Issues](https://github.com/thelastpickle/cassandra-reaper/issues) section for more | ||
information on planned development, and known issues. | ||
|
@@ -63,8 +63,8 @@ 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` | ||
Notice that you can also build Debian and RPM package from this project by using *Make*, for example: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implemented in #134 . |
||
`make all`. | ||
|
||
|
||
Configuration | ||
|
@@ -346,6 +346,20 @@ 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/index.html` | ||
|
||
Reaper can also be accessed using the REST API exposed on port 8080, or using the command line tool `bin/spreaper` | ||
|
||
|
||
Docker Support | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No longer relevant. |
||
-------------- | ||
|
||
Docker support and documentation has been added to [./docker](./docker). The | ||
README.md within that directory includes instructions for: | ||
|
||
* Building Debian, RPM, and jar packages using Docker. | ||
* Running an In-Memory Reaper deployment. | ||
* Running a Cassandra-backed Reaper deployment. | ||
* With a containerized Cassandra. | ||
* With a Cassandra cluster located at a different IP address. | ||
* Building a production-ready Docker container. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
version: "2.1" | ||
|
||
services: | ||
reaper-in-memory: | ||
build: | ||
context: . | ||
dockerfile: docker/reaper/Dockerfile | ||
command: java -jar cassandra-reaper-0.4.0-SNAPSHOT.jar server cassandra-reaper/resource/cassandra-reaper-memory.yaml | ||
ports: | ||
# web ui port | ||
- "8080:8080" | ||
# admin ui port | ||
- "8081:8081" | ||
|
||
reaper-setup: | ||
build: | ||
context: . | ||
dockerfile: docker/reaper-setup/Dockerfile | ||
command: cassandra | ||
links: | ||
- cassandra:cassandra | ||
|
||
reaper: | ||
build: | ||
context: . | ||
dockerfile: docker/reaper/Dockerfile | ||
command: cassandra | ||
links: | ||
- cassandra:cassandra | ||
ports: | ||
# web ui port | ||
- "8080:8080" | ||
# admin ui port | ||
- "8081:8081" | ||
restart: always | ||
|
||
cassandra: | ||
image: cassandra:3.0.10 | ||
env_file: | ||
- docker/cassandra.env | ||
|
||
# disable swap: | ||
# https://github.com/docker/docker/issues/18894#issuecomment-167177866 | ||
# https://github.com/docker/compose/pull/3542 | ||
mem_limit: 4g | ||
memswap_limit: 4g | ||
mem_swappiness: 0 | ||
|
||
# expose these ports to any container with a link to `cassandra` | ||
ports: | ||
# intra-node communication | ||
- "7000:7000" | ||
# TLS intra-node communication | ||
- "7001:7001" | ||
# JMX | ||
- "7199:7199" | ||
# CQL | ||
- "9042:9042" | ||
|
||
# required in production environments: | ||
# volumes: | ||
# - ./data/cassandra_reaper:/var/lib/cassandra |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
Docker Support and Infrastructure for Reaper | ||
============================================ | ||
|
||
The following software is required: | ||
|
||
* [Docker](https://docs.docker.com/engine/installation/) | ||
* [Docker Compose](https://docs.docker.com/compose/install/) | ||
|
||
**Note**: The following commands are all assumed to be run from the root | ||
repository directory. | ||
|
||
|
||
Building Reaper Packages Using Docker | ||
------------------------------------- | ||
|
||
This command installs all dependencies needed to build the Debian, jar, | ||
and RPM packages: | ||
|
||
docker build --tag reaper-build-packages --file docker/build-packages/Dockerfile . | ||
|
||
This command builds the packages into the host machine's `./packages` directory: | ||
|
||
docker run -ti -v `pwd`/packages:/usr/src/app/packages reaper-build-packages | ||
|
||
|
||
Running In-Memory Reaper Using Docker Compose | ||
--------------------------------------------- | ||
|
||
These commands will build the jar file into the `./packages` directory: | ||
|
||
docker build --tag reaper-build-packages --file docker/build-packages/Dockerfile . | ||
docker run -ti -v `pwd`/packages:/usr/src/app/packages reaper-build-packages | ||
|
||
This command will build the service images using the previously built jar file: | ||
|
||
docker-compose build | ||
|
||
This command will run Reaper in in-memory mode: | ||
|
||
docker-compose up reaper-in-memory | ||
|
||
The following URLs become available: | ||
|
||
* Main Interface: [http://localhost:8080/webui/index.html](http://localhost:8080/webui/index.html) | ||
* Operational Interface: [http://localhost:8081](http://localhost:8081) | ||
|
||
|
||
Running Cassandra-backed Reaper using Docker Compose | ||
---------------------------------------------------- | ||
|
||
After having built the images as described in the | ||
`Running In-Memory Reaper Using Docker Compose` section, ensure there are no | ||
running containers by using: | ||
|
||
docker-compose down | ||
|
||
Then, ensure there exists a running Cassandra container. This can be confirmed | ||
once `Starting listening for CQL clients` appears in the log output: | ||
|
||
docker-compose up cassandra | ||
|
||
If not already initialized, make sure the Cassandra cluster has the correct | ||
schema: | ||
|
||
docker-compose run reaper-setup | ||
|
||
Once Cassandra's schema has been initialized, run Reaper: | ||
|
||
docker-compose up reaper | ||
|
||
The following URLs become available: | ||
|
||
* Main Interface: [http://localhost:8080/webui/index.html](http://localhost:8080/webui/index.html) | ||
* Operational Interface: [http://localhost:8081](http://localhost:8081) | ||
|
||
**Note**: Although Reaper will be using a Cassandra backend, the Dockerized | ||
Cassandra container will be running with JMX accessible *only* from localhost. | ||
Therefore, another Cassandra cluster with proper JMX settings will need to | ||
be created in order for Reaper to monitor a cluster. | ||
|
||
In order for JMX authentication to be set up correctly, the following settings | ||
must be in effect on the Cassandra-side: | ||
|
||
* cassandra.yaml | ||
* `seeds`: must be set to the host's private IP address. | ||
* `listen_address`: must be set to the host's private IP address. | ||
* `rpc_address`: must be set to the host's private IP address. | ||
* cassandra-env.sh | ||
* `LOCAL_JMX` must resolve to something other than "yes". | ||
* /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/management/jmxremote.access | ||
* Should include a line in the format of: `<user> readwrite`. | ||
* /etc/cassandra/jmxremote.password | ||
* Should include a line in the format of: `<user> <password>`. | ||
* Have `600` file permissions. | ||
* Be owned by the `cassandra` user and group. | ||
|
||
|
||
|
||
Running Cassandra-backed Reaper using Docker Compose and External Cassandra Cluster | ||
----------------------------------------------------------------------------------- | ||
|
||
If you wish to use an existing Cassandra backend on a separate machine, instead | ||
of the provided containerized Cassandra, the directions are the same as the | ||
above sections with a few differences: | ||
|
||
* Update `./docker-compose.yml`'s `reaper` and `reaper-setup` services to use | ||
`command`s that match an existing Cassandra node's IP address. | ||
* Initialize the schema using: `docker-compose run reaper-setup`. | ||
* Run Reaper using: `docker-compose up reaper`. | ||
|
||
**Note**: Because Docker networking can use different settings and use of the | ||
correct JMX settings are required for this sort of setup, using a Cassandra cluster not | ||
located at `127.0.0.1`, or `localhost`, is ideal. | ||
|
||
|
||
Shutting Down Docker Compose Containers | ||
--------------------------------------- | ||
|
||
To shut everything down all containers that were started using `docker-compose` | ||
command, run: | ||
|
||
docker-compose down | ||
|
||
|
||
Using a Docker Container in Production | ||
-------------------------------------- | ||
|
||
To facilitate production environments where Docker is heavily in use, we've | ||
provided a Dockerfile example for building an ideal production image. That file | ||
and README can be found in [./production-reaper](./production-reaper). | ||
|
||
There is a [ticket](https://github.com/thelastpickle/cassandra-reaper/issues/51) | ||
to deploy new Docker images to Docker Hub on each release. Once this ticket has | ||
been closed, the instructions should stay the same while the Dockerfile is | ||
simpler and pre-built using Docker Hub's automated build system. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
FROM ubuntu:16.04 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implemented in #134 . |
||
|
||
# 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} | ||
|
||
# grab source | ||
COPY . ${WORKDIR}/cassandra-reaper | ||
WORKDIR ${WORKDIR}/cassandra-reaper | ||
|
||
# target directory for final build | ||
RUN mkdir ${WORKDIR}/packages | ||
VOLUME ${WORKDIR}/packages | ||
|
||
# Add entrypoint script | ||
COPY docker/build-packages/docker-entrypoint.sh ${WORKDIR} | ||
ENTRYPOINT ["/usr/src/app/docker-entrypoint.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implemented in #134 . |
||
|
||
set -x | ||
|
||
# build jar | ||
# build web UI | ||
# build Debian and RPM packages | ||
# copy built packages into a mounted volume | ||
mvn clean package -Pbuild-ui \ | ||
&& make all \ | ||
&& cp *.deb *.rpm target/*.jar ${WORKDIR}/packages | ||
|
||
# cd into the directory that contains the built packages | ||
cd ${WORKDIR}/packages | ||
|
||
# execute any provided command | ||
$@ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
# leave blank to auto configure | ||
CASSANDRA_LISTEN_ADDRESS | ||
CASSANDRA_BROADCAST_ADDRESS | ||
CASSANDRA_RPC_ADDRESS | ||
|
||
# name of this Cassandra cluster | ||
CASSANDRA_CLUSTER_NAME='reaper' | ||
|
||
# leave as is, or manually configure | ||
CASSANDRA_SEEDS | ||
CASSANDRA_NUM_TOKENS=32 | ||
|
||
# snitch information | ||
CASSANDRA_DC=us-east-1 | ||
CASSANDRA_RACK=rack1 | ||
CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM ubuntu:16.04 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deprecated for #76. |
||
|
||
# use a common app path, copied from python-onbuild:latest | ||
ENV WORKDIR /usr/src/app | ||
RUN mkdir -p ${WORKDIR} | ||
WORKDIR ${WORKDIR} | ||
|
||
# install Java | ||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
openjdk-8-jdk | ||
|
||
# grab jar and configuration from the build directory | ||
COPY ./*.jar ${WORKDIR}/ | ||
COPY cassandra-reaper*.yaml ${WORKDIR}/ | ||
|
||
# start the reaper process | ||
CMD java -jar cassandra-reaper*.jar server cassandra-reaper*.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skip this file.
Not needed in #134 .