Skip to content

Commit

Permalink
feat: create metron images
Browse files Browse the repository at this point in the history
  • Loading branch information
m9rco committed Jun 19, 2019
1 parent 4ac2d53 commit 18cbdc2
Show file tree
Hide file tree
Showing 13 changed files with 321 additions and 2 deletions.
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
sudo: required

services:
- docker

env:
DOCKER_COMPOSE_VERSION: 1.8.1

before_install:
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
- sudo mv docker-compose /usr/local/bin
- chmod +x /usr/local/bin/docker-compose

- docker version

- docker build --no-cache -t m9rco/metron:0.7.1 -f 0.7.1/Dockerfile 0.7.1/
- docker run --name metron-0.7.1 -d -v $PWD:/app m9rco/metron:0.7.1

script:
- docker exec metron-0.7.1 sh -c "apk -V"
115 changes: 115 additions & 0 deletions 0.7.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

FROM centos:7
LABEL maintainer="m9rco <pushaowei0727@gmail.com>"

ADD rootfs /
WORKDIR /root

# Create a metron user
RUN adduser metron; \
echo metron | passwd metron --stdin; \
usermod -aG wheel metron;

# Update 163 Images
RUN mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup \
&& curl -o /etc/yum.repos.d/CentOS7-Base-163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo \
&& yum clean all \
&& yum makecache

# Start
RUN yum install -y \
tar \
initscripts \
sudo \
centos-release-scl \
devtoolset-4-gcc-c++ \
devtoolset-4-gcc \
zlib-dev \
openssl-devel \
sqlite-devel \
bzip2-devel \
libffi-devel \
java-1.8.0-openjdk \
java-1.8.0-openjdk-devel \
nss \
asciidoc \
rpm-build \
rpm2cpio \
xmlto \
rpmlint \
make \
# base development tools required \
&& yum groupinstall -y \
"Development tools" \
# Install Software Collections repo (needs to be done in separate command) \
# newer cpp 11 support required for building node modules \
# install metron 0.7.1 \
&& curl -o /root/metron-0.7.1.tgr.gz https://m9rco-bjhb2-storage.oss-cn-beijing.aliyuncs.com/apache-metron_0.7.1-release.tar.gz \
&& tar xvf /root/metron-0.7.1.tgr.gz \
# install python 2.7.11 but do not make it the default \
&& curl -o /usr/src/Python-2.7.11.tgz https://m9rco-bjhb2-storage.oss-cn-beijing.aliyuncs.com/Python-2.7.11.tgz \
&& cd /usr/src \
&& tar xvf Python-2.7.11.tgz \
&& rm -rf Python-2.7.11.tgz \
&& cd /usr/src/Python-2.7.11 \
&& ./configure \
&& make altinstall \
&& cd /usr/src \
&& curl -o /usr/src/setuptools-11.3.tar.gz https://m9rco-bjhb2-storage.oss-cn-beijing.aliyuncs.com/setuptools-11.3.tar.gz \
&& tar xvf setuptools-11.3.tar.gz \
&& rm setuptools-11.3.tar.gz \
&& cd /usr/src/setuptools-11.3 \
&& python2.7 setup.py install \
&& easy_install-2.7 pip \
# install ansible and set the configuration var \
&& pip2.7 install \
ansible==2.0.0.2 \
boto \
# java \
&& cd /usr/src \
# setup maven \
&& curl -o apache-maven-3.3.9-bin.tar.gz https://m9rco-bjhb2-storage.oss-cn-beijing.aliyuncs.com/apache-maven-3.3.9-bin.tar.gz \
&& tar xzvf apache-maven-3.3.9-bin.tar.gz \
&& rm apache-maven-3.3.9-bin.tar.gz \
&& mv apache-maven-3.3.9 /opt/maven \
&& ln -s /opt/maven/bin/mvn /usr/bin/mvn \
# install rpm tools required to build rpms \
# create a .bashrc for root, enabling the cpp 11 toolset \
&& touch /root/.bashrc \
&& echo '/opt/rh/devtoolset-4/enable' >> /root/.bashrc \
# install node so that the node dependencies can be packaged into the RPMs \
&& curl --silent --location https://rpm.nodesource.com/setup_6.x | bash - \
# Remove packages just needed for builds \
# Clean up yum caches \
&& yum clean all


# Enable systemd usage
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in ; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/; \
rm -f /etc/systemd/system/.wants/; \
rm -f /lib/systemd/system/local-fs.target.wants/; \
rm -f /lib/systemd/system/sockets.target.wants/udev; \
rm -f /lib/systemd/system/sockets.target.wants/initctl; \
rm -f /lib/systemd/system/basic.target.wants/; \
rm -f /lib/systemd/system/anaconda.target.wants/*;

VOLUME ["/sys/fs/cgroup"]

CMD ["/usr/sbin/init"]
26 changes: 26 additions & 0 deletions 0.7.1/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM m9rco/metron:0.7.1
LABEL maintainer="m9rco <pushaowei0727@gmail.com>"


ARG USER=root
ARG PASSWORD=root

RUN apk add -U --no-cache \
openssh \
supervisor \
autoconf \
git \
curl \
wget \
zip \
# clean up
&& rm -rf /var/cache/apk/* \
# add ssh
&& sed -i s/#PermitRootLogin.*/PermitRootLogin\ yes/ /etc/ssh/sshd_config \
&& echo "${USER}:${PASSWORD}" | chpasswd \
&& ssh-keygen -A

COPY devfs /

CMD ["supervisord", "--nodaemon", "--configuration", "/etc/supervisor/conf.d/supervisord.conf"]
EXPOSE 22 27017 28017
13 changes: 13 additions & 0 deletions 0.7.1/devfs/etc/profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export CHARSET=UTF-8
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export PAGER=less
export PS1='\h:\w\$ '

umask 022


for script in /etc/profile.d/*.sh ; do
if [ -r $script ] ; then
. $script
fi
done
11 changes: 11 additions & 0 deletions 0.7.1/devfs/etc/supervisor/conf.d/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[supervisord]
nodaemon=true
logfile=/var/log/supervisord.log
pidfile=/var/run/supervisord.pid

loglevel=debug


[program:ssh]
command=/usr/sbin/sshd -D

1 change: 1 addition & 0 deletions 0.7.1/rootfs/data/db/@m9rco
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@m9rco
19 changes: 19 additions & 0 deletions 0.7.1/rootfs/etc/mongodb/conf/mongodb-inputs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"advertisedHostname": "{{$global.env.MONGODB_ADVERTISED_HOSTNAME}}",
"database": "{{$global.env.MONGODB_DATABASE}}",
"disableSystemLog": "{{$global.env.MONGODB_DISABLE_SYSTEM_LOG}}",
"enableDirectoryPerDB": "{{$global.env.MONGODB_ENABLE_DIRECTORY_PER_DB}}",
"enableIPv6": "{{$global.env.MONGODB_ENABLE_IPV6}}",
"mongodbPort": "{{$global.env.MONGODB_PORT_NUMBER}}",
"password": "{{$global.env.MONGODB_PASSWORD}}",
"primaryHost": "{{$global.env.MONGODB_PRIMARY_HOST}}",
"primaryPort": "{{$global.env.MONGODB_PRIMARY_PORT_NUMBER}}",
"primaryRootPassword": "{{$global.env.MONGODB_PRIMARY_ROOT_PASSWORD}}",
"primaryRootUser": "{{$global.env.MONGODB_PRIMARY_ROOT_USER}}",
"replicaSetKey": "{{$global.env.MONGODB_REPLICA_SET_KEY}}",
"replicaSetMode": "{{$global.env.MONGODB_REPLICA_SET_MODE}}",
"replicaSetName": "{{$global.env.MONGODB_REPLICA_SET_NAME}}",
"rootPassword": "{{$global.env.MONGODB_ROOT_PASSWORD}}",
"systemLogVerbosity": "{{$global.env.MONGODB_SYSTEM_LOG_VERBOSITY}}",
"username": "{{$global.env.MONGODB_USERNAME}}"
}
23 changes: 23 additions & 0 deletions 0.7.1/rootfs/root/.aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
alias grep="grep -rnE --color"
alias mkdir="mkdir -pv"
alias cp='cp -v'
alias cpr='cp -r'
alias mv='mv -v'
alias chmod='chmod -v --preserve-root'
alias chown='chown -v --preserve-root'
alias df="df -h"
alias du="du -h"
alias last="last -a"
alias free='free -m'
alias lftp="lftp user:pwd@ftpip"


alias ll='ls -lh'
alias ..='cd ..'
alias ...='cd ../../'
alias ....='cd ../../../'
alias .....='cd ../../../../'
alias ......='cd ../../../../../'

alias freq='cut -f1 -d" " ~/.bash_history | sort | uniq -c | sort -nr | head -n 30'
alias tm='ps -ef | grep'
2 changes: 2 additions & 0 deletions 0.7.1/rootfs/root/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source ~/.aliases
source /etc/profile
28 changes: 28 additions & 0 deletions 0.7.1/rootfs/root/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
[defaults]
host_key_checking = False
library = ../extra_modules
roles_path = ../roles
pipelining = True
remote_user = centos
forks = 20
log_path = ./ansible.log

# fix for "ssh throws 'unix domain socket too long' " problem
[ssh_connection]
control_path = ~/.ssh/ansible-ssh-%%h-%%r
3 changes: 3 additions & 0 deletions 0.7.1/rootfs/usr/share/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

exec "$@"
61 changes: 59 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,59 @@
# metron
Apache Metron in a Docker container
<p align="center">
<img src="logo.png" width=300/>
</p>

# Apache Metron

<p align="center">

[![Author](https://img.shields.io/badge/Author-m9rco-Green.svg?style=flat&logo=tinder)](https://about.me/pushaowei/)
[![Open Source Love](https://badges.frapsoft.com/os/v2/open-source.svg?v=102)](https://travis-ci.org/m9rco/metron/)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/m9rco/metron/pulls)
[![Build Status](https://travis-ci.org/m9rco/metron.svg?branch=master)](https://travis-ci.org/m9rco/metron)
![Docker Pulls](https://img.shields.io/docker/pulls/m9rco/metron.svg?style=flat-square)

</p>

## Images

- [0.7.1](0.7.1)


## Usage

The recommended way to get the m9rco metron Docker Image is to pull the prebuilt image from the [Docker Hub Registry](https://hub.docker.com/r/m9rco/metron).

```sh
docker pull m9rco/metron:latest
```

To use a specific version, you can pull a versioned tag. You can view the [list of available versions](https://hub.docker.com/r/m9rco/metron/tags/) in the Docker Hub Registry.

```sh
$ docker pull m9rco/metron:[TAG]
```

## Run the Docker

```
docker run -itd --privileged --name=metron m9rco/metron
```

## Go inside the docker

```sh
docker exec -it --privileged metron bash
```

## Build Metron

```
cd ~/metron
mvn clean package -DskipTests [-e -X]
```

### Further documentation
For further documentation, please check metron documentation or its GitHub repository

### Contributing
We'd love for you to contribute to this container. You can request new features by creating an issue, or submit a pull request with your contribution.
Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 18cbdc2

Please sign in to comment.