Refactor entire project for Docker-native operation
Complete Docker-first refactor of the 6,800-line management script: Core Architecture: - Added is_docker() detection (/.dockerenv + /proc/1/cgroup check) - Added asterisk_running() helper replacing all systemctl is-active calls - Moved restart_asterisk_safe() to top-level with Docker/bare-metal branches - Added webadmin_running(), start_webadmin(), stop_webadmin(), restart_webadmin() for process-based web admin management (replaces systemd service) Functions Refactored (Docker-aware): - fix_asterisk_systemd(): no-op in Docker (no systemd) - install_asterisk_packages(): skips apt in Docker (pre-installed) - install_baresip_packages(): skips in Docker (no local audio client) - open_firewall_ports(): skips ufw in Docker (host responsibility) - configure_asterisk(): skips systemctl enable in Docker - enable_client_services(): skips entirely in Docker (no kiosk client) - configure_baresip(): skips entirely in Docker - configure_local_client(): shows error with guidance to use mobile clients - run_client_diagnostics(): redirects to vpn-diagnostics - fix_audio_manually(): not available in Docker (no audio hardware) - uninstall_menu(): shows Docker-specific reset options - manual_update_asterisk(): shows Docker rebuild instructions - create_web_admin_service(): no-op in Docker (process-managed) - web_admin_menu(): uses start/stop/restart_webadmin() instead of systemctl Menu System: - show_main_menu(): Docker-specific status display (Asterisk, Web Admin, VPN ICE status) with streamlined menu (no Client Settings option) - submenu_install(): Docker shows Configure/Reset instead of Install/Uninstall - submenu_tools(): Docker shows Room Directory, Update, VPN Diagnostics, DNS Whitelist (hides audio tools that need hardware) Entrypoint: - Proper signal trapping (SIGTERM/SIGINT) for clean shutdown - Generates all Asterisk configs with STUN/ICE support from env vars - Creates default device categories on first run - Starts web admin as background process with env-based config Dockerfile: - Added lsof dependency (needed for port management) - Added STUN port 3478 exposure - Ensured /.dockerenv marker exists Backward compatible: bare-metal installs work exactly as before. https://claude.ai/code/session_01Vm6NLaQuzM4VosAotqS1q8
This commit is contained in:
+10
-1
@@ -6,6 +6,8 @@
|
||||
# docker compose up -d # Asterisk only
|
||||
# docker compose --profile stun up -d # Asterisk + self-hosted STUN
|
||||
# docker exec -it easy-asterisk easy-asterisk # Interactive management
|
||||
# docker exec -it easy-asterisk vpn-diagnostics # VPN diagnostics
|
||||
# docker exec -it easy-asterisk dns-whitelist # DNS whitelist check
|
||||
# ================================================================
|
||||
|
||||
FROM ubuntu:24.04
|
||||
@@ -13,7 +15,7 @@ FROM ubuntu:24.04
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV LANG=C.UTF-8
|
||||
|
||||
# Install Asterisk and dependencies (matches install_asterisk_packages)
|
||||
# Install Asterisk and all dependencies (matches install_asterisk_packages)
|
||||
RUN echo "exit 101" > /usr/sbin/policy-rc.d && chmod +x /usr/sbin/policy-rc.d && \
|
||||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
@@ -30,6 +32,7 @@ RUN echo "exit 101" > /usr/sbin/policy-rc.d && chmod +x /usr/sbin/policy-rc.d &&
|
||||
dnsutils \
|
||||
iputils-ping \
|
||||
procps \
|
||||
lsof \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& rm -f /usr/sbin/policy-rc.d \
|
||||
&& ldconfig \
|
||||
@@ -50,6 +53,9 @@ RUN mkdir -p \
|
||||
/var/spool/asterisk \
|
||||
/var/run/asterisk
|
||||
|
||||
# Docker detection marker (used by is_docker() in the script)
|
||||
RUN touch /.dockerenv
|
||||
|
||||
# Copy the main management script
|
||||
COPY easy-asterisk-v0.10.0.sh /usr/local/bin/easy-asterisk
|
||||
RUN chmod +x /usr/local/bin/easy-asterisk
|
||||
@@ -73,6 +79,9 @@ EXPOSE 8080/tcp
|
||||
EXPOSE 8088/tcp
|
||||
EXPOSE 8089/tcp
|
||||
|
||||
# STUN (if running coturn in same container)
|
||||
EXPOSE 3478/udp
|
||||
|
||||
# RTP media range (use --network host in production for full range)
|
||||
# Docker port-mapping 10000 ports is impractical; host networking recommended
|
||||
EXPOSE 10000-10100/udp
|
||||
|
||||
Reference in New Issue
Block a user