-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Docker compose Xray example (#116)
* Add Docker compose Xray example (Issue #115)
- Loading branch information
Showing
18 changed files
with
251 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea | ||
*.iml | ||
.DS_Store | ||
temp |
File renamed without changes.
File renamed without changes.
File renamed without changes.
0
docker-compose/art-compose → docker-compose/artifactory/art-compose
100755 → 100644
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
XRAY_VERSION=2.3.2 | ||
RABBITMQ_VERSION=3.6.1-management | ||
POSTGRES_VERSION=9.5.2 | ||
MONGO_VERSION=3.2.6 | ||
|
||
XRAY_DOCKER_REPO=docker.bintray.io/jfrog | ||
XRAYDB_DOCKER_REPO=docker.bintray.io/jfrog | ||
|
||
XRAY_SERVER_PORT=8000 | ||
XRAY_MOUNT_ROOT=/data | ||
XRAY_DATA=/var/opt/jfrog/xray/data | ||
XRAY_USER_ID=1035 | ||
|
||
DOCKER_SERVER_HOSTNAME=xray | ||
DOCKER_SERVER_FQDN=xray.example.com | ||
|
||
DOCKER_COMPOSE_FLAGS= | ||
DOCKER_COMPOSE_XRAY_SERVER_FLAGS= | ||
DOCKER_COMPOSE_XRAY_INDEXER_FLAGS= | ||
DOCKER_COMPOSE_XRAY_ANALYSIS_FLAGS= | ||
DOCKER_COMPOSE_XRAY_PERSIST_FLAGS= | ||
|
||
RABBITMQ_ERLANG_COOKIE=xray-erlang-cookie | ||
|
||
POSTGRES_USER=xray | ||
POSTGRES_PASSWORD=xray | ||
POSTGRES_DB=xraydb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Xray Docker Compose Examples | ||
|
||
This directory provides some examples that show different ways to run Xray with Docker Compose. | ||
To learn more about Docker and how to set it up, please refer to the [Docker](https://docs.docker.com) and [Docker Compose](https://docs.docker.com/compose/overview/) documentation. | ||
|
||
Xray is available as different Docker images for: | ||
|
||
* [xray-server](https://bintray.com/jfrog/reg2/jfrog%3Axray-server) : Generating violations, hosting API / UI endpoints, running scheduled jobs | ||
* [xray-indexer](https://bintray.com/jfrog/reg2/jfrog%3Axray-indexer) : Responsible for the indexing process | ||
* [xray-analysis](https://bintray.com/jfrog/reg2/jfrog%3Axray-analysis) : Responsible for enriching component metadata | ||
* [xray-persist](https://bintray.com/jfrog/reg2/jfrog%3Axray-persist) : Matching the given components graph, completing component naming, storing the data in the relevant databases | ||
* [xray-rabbitmq](https://bintray.com/jfrog/reg2/jfrog%3Axray-rabbitmq) : Microservice Communication and Messaging | ||
* [xray-postgres](https://bintray.com/jfrog/reg2/jfrog%3Axray-postgres) : Components Graph Database | ||
* [xray-mongo](https://bintray.com/jfrog/reg2/jfrog%3Axray-mongo) : Components Metadata and Configuration | ||
|
||
These images are available for download from [JFrog Bintray](https://bintray.com/jfrog). | ||
|
||
## Docker-Compose Usage | ||
|
||
To run any of the examples, you should execute: | ||
|
||
```bash | ||
$ docker-compose -f <compose-file> <options> | ||
``` | ||
|
||
--- | ||
### Persistent Storage | ||
|
||
For persistent storage, all volumes are mounted from the host. | ||
|
||
All examples default to the host's **/data** directory via `.env` file | ||
|
||
> **IMPORTANT:** You should create the directories on the host before running `docker-compose`. | ||
- Xray data: **/data/xray** | ||
- RabbitMQ data: **/data/rabbitmq** | ||
- PostgreSQL data: **/data/postgres** | ||
- MongoDB data: **/data/mongodb** | ||
|
||
--- | ||
# Docker Compose Examples | ||
|
||
Below is a list of included examples. You are welcome to contribute. | ||
|
||
--- | ||
## Xray | ||
|
||
#### Run Xray with RabbitMQ, PostgreSQL and MongoDB | ||
|
||
Preparing all the needed files and directories on the host. | ||
|
||
```bash | ||
$ sudo ./prepareHostEnv.sh | ||
``` | ||
|
||
If it's the first installation, you have to create users first using [`createMongoUsers.js`](createMongoUsers.js) script : | ||
|
||
```bash | ||
$ sudo docker-compose -f xray.xml up -d mongo | ||
$ sudo cat createMongoUsers.js | docker exec -i xray-mongodb mongo | ||
``` | ||
|
||
Then you are ready to go : | ||
|
||
```bash | ||
$ sudo docker-compose -f xray.yml up -d | ||
``` | ||
|
||
This example starts the following containers and exposes Xray on port 8000 (http) | ||
|
||
## Run Xray with Traefik | ||
|
||
_TODO_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//JFrog Xray MongoDB Bootstrap | ||
|
||
//Creating default admin user | ||
var adminUser = { | ||
user:"admin", | ||
pwd: "password", | ||
roles: ["root"], | ||
customData: { | ||
createdBy: "JFrog Xray installer" | ||
} | ||
} | ||
db.getSiblingDB("admin").createUser(adminUser) | ||
|
||
//Creating default xray user | ||
var xrayUser = { | ||
user:"xray", | ||
pwd: "password", | ||
roles: ["dbOwner"], | ||
customData: { | ||
createdBy: "JFrog Xray installer" | ||
} | ||
} | ||
|
||
//Authenticating as admin to create xray user | ||
var loginOutput = db.getSiblingDB("admin").auth(adminUser.user,adminUser.pwd) | ||
db.getSiblingDB("xray").createUser(xrayUser) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
# This file is for preparing all the needed files and directories on the host. | ||
|
||
SCRIPT_DIR=$(dirname $0) | ||
OS_NAME=$(uname) | ||
|
||
errorExit () { | ||
echo; echo "ERROR: $1"; echo | ||
exit 1 | ||
} | ||
|
||
if [ "${OS_NAME}" = "Linux" ] && [ "$EUID" != 0 ]; then | ||
errorExit "This script must be run as root or with sudo" | ||
fi | ||
|
||
if [ ! -f ./.env ]; then | ||
errorExit ".env file does not exist in $SCRIPT_DIR" | ||
fi | ||
|
||
source ./.env | ||
|
||
if [ ! -d ${XRAY_MOUNT_ROOT}/xray ]; then | ||
echo "Creating ${XRAY_MOUNT_ROOT}/xray" | ||
mkdir -p ${XRAY_MOUNT_ROOT}/xray | ||
fi | ||
|
||
if [ $(stat -c '%u' ${XRAY_MOUNT_ROOT}/xray) != "${XRAY_USER_ID}" ] || [ $(stat -c '%g' ${XRAY_MOUNT_ROOT}/xray) != "${XRAY_USER_ID}" ]; then | ||
echo "Setting needed ownerships on ${XRAY_MOUNT_ROOT}/xray" | ||
chown -R ${XRAY_USER_ID}:${XRAY_USER_ID} ${XRAY_MOUNT_ROOT}/xray || errorExit "Setting ownership of ${XRAY_MOUNT_ROOT}/xray to ${XRAY_USER_ID} failed" | ||
fi | ||
|
||
echo "Done!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
version: "3" | ||
|
||
services: | ||
xray-server: | ||
image: $XRAY_DOCKER_REPO/xray-server:$XRAY_VERSION | ||
container_name: xray-server | ||
ports: | ||
- "$XRAY_SERVER_PORT:$XRAY_SERVER_PORT" | ||
depends_on: | ||
- mongodb | ||
- postgres | ||
- rabbitmq | ||
volumes: | ||
- "$XRAY_MOUNT_ROOT/xray:$XRAY_DATA" | ||
environment: | ||
- "XRAYCONFIGPATH=$XRAY_DATA" | ||
- "DOCKER_COMPOSE_FLAGS=$DOCKER_COMPOSE_FLAGS" | ||
- "DOCKER_COMPOSE_XRAY_FLAGS=$DOCKER_COMPOSE_XRAY_SERVER_FLAGS" | ||
restart: always | ||
|
||
xray-indexer: | ||
image: $XRAY_DOCKER_REPO/xray-indexer:$XRAY_VERSION | ||
container_name: xray-indexer | ||
depends_on: | ||
- postgres | ||
- rabbitmq | ||
volumes: | ||
- "$XRAY_MOUNT_ROOT/xray:$XRAY_DATA" | ||
environment: | ||
- "XRAYCONFIGPATH=$XRAY_DATA" | ||
- "DOCKER_COMPOSE_FLAGS=$DOCKER_COMPOSE_FLAGS" | ||
- "DOCKER_COMPOSE_XRAY_FLAGS=$DOCKER_COMPOSE_XRAY_INDEXER_FLAGS" | ||
restart: always | ||
|
||
xray-analysis: | ||
image: $XRAY_DOCKER_REPO/xray-analysis:$XRAY_VERSION | ||
container_name: xray-analysis | ||
depends_on: | ||
- postgres | ||
- rabbitmq | ||
volumes: | ||
- "$XRAY_MOUNT_ROOT/xray:$XRAY_DATA" | ||
environment: | ||
- "XRAYCONFIGPATH=$XRAY_DATA" | ||
- "DOCKER_COMPOSE_FLAGS=$DOCKER_COMPOSE_FLAGS" | ||
- "DOCKER_COMPOSE_XRAY_FLAGS=$DOCKER_COMPOSE_XRAY_ANALYSIS_FLAGS" | ||
restart: always | ||
|
||
xray-persist: | ||
image: $XRAY_DOCKER_REPO/xray-persist:$XRAY_VERSION | ||
container_name: xray-persist | ||
depends_on: | ||
- postgres | ||
- rabbitmq | ||
volumes: | ||
- "$XRAY_MOUNT_ROOT/xray:$XRAY_DATA" | ||
environment: | ||
- "XRAYCONFIGPATH=$XRAY_DATA" | ||
- "DOCKER_COMPOSE_FLAGS=$DOCKER_COMPOSE_FLAGS" | ||
- "DOCKER_COMPOSE_XRAY_FLAGS=$DOCKER_COMPOSE_XRAY_PERSIST_FLAGS" | ||
restart: always | ||
|
||
rabbitmq: | ||
image: $XRAYDB_DOCKER_REPO/xray-rabbitmq:$RABBITMQ_VERSION | ||
container_name: xray-rabbitmq | ||
hostname: $DOCKER_SERVER_HOSTNAME | ||
volumes: | ||
- "$XRAY_MOUNT_ROOT/rabbitmq:/var/lib/rabbitmq" | ||
environment: | ||
- "RABBITMQ_ERLANG_COOKIE=$RABBITMQ_ERLANG_COOKIE" | ||
restart: always | ||
|
||
postgres: | ||
image: $XRAYDB_DOCKER_REPO/xray-postgres:$POSTGRES_VERSION | ||
container_name: xray-postgres | ||
environment: | ||
- "POSTGRES_USER=$POSTGRES_USER" | ||
- "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" | ||
- "POSTGRES_DB=$POSTGRES_DB" | ||
volumes: | ||
- "$XRAY_MOUNT_ROOT/postgres:/var/lib/postgresql/data" | ||
restart: always | ||
|
||
mongodb: | ||
image: $XRAYDB_DOCKER_REPO/xray-mongo:$MONGO_VERSION | ||
container_name: xray-mongodb | ||
entrypoint: /bin/bash -c "chmod 777 /data/logs; /entrypoint.sh --logpath /data/logs/xray-mongo.log --auth" | ||
volumes: | ||
- "$XRAY_MOUNT_ROOT/mongodb/logs:/data/logs" | ||
- "$XRAY_MOUNT_ROOT/mongodb/configdb:/data/configdb" | ||
- "$XRAY_MOUNT_ROOT/mongodb/db:/data/db" | ||
restart: always |