From 1edba2d13b8de836e1f97100b65e4596933692c2 Mon Sep 17 00:00:00 2001 From: Paul-Emmanuel Raoul Date: Mon, 26 Nov 2018 20:50:47 +0000 Subject: [PATCH 01/10] Specify the release installed by Dockerfile using an argument --- docker/Dockerfile | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 6cd945d70..88f6c6888 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,17 +2,19 @@ FROM debian:jessie-slim LABEL MAINTAINER="theonlydoo " +ARG RELEASE=1.6 + WORKDIR /app -ADD https://github.com/guardicore/monkey/releases/download/1.5.2/infection_monkey_1.5.2_deb.tgz . +ADD https://github.com/guardicore/monkey/releases/download/${RELEASE}/infection_monkey_deb.${RELEASE}.tgz . -RUN tar xvf infection_monkey_1.5.2_deb.tgz \ - && apt-get -yqq update \ - && apt-get -yqq upgrade \ - && apt-get -yqq install python-pip \ - libssl-dev \ - supervisor \ - && dpkg -i *.deb +RUN tar xvf infection_monkey_deb.${RELEASE}.tgz \ + && apt-get -yqq update \ + && apt-get -yqq upgrade \ + && apt-get -yqq install python-pip \ + libssl-dev \ + supervisor \ + && dpkg -i *.deb COPY stack.conf /etc/supervisor/conf.d/stack.conf From 8ac1f35142a01ba079edfdf71aa4714154d5fdad Mon Sep 17 00:00:00 2001 From: Paul-Emmanuel Raoul Date: Mon, 26 Nov 2018 20:52:35 +0000 Subject: [PATCH 02/10] Fix installation issue in Dockerfile --- docker/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index 88f6c6888..88a120f0e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -12,6 +12,7 @@ RUN tar xvf infection_monkey_deb.${RELEASE}.tgz \ && apt-get -yqq update \ && apt-get -yqq upgrade \ && apt-get -yqq install python-pip \ + python-dev \ libssl-dev \ supervisor \ && dpkg -i *.deb From f1dd30d18c94fe473ee0ae56060e6fb49a1228cf Mon Sep 17 00:00:00 2001 From: Paul-Emmanuel Raoul Date: Mon, 26 Nov 2018 21:03:45 +0000 Subject: [PATCH 03/10] Add EXPOSE instruction to Dockerfile --- docker/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index 88a120f0e..911afb433 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,6 +4,8 @@ LABEL MAINTAINER="theonlydoo " ARG RELEASE=1.6 +EXPOSE 5000 + WORKDIR /app ADD https://github.com/guardicore/monkey/releases/download/${RELEASE}/infection_monkey_deb.${RELEASE}.tgz . From 195a3c830447f5b95b83ff110c3fa9c69eda872d Mon Sep 17 00:00:00 2001 From: Paul-Emmanuel Raoul Date: Tue, 27 Nov 2018 11:15:48 +0000 Subject: [PATCH 04/10] Add 'DEBIAN_FRONTEND' as 'ARG' Using 'ARG' instead of 'ENV' allows to define environment variables only for the build stage. See https://github.com/moby/moby/issues/4032#issuecomment-34597177. --- docker/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index 911afb433..ca8be5c9a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -3,6 +3,7 @@ FROM debian:jessie-slim LABEL MAINTAINER="theonlydoo " ARG RELEASE=1.6 +ARG DEBIAN_FRONTEND=noninteractive EXPOSE 5000 From c1c8c33c85b29ed06fdbf6d3994fe91cba1e89c7 Mon Sep 17 00:00:00 2001 From: Paul-Emmanuel Raoul Date: Tue, 27 Nov 2018 11:19:26 +0000 Subject: [PATCH 05/10] Delete installation files --- docker/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index ca8be5c9a..56085b40e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -18,7 +18,8 @@ RUN tar xvf infection_monkey_deb.${RELEASE}.tgz \ python-dev \ libssl-dev \ supervisor \ - && dpkg -i *.deb + && dpkg -i *.deb \ + && rm -f *.deb *.tgz COPY stack.conf /etc/supervisor/conf.d/stack.conf From 8beada58d538c76aaece0a8281546f02b9fa1532 Mon Sep 17 00:00:00 2001 From: Paul-Emmanuel Raoul Date: Tue, 27 Nov 2018 11:20:17 +0000 Subject: [PATCH 06/10] Add '.dockerignore' --- docker/.dockerignore | 1 + docker/Dockerfile | 4 ++-- docker/docker-compose.yml | 23 +++++++++++++++++++++++ docker/stack.conf | 4 +--- 4 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 docker/.dockerignore create mode 100644 docker/docker-compose.yml diff --git a/docker/.dockerignore b/docker/.dockerignore new file mode 100644 index 000000000..dd449725e --- /dev/null +++ b/docker/.dockerignore @@ -0,0 +1 @@ +*.md diff --git a/docker/Dockerfile b/docker/Dockerfile index 56085b40e..762b20a7d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:jessie-slim +FROM debian:stretch-slim LABEL MAINTAINER="theonlydoo " @@ -23,4 +23,4 @@ RUN tar xvf infection_monkey_deb.${RELEASE}.tgz \ COPY stack.conf /etc/supervisor/conf.d/stack.conf -ENTRYPOINT [ "supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf" ] \ No newline at end of file +ENTRYPOINT [ "supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf" ] diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 000000000..0fa49bf62 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,23 @@ +version: '3.3' + +services: + db: + image: mongo:4 + restart: always + volumes: + - db_data:/data/db + environment: + MONGO_INITDB_ROOT_USERNAME: root + MONGO_INITDB_ROOT_PASSWORD: test + monkey: + depends_on: + - db + build: . + image: monkey:latest + ports: + - "5000:5000" + environment: + MONGO_URL: mongodb://root:test@db:27017/ + +volumes: + db_data: diff --git a/docker/stack.conf b/docker/stack.conf index b742c0392..e84d508aa 100644 --- a/docker/stack.conf +++ b/docker/stack.conf @@ -1,4 +1,2 @@ -[program:mongod] -command=/var/monkey_island/bin/mongodb/bin/mongod --quiet --dbpath /var/monkey_island/db [program:monkey] -command=/var/monkey_island/ubuntu/systemd/start_server.sh +command=/var/monkey/monkey_island/ubuntu/systemd/start_server.sh From 290ee213fd88d994b7c603f8a0a58c6c7ddd805e Mon Sep 17 00:00:00 2001 From: Paul-Emmanuel Raoul Date: Thu, 29 Nov 2018 15:11:41 +0000 Subject: [PATCH 07/10] Use an external Mongo database with Docker Compose --- docker/docker-compose.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 0fa49bf62..1620ae330 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -7,8 +7,7 @@ services: volumes: - db_data:/data/db environment: - MONGO_INITDB_ROOT_USERNAME: root - MONGO_INITDB_ROOT_PASSWORD: test + MONGO_INITDB_DATABASE: monkey monkey: depends_on: - db @@ -17,7 +16,7 @@ services: ports: - "5000:5000" environment: - MONGO_URL: mongodb://root:test@db:27017/ + MONGO_URL: mongodb://db:27017/monkey volumes: db_data: From f3ce6c08c57248dadfd4b488fd29c16651384185 Mon Sep 17 00:00:00 2001 From: Paul-Emmanuel Raoul Date: Thu, 29 Nov 2018 16:20:55 +0000 Subject: [PATCH 08/10] Remove supervisord --- docker/Dockerfile | 8 +++----- docker/stack.conf | 2 -- 2 files changed, 3 insertions(+), 7 deletions(-) delete mode 100644 docker/stack.conf diff --git a/docker/Dockerfile b/docker/Dockerfile index 762b20a7d..2d0d0b55b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -16,11 +16,9 @@ RUN tar xvf infection_monkey_deb.${RELEASE}.tgz \ && apt-get -yqq upgrade \ && apt-get -yqq install python-pip \ python-dev \ - libssl-dev \ - supervisor \ && dpkg -i *.deb \ && rm -f *.deb *.tgz -COPY stack.conf /etc/supervisor/conf.d/stack.conf - -ENTRYPOINT [ "supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf" ] +WORKDIR /var/monkey +ENTRYPOINT ["/var/monkey/monkey_island/bin/python/bin/python"] +CMD ["/var/monkey/monkey_island.py"] diff --git a/docker/stack.conf b/docker/stack.conf deleted file mode 100644 index e84d508aa..000000000 --- a/docker/stack.conf +++ /dev/null @@ -1,2 +0,0 @@ -[program:monkey] -command=/var/monkey/monkey_island/ubuntu/systemd/start_server.sh From 2c5019306bb1d51c4d9c3d35c7b60fb329d2d280 Mon Sep 17 00:00:00 2001 From: Paul-Emmanuel Raoul Date: Fri, 30 Nov 2018 12:25:06 +0000 Subject: [PATCH 09/10] Change the Mongo database's name to stick to the documentation See https://github.com/guardicore/monkey/blob/develop/monkey/monkey_island/readme.txt. --- docker/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 1620ae330..69678c004 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -16,7 +16,7 @@ services: ports: - "5000:5000" environment: - MONGO_URL: mongodb://db:27017/monkey + MONGO_URL: mongodb://db:27017/monkeyisland volumes: db_data: From 4283d8d488134d8bc80579d495bc5456bcf72fb0 Mon Sep 17 00:00:00 2001 From: Paul-Emmanuel Raoul Date: Fri, 30 Nov 2018 14:40:12 +0000 Subject: [PATCH 10/10] Fix previous commit I forgot to change the `MONGO_INITDB_DATABASE` variable. --- docker/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 69678c004..94a81b00e 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -7,7 +7,7 @@ services: volumes: - db_data:/data/db environment: - MONGO_INITDB_DATABASE: monkey + MONGO_INITDB_DATABASE: monkeyisland monkey: depends_on: - db