From 21d7a64f0df162e54e976601e4c97632e52193cb Mon Sep 17 00:00:00 2001 From: Raul Sampedro <5142014+rsrdesarrollo@users.noreply.github.com> Date: Mon, 26 Aug 2024 20:56:40 +0200 Subject: [PATCH 1/3] build nzyme from sources, add docker-compose with build --- docker-compose-local.yml | 85 ++++++++++++++++++++++++++++++++++++++++ nzyme/Dockerfile | 15 +++++-- 2 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 docker-compose-local.yml diff --git a/docker-compose-local.yml b/docker-compose-local.yml new file mode 100644 index 0000000..f00df67 --- /dev/null +++ b/docker-compose-local.yml @@ -0,0 +1,85 @@ +services: + aps: + build: ./APs/ # uncomment to build the Docker file + restart: unless-stopped + container_name: WiFiChallengeLab-APs + env_file: ./APs/.env + volumes: + - /lib/modules:/lib/modules + - ./logsAP:/root/logs/ + network_mode: host #NETNS + privileged: true #NETNS + + clients: + build: ./Clients/ # uncomment to build the Docker file + restart: unless-stopped + container_name: WiFiChallengeLab-Clients + env_file: ./Clients/.env + volumes: + - /lib/modules:/lib/modules + - ./logsClient:/root/logs/ + depends_on: + - aps + network_mode: host #NETNS + privileged: true #NETNS + + nzyme: + build: ./nzyme/ + restart: unless-stopped + env_file: .env + container_name: WiFiChallengeLab-nzyme + security_opt: + - no-new-privileges:true + volumes: + - ./nzyme/nzyme.conf:/etc/nzyme/nzyme.conf.tmp #copy in entrypoint + - ./logsNzyme:/var/log/nzyme/ + #ports: + # - "22900:22900" + depends_on: + - aps + - db + environment: + - TZ=Europe/Berlin + - DATABASE_URL=$DATABASE_URL + - ADMIN_PASSWORD_HASH=$ADMIN_PASSWORD_HASH + - EXTERNAL_URL=$EXTERNAL_URL + network_mode: host #USB Antena + cap_add: # full access to wifi interface + - NET_ADMIN + - NET_RAW + deploy: + resources: + limits: + cpus: "0.50" + memory: 512M + reservations: + memory: 128M + db: + image: postgres:14 + restart: unless-stopped + env_file: .env + container_name: WiFiChallengeLab-nzyme-db + security_opt: + - no-new-privileges:true + depends_on: + - aps + environment: + - TZ=Europe/Berlin + - POSTGRES_DB=$POSTGRES_DB + - POSTGRES_USER=$POSTGRES_USER + - POSTGRES_PASSWORD=$POSTGRES_PASS + volumes: + - ./nzyme/data:/var/lib/postgresql/data + ports: + - 127.0.0.1:5432:5432 # Since we use host net on nzyme, listen only locally + healthcheck: + test: ["CMD", "pg_isready", "-U", "$POSTGRES_USER"] + interval: 10s + start_period: 30s + deploy: + resources: + limits: + cpus: "0.50" + memory: 512M + reservations: + memory: 128M \ No newline at end of file diff --git a/nzyme/Dockerfile b/nzyme/Dockerfile index 8652051..32488e9 100644 --- a/nzyme/Dockerfile +++ b/nzyme/Dockerfile @@ -1,8 +1,17 @@ +FROM chainguard/git:latest as repo +RUN git clone --depth 1 --branch 1.2.2 https://github.com/nzymedefense/nzyme.git + + +FROM maven:3.8.3-adoptopenjdk-11 as build +COPY --from=repo /home/git/nzyme /nzyme +WORKDIR /nzyme +RUN mvn jdeb:jdeb + + FROM ubuntu:20.04 -RUN apt-get update && apt-get install -y --no-install-recommends python3 libpcap0.8 openjdk-11-jre-headless wireless-tools gettext-base curl \ +COPY --from=build /nzyme/target/nzyme_1.2.2_all.deb nzyme.deb +RUN apt-get update && apt-get install -y --no-install-recommends python3 libpcap0.8 openjdk-11-jre-headless wireless-tools gettext-base curl git \ && apt-get clean && rm -rf /var/lib/apt/lists/* \ - && export VERSION=`curl -s https://v1.nzyme.org/blog/rss.xml | grep -E '[0-9]+\.[0-9]+\.[0-9]+' -o | head -n1` \ - && echo $VERSION && curl -s https://assets.nzyme.org/releases/nzyme-$VERSION.deb -o nzyme.deb \ && dpkg -i nzyme.deb && rm nzyme.deb # Entrypoint: Replace variables in config From e53c1f4062e06e40f3f5027a3d6c176c4fc548e5 Mon Sep 17 00:00:00 2001 From: Raul Sampedro <5142014+rsrdesarrollo@users.noreply.github.com> Date: Tue, 27 Aug 2024 15:52:03 +0200 Subject: [PATCH 2/3] dockerfile --- .gitignore | 1 + nzyme/Dockerfile | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 84c966c..b033add 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ logsClient/* vagrant/.vagrant/* vagrant/date.log *.log +.DS_Store \ No newline at end of file diff --git a/nzyme/Dockerfile b/nzyme/Dockerfile index 32488e9..55ba2e6 100644 --- a/nzyme/Dockerfile +++ b/nzyme/Dockerfile @@ -5,7 +5,7 @@ RUN git clone --depth 1 --branch 1.2.2 https://github.com/nzymedefense/nzyme.git FROM maven:3.8.3-adoptopenjdk-11 as build COPY --from=repo /home/git/nzyme /nzyme WORKDIR /nzyme -RUN mvn jdeb:jdeb +RUN mvn -Dmaven.test.skip=true install jdeb:jdeb FROM ubuntu:20.04 @@ -16,8 +16,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends python3 libpcap # Entrypoint: Replace variables in config COPY docker-entrypoint.sh /bin/ +COPY nzyme.conf /etc/nzyme/nzyme.conf.tmp RUN chmod +x /usr/bin/docker-entrypoint.sh ENTRYPOINT ["docker-entrypoint.sh"] -CMD /bin/bash /usr/share/nzyme/bin/nzyme \ No newline at end of file +CMD /usr/bin/java -jar /opt/nzyme/nzyme-1.2.2.jar -c /etc/nzyme/nzyme.conf \ No newline at end of file From f1195c3614e9e558c4545be8f32df0474f1fdad0 Mon Sep 17 00:00:00 2001 From: Raul Sampedro <5142014+rsrdesarrollo@users.noreply.github.com> Date: Tue, 27 Aug 2024 16:04:43 +0200 Subject: [PATCH 3/3] dockerfile --- nzyme/docker-entrypoint.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nzyme/docker-entrypoint.sh b/nzyme/docker-entrypoint.sh index 6c7b481..c0aaae4 100644 --- a/nzyme/docker-entrypoint.sh +++ b/nzyme/docker-entrypoint.sh @@ -5,6 +5,9 @@ echo Updating nzyme.conf using .env echo $DATABASE_URL +# Create data_directory if not present +mkdir /usr/share/nzyme 2> /dev/null + envsubst < /etc/nzyme/nzyme.conf.tmp > /etc/nzyme/nzyme.conf #/bin/sh /usr/share/nzyme/bin/nzyme