diff --git a/.dockerignore b/.dockerignore index 5d2adff0..64d3e9a2 100644 --- a/.dockerignore +++ b/.dockerignore @@ -44,3 +44,8 @@ erl_crash.dump /assets/node_modules/ /priv/static/assets/ /priv/static/cache_manifest.json + +# Compiled NIF binaries - should be built in container for target architecture +/priv/*.so +/priv/*.dylib +/c_src/*.o diff --git a/.gitignore b/.gitignore index 929b42ab..3351579b 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,8 @@ profiles.json # Application MIB files (now committed to git and included in Docker image) # Only ignore the top-level librenms mibs directory (symlink) + +# Compiled NIF binaries (platform-specific, should be built in Docker) +/priv/*.so +/priv/*.dylib +/c_src/*.o diff --git a/Dockerfile b/Dockerfile index 6716d019..0ae14564 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,7 @@ ENV TERM=dumb # install build dependencies RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential git \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential git libsnmp-dev \ && rm -rf /var/lib/apt/lists/* # prepare build dir @@ -63,6 +63,8 @@ RUN --mount=type=cache,target=/root/.mix \ COPY priv priv +COPY c_src c_src + COPY lib lib # Compile the release @@ -84,7 +86,7 @@ RUN mix release FROM ${RUNNER_IMAGE} AS final RUN apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends libstdc++6 openssl libncurses6 locales ca-certificates iputils-ping snmp \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends libstdc++6 openssl libncurses6 locales ca-certificates iputils-ping snmp libsnmp40 \ && rm -rf /var/lib/apt/lists/* # Set the locale diff --git a/lib/towerops/profiles/profile_watcher.ex b/lib/towerops/profiles/profile_watcher.ex index a6a4eb18..3e1ad1ad 100644 --- a/lib/towerops/profiles/profile_watcher.ex +++ b/lib/towerops/profiles/profile_watcher.ex @@ -5,6 +5,8 @@ defmodule Towerops.Profiles.ProfileWatcher do Uses FileSystem to monitor the priv/profiles directory for file changes. When a .yaml or .yml file is created, modified, or deleted, triggers a reload of all profiles via YamlProfiles.reload/0. + + Note: Only available in development mode. FileSystem is a dev-only dependency. """ use GenServer @@ -20,16 +22,24 @@ defmodule Towerops.Profiles.ProfileWatcher do @impl true def init(_opts) do - # Get the absolute path to the profiles directory - profiles_path = Path.join(Application.app_dir(:towerops), @profiles_dir) + # Only start file watcher in development + # FileSystem is a dev-only dependency + if Code.ensure_loaded?(FileSystem) do + # Get the absolute path to the profiles directory + profiles_path = Path.join(Application.app_dir(:towerops), @profiles_dir) - # Start watching the profiles directory for changes - {:ok, watcher_pid} = FileSystem.start_link(dirs: [profiles_path]) - FileSystem.subscribe(watcher_pid) + # Start watching the profiles directory for changes + {:ok, watcher_pid} = FileSystem.start_link(dirs: [profiles_path]) + FileSystem.subscribe(watcher_pid) - Logger.info("ProfileWatcher: Started watching #{profiles_path}") + Logger.info("ProfileWatcher: Started watching #{profiles_path}") - {:ok, %{watcher_pid: watcher_pid, profiles_path: profiles_path}} + {:ok, %{watcher_pid: watcher_pid, profiles_path: profiles_path}} + else + # In production, FileSystem is not available + Logger.debug("ProfileWatcher: FileSystem not available, running in no-op mode") + {:ok, %{}} + end end @impl true diff --git a/priv/towerops_nif.so b/priv/towerops_nif.so deleted file mode 100755 index 1d8d81b6..00000000 Binary files a/priv/towerops_nif.so and /dev/null differ