diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 0000000..8f4e724 --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,20 @@ +FROM python:3.7.0-slim-stretch + +WORKDIR /tmp +ADD bin ./bin +ADD build ./build +ADD templates ./templates +ADD tests ./tests +ADD beats.txt Makefile requirements.txt version.json ./ + +RUN pip3 install -r requirements.txt +RUN pip3 install virtualenv + +# Need `make` installed +RUN apt-get update +RUN apt-get install -y build-essential + +# actually generate the Dockerfile via a `make` target +RUN make images + +CMD ["cat", "/tmp/build/filebeat/Dockerfile-full"] diff --git a/Makefile b/Makefile index b68ca59..d40f2be 100644 --- a/Makefile +++ b/Makefile @@ -77,7 +77,7 @@ $(BEATS): venv -D url=$(DOWNLOAD_URL_ROOT)/$@/$@-$(ELASTIC_VERSION)-linux-x86_64.tar.gz \ -D image_flavor=full \ templates/Dockerfile.j2 > build/$@/Dockerfile-full - docker build $(DOCKER_FLAGS) -f build/$@/Dockerfile-full --tag=$(REGISTRY)/beats/$@:$(VERSION_TAG) build/$@ + #docker build $(DOCKER_FLAGS) -f build/$@/Dockerfile-full --tag=$(REGISTRY)/beats/$@:$(VERSION_TAG) build/$@ jinja2 \ -D beat=$@ \ @@ -85,7 +85,7 @@ $(BEATS): venv -D url=$(DOWNLOAD_URL_ROOT)/$@/$@-oss-$(ELASTIC_VERSION)-linux-x86_64.tar.gz \ -D image_flavor=oss \ templates/Dockerfile.j2 > build/$@/Dockerfile-oss - docker build $(DOCKER_FLAGS) -f build/$@/Dockerfile-oss --tag=$(REGISTRY)/beats/$@-oss:$(VERSION_TAG) build/$@ + #docker build $(DOCKER_FLAGS) -f build/$@/Dockerfile-oss --tag=$(REGISTRY)/beats/$@-oss:$(VERSION_TAG) build/$@ local-httpd: docker run --rm -d --name=$(HTTPD) --network=host \ diff --git a/README.md b/README.md index 43d6104..e8c3491 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +## section-io specifics +We forked a version of filebeats at v6.2.3. In order to build an equivalent docker image +we need to also use the Dockerfile that created the v6.2.3 that Elastic produces. + +The file `sectin-io.md` explains how to go about generating the Dockerfile along with the changes to a number of files in this fork. + ## Description This repository contains the official [Beats][beats] Docker images from diff --git a/beats.txt b/beats.txt index 89238e0..faf4049 100644 --- a/beats.txt +++ b/beats.txt @@ -1,5 +1 @@ -auditbeat filebeat -heartbeat -metricbeat -packetbeat diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..9ca0030 --- /dev/null +++ b/build.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +build() { + docker build -t section-io-filebeats -f Dockerfile.build -v + docker run --rm -it section-io-filebeats > Dockerfile +} + +build \ No newline at end of file diff --git a/dev-local.sh b/dev-local.sh new file mode 100644 index 0000000..47a07c7 --- /dev/null +++ b/dev-local.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +USER=sysadmin +IP=192.168.1.38 +ACCT=$USER@$IP + +push() { + for f in ./* ; do + if [[ -d $f ]]; then + scp -r $f $ACCT:/home/$USER/ + elif [[ -f $f ]]; then + scp $f $ACCT:/home/$USER/$f + else + echo "invalid $f" + fi + done +} + +if [ "$1" == "" ]; then + push +else + $1 +fi \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..a6347e0 --- /dev/null +++ b/install.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# change this to the user you created for your VM +DOCKER_USER="sysadmin" + +docker_installs() { + apt-get update + apt-get remove docker docker-engine docker.io + apt-get install -y \ + apt-transport-https \ + ca-certificates \ + curl \ + software-properties-common + + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - + + #apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" + + # sadly this is the command to run because ubuntu doesn't have a docker + # package easy to install via apt-get??? + # see: https://askubuntu.com/questions/938700/how-do-i-install-docker-on-ubuntu-16-04-lts + apt install docker.io +} + +# post installation setup for user +post_installs() { + if [ ! $(getent group docker) ]; then + echo "add a docker group" + groupadd docker + fi + echo "Adding '$DOCKER_USER' to docker group" + usermod -aG docker "$DOCKER_USER" +} + +# Pull the python image before the build -- convenience for development. +docker_pull() { + docker pull python:3.7.0-slim-stretch +} + +# 1) setup the shell and dev tools for the user +# 2) add docker to the system +# 3) make docker group and add user +# 4) change user's shell to zsh +installs() { + docker_installs + post_installs +} + +$1 \ No newline at end of file diff --git a/section.io.md b/section.io.md new file mode 100644 index 0000000..7a8d944 --- /dev/null +++ b/section.io.md @@ -0,0 +1,29 @@ +# Purpose +These instruction outline the steps used to create the Dockerfile used +to build filebeats for the section.io deployment. + +## TL;DR +This is provided as step to create an environment from scratch on a VM +that doesn't initially have docker running. + +- Setup a VM (ubuntu/xenial) +- Get User and IP from VM (with bridged network or something that lets + you SSH and SCP to the VM). +- Edit dev-local.sh with the USER and IP +- Run ./dev-local.sh to push local files into VM via SCP +- Ssh into the machine and run $HOME/install.sh which will add docker to the + machine and setup the docker group +- With the ssh session then run $HOME/build.sh which will create the docker + image, then output to console the Dockerfile that was generated. + +## Sorter version +Starting with a docker deamon running some environment such that the local +docker can issue commands against. + +Simply run `./build.sh` which should `docker build` the image targeting the +configured deamon. The script will then also attempt to run the created +image and simply output the generated Dockerfile. + +## Steps in Code +See Dockerfile.build. It hightlights the steps in Dockerfile format using a +Python3 image. diff --git a/version.json b/version.json index a2add87..5154dea 100644 --- a/version.json +++ b/version.json @@ -1 +1 @@ -{"version": "7.0.0-alpha1"} +{"version": "6.2.3"}