Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build nzyme from source #7

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ logsClient/*
vagrant/.vagrant/*
vagrant/date.log
*.log
.DS_Store
85 changes: 85 additions & 0 deletions docker-compose-local.yml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 14 additions & 4 deletions nzyme/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
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 -Dmaven.test.skip=true install 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
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
CMD /usr/bin/java -jar /opt/nzyme/nzyme-1.2.2.jar -c /etc/nzyme/nzyme.conf
3 changes: 3 additions & 0 deletions nzyme/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down