# DO NOT MODIFY THIS FILE DIRECTLY. IT IS AUTO-GENERATED BY .devcontainer/scripts/generate-dockerfile.sh # ---/Dockerfile--- FROM alpine:3.22 AS builder ARG INSTALL_DIR=/app ENV PYTHONUNBUFFERED=1 # Install build dependencies RUN apk add --no-cache bash shadow python3 python3-dev gcc musl-dev libffi-dev openssl-dev git \ && python -m venv /opt/venv # Enable venv ENV PATH="/opt/venv/bin:$PATH" RUN pip install openwrt-luci-rpc asusrouter asyncio aiohttp graphene flask flask-cors unifi-sm-api tplink-omada-client wakeonlan pycryptodome requests paho-mqtt scapy cron-converter pytz json2table dhcp-leases pyunifi speedtest-cli chardet python-nmap dnspython librouteros yattag git+https://github.com/foreign-sub/aiofreepybox.git # Append Iliadbox certificate to aiofreepybox # second stage FROM alpine:3.22 AS runner ARG INSTALL_DIR=/app COPY --from=builder /opt/venv /opt/venv COPY --from=builder /usr/sbin/usermod /usr/sbin/groupmod /usr/sbin/ # Enable venv ENV PATH="/opt/venv/bin:$PATH" # default port and listen address ENV PORT=20211 LISTEN_ADDR=0.0.0.0 # needed for s6-overlay ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 # ❗ IMPORTANT - if you modify this file modify the /install/install_dependecies.sh file as well ❗ RUN apk update --no-cache \ && apk add --no-cache bash libbsd zip lsblk gettext-envsubst sudo mtr tzdata s6-overlay \ && apk add --no-cache curl arp-scan iproute2 iproute2-ss nmap nmap-scripts traceroute nbtscan avahi avahi-tools openrc dbus net-tools net-snmp-tools bind-tools awake ca-certificates \ && apk add --no-cache sqlite php83 php83-fpm php83-cgi php83-curl php83-sqlite3 php83-session \ && apk add --no-cache python3 nginx \ && ln -s /usr/bin/awake /usr/bin/wakeonlan \ && rm -f /etc/nginx/http.d/default.conf # Add crontab file COPY --chmod=600 --chown=root:root install/crontab /etc/crontabs/root # Start all required services HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=2 \ CMD curl -sf -o /dev/null ${LISTEN_ADDR}:${PORT}/php/server/query_json.php?file=app_state.json ENTRYPOINT ["/init"] # ---/resources/devcontainer-Dockerfile--- # Devcontainer build stage (do not build directly) # This file is combined with the root /Dockerfile by # .devcontainer/scripts/generate-dockerfile.sh # The generator appends this stage to produce .devcontainer/Dockerfile. # Prefer to place dev-only setup here; use setup.sh only for runtime fixes. FROM runner AS devcontainer ENV INSTALL_DIR=/app ENV PYTHONPATH=/workspaces/NetAlertX/test:/workspaces/NetAlertX/server:/app:/app/server:/opt/venv/lib/python3.12/site-packages # Install common tools, create user, and set up sudo RUN apk add --no-cache git nano vim jq php83-pecl-xdebug py3-pip nodejs sudo gpgconf pytest pytest-cov && \ adduser -D -s /bin/sh netalertx && \ addgroup netalertx nginx && \ addgroup netalertx www-data && \ echo "netalertx ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-netalertx && \ chmod 440 /etc/sudoers.d/90-netalertx # Install debugpy in the virtualenv if present, otherwise into system python3 RUN /bin/sh -c '(/opt/venv/bin/python3 -m pip install --no-cache-dir debugpy) || (python3 -m pip install --no-cache-dir debugpy) || true' # setup nginx COPY .devcontainer/resources/netalertx-devcontainer.conf /etc/nginx/http.d/netalert-frontend.conf RUN set -e; \ chown netalertx:nginx /etc/nginx/http.d/netalert-frontend.conf; \ install -d -o netalertx -g www-data -m 775 /app; \ install -d -o netalertx -g www-data -m 755 /run/nginx; \ install -d -o netalertx -g www-data -m 755 /var/lib/nginx/logs; \ rm -f /var/lib/nginx/logs/* || true; \ for f in error access; do : > /var/lib/nginx/logs/$f.log; done; \ install -d -o netalertx -g www-data -m 777 /run/php; \ install -d -o netalertx -g www-data -m 775 /var/log/php; \ chown -R netalertx:www-data /etc/nginx/http.d; \ chmod -R 775 /etc/nginx/http.d; \ chown -R netalertx:www-data /var/lib/nginx; \ chmod -R 755 /var/lib/nginx && \ chown -R netalertx:www-data /var/log/nginx/ && \ sed -i '/^user /d' /etc/nginx/nginx.conf; \ sed -i 's|^error_log .*|error_log /dev/stderr warn;|' /etc/nginx/nginx.conf; \ sed -i 's|^access_log .*|access_log /dev/stdout main;|' /etc/nginx/nginx.conf; \ sed -i 's|error_log .*|error_log /dev/stderr warn;|g' /etc/nginx/http.d/*.conf 2>/dev/null || true; \ sed -i 's|access_log .*|access_log /dev/stdout main;|g' /etc/nginx/http.d/*.conf 2>/dev/null || true; \ mkdir -p /run/openrc; \ chown netalertx:nginx /run/openrc/; \ rm -Rf /run/openrc/*; # setup pytest RUN sudo /opt/venv/bin/python -m pip install -U pytest pytest-cov WORKDIR /workspaces/NetAlertX ENTRYPOINT ["/bin/sh","-c","sleep infinity"]