From d644dc1902d07fdb89682e1e7404a8c83eebfbf2 Mon Sep 17 00:00:00 2001 From: gabrielsclimaco Date: Sep 12 2017 21:42:00 +0000 Subject: [PATCH 1/2] Add docker for environment set up and documentation for running it --- diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6865040 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +Dockerfile +.git +Jenkinsfile +LICENSE +README.md +.gitignore +.gitmodules +doc/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0eea468 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM fedora + +RUN dnf install -y openssl-devel docker python3-devel gcc redhat-rpm-config \ + docker python-pip make \ + && mkdir /app + +ADD . /app +WORKDIR /app + +RUN pip install virtualenv && virtualenv -p /usr/bin/python3 . &&\ + source bin/activate && pip install -e . && pip install "fedmsg[consumers]" + +EXPOSE 5000 + +RUN source bin/activate diff --git a/Makefile b/Makefile index 21aa3b1..343042c 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ help: - @printf "Available targets: check, analyzers, clean\n\n" + @printf "Available targets: check, analyzers, clean, run-docker-env, build-docker-env\n\n" check: coverage run --omit="lib/*","setup.py","kiskadee/tests/*",".eggs/*",".venv/*" ./setup.py test @@ -22,3 +22,16 @@ analyzers: clean: rm -rf htmlcov .coverage + +run-docker-env: + docker run --rm -it \ + -v "/var/run/docker.sock:/var/run/docker.sock" \ + -v "$(shell pwd)/kiskadee:/app/kiskadee" \ + -v "$(shell pwd)/util:/app/util" \ + -p "5000:5000" \ + --name=kiskadee_backend \ + kiskadee_backend bash + +build-docker-env: + docker build -t kiskadee_backend . + diff --git a/README.md b/README.md index b030bc2..8cef88e 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,74 @@ Test the database connection: If you was able to get into the psql shell, the database is properly configured. Leave the shell with ctrl+d. +### With Docker + +If you don't want to install all dependencies, use the Dockerfile on the root of the project: + +#### First, change the database host: + +Go to ```util/kiskadee.conf``` and change the following line: + +``` +hostname = localhost +``` + +If you are on Linux change it to: + +``` +hostname = 172.17.0.1 +``` + +If you are on MacOS change it to: + +``` +hostname = docker.for.mac.localhost +``` + +#### Now build the kiskadee image + +``` +docker build -t kiskadee_backend . +``` + +With Makefile: + +``` +make build-docker-env +``` + +#### Then, run the image using the following command: + +``` +docker run --rm -it \ + -v "/var/run/docker.sock:/var/run/docker.sock" \ + -v "$(shell pwd)/kiskadee:/app/kiskadee" \ + -v "$(shell pwd)/util:/app/util" \ + -p "5000:5000" \ + --name=kiskadee_backend \ + kiskadee_backend bash +``` + +Using the Makefile: + +``` +make run-docker-env +``` + +#### Now you're into docker, just enter the environment as usual: + +``` +source bin/activate +``` + +Now you can run ```kiskadee``` and ```kiskadee_api```. + +--- + +**Obs:** You still need to set up the [PostgreSQL database](#database) and build the [docker images](#docker-images). + +--- + ### Running our first analysis kiskadee reads environment variables from the `util/kiskadee.conf` file. From 9821490ed66613b858ea8df6fd94dc9b44465f31 Mon Sep 17 00:00:00 2001 From: gabrielsclimaco Date: Sep 12 2017 21:42:00 +0000 Subject: [PATCH 2/2] Add dpkg to dependencies --- diff --git a/Dockerfile b/Dockerfile index 0eea468..d71380b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM fedora RUN dnf install -y openssl-devel docker python3-devel gcc redhat-rpm-config \ - docker python-pip make \ + docker python-pip make dpkg \ && mkdir /app ADD . /app