Skip to content
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
27 changes: 27 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Ignore build artifacts
target
# Ignore deployment scripts and configs (unless you need them in the image)
deploy/
Dockerfile

.dockerignore
.git
.gitignore


# Ignore editor/project files
*.swp
*.swo
*.bak
*.tmp
*.log
.DS_Store
.idea/
.vscode/

# Ignore test and coverage outputs
coverage/

# Ignore OS-specific files
Thumbs.db
ehthumbs.db
14 changes: 9 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ Session.vim
.settings/
.vs/

# Log files
## Log files
*.log

# Environment
## Environment
*.env


Expand All @@ -48,7 +48,7 @@ build/
/src/tools/x/target
Cargo.lock

# Created by default with `src/ci/docker/run.sh`
## Created by default with `src/ci/docker/run.sh`
/obj/


Expand All @@ -58,15 +58,19 @@ __pycache__/
*$py.class


# Applications
## Applications
*.app
*.exe
*.war

# Large media files
## Large media files
*.mp4
*.tiff
*.avi
*.flv
*.mov
*.wmv

## Ignore the pcaps and certificates generated during integration tests
tests/integration/capture/*
tests/integration/cert/*
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["lightning-cli", "lightning-nf/omnipath/*", "utils/*"]
members = ["lightning-cli", "lightning-nf/omnipath/app", "tests/integration", "utils/*"]
resolver = "2"

[workspace.package]
Expand Down
2 changes: 1 addition & 1 deletion config/amfcfg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ configuration:
sd: 112233 # Slice Differentiator (3 bytes hex string, range: 000000~FFFFFF)
supportDnnList: # the DNN (Data Network Name) list supported by this AMF
- internet
nrfUri: http://103.227.96.139:3000 # a valid URI of NRF
nrfUri: http://10.0.0.4:8000 # a valid URI of NRF
security: # NAS security parameters
integrityOrder: # the priority of integrity algorithms
- NIA2
Expand Down
16 changes: 16 additions & 0 deletions deploy/base/Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM rust:1.88-slim-bookworm

LABEL maintainer="UnifyAir <support@unifyair.com>"

# Install build dependencies and cargo-chef
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
libclang-dev \
clang \
libsctp-dev

RUN cargo install cargo-chef

# Clean apt cache
RUN apt-get clean
Comment on lines +6 to +16
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Hardening & layer optimisation for builder image

  1. apt-get install without --no-install-recommends pulls unnecessary packages.
  2. apt-get clean alone leaves /var/lib/apt/lists behind, bloating the image.
  3. cargo install cargo-chef is unpinned; builds may break on future releases.

Suggested refinement:

-RUN apt-get update && apt-get install -y \
-    pkg-config \
-    libssl-dev \
-    libclang-dev \
-    clang \
-    libsctp-dev
-
-RUN cargo install cargo-chef
-
-# Clean apt cache
-RUN apt-get clean
+RUN set -eux; \
+    apt-get update; \
+    apt-get install -y --no-install-recommends \
+        pkg-config \
+        libssl-dev \
+        libclang-dev \
+        clang \
+        libsctp-dev; \
+    rm -rf /var/lib/apt/lists/*
+
+# Pin cargo-chef for reproducibility
+RUN cargo install cargo-chef --locked --version 0.1.64

This reduces size, improves reproducibility, and passes typical container-lint checks.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
libclang-dev \
clang \
libsctp-dev
RUN cargo install cargo-chef
# Clean apt cache
RUN apt-get clean
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
pkg-config \
libssl-dev \
libclang-dev \
clang \
libsctp-dev; \
rm -rf /var/lib/apt/lists/*
# Pin cargo-chef for reproducibility
RUN cargo install cargo-chef --locked --version 0.1.64
🧰 Tools
🪛 RuboCop (1.76.1)

[fatal] 6-6: unexpected token tIDENTIFIER
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)

(Lint/Syntax)


[fatal] 6-6: unexpected token tIDENTIFIER
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)

(Lint/Syntax)


[fatal] 7-7: unexpected token tIDENTIFIER
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)

(Lint/Syntax)


[fatal] 8-8: unexpected token tIDENTIFIER
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)

(Lint/Syntax)


[fatal] 9-9: unexpected token tIDENTIFIER
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)

(Lint/Syntax)


[fatal] 10-10: unexpected token tIDENTIFIER
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)

(Lint/Syntax)


[fatal] 16-16: unexpected token tIDENTIFIER
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)

(Lint/Syntax)

🤖 Prompt for AI Agents
In deploy/base/Dockerfile.builder around lines 6 to 16, the apt-get install
command should include the --no-install-recommends flag to avoid installing
unnecessary packages, reducing image size. After installing packages, remove the
/var/lib/apt/lists directory to clean up apt cache fully and prevent image
bloat. Additionally, pin the version of cargo-chef during installation to ensure
build reproducibility and prevent future breakage. Update the Dockerfile
accordingly to implement these improvements.

12 changes: 12 additions & 0 deletions deploy/base/Dockerfile.executor
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM debian:bookworm-slim AS executor

LABEL maintainer="UnifyAir <support@unifyair.com>"

# Install runtime dependencies
RUN apt-get update && apt-get install -y \
libssl3 \
ca-certificates \
libsctp1

# Clean apt cache
RUN apt-get clean
Comment on lines +6 to +12
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Combine RUN commands to optimize Docker layers

The apt-get update, install, and clean commands should be combined into a single RUN instruction to minimize layers and ensure the apt cache is cleaned in the same layer where it's created.

-# Install runtime dependencies
-RUN apt-get update && apt-get install -y \
-    libssl3 \
-    ca-certificates \
-    libsctp1 
-
-# Clean apt cache
-RUN apt-get clean
+# Install runtime dependencies
+RUN apt-get update && apt-get install -y \
+    libssl3 \
+    ca-certificates \
+    libsctp1 && \
+    apt-get clean && \
+    rm -rf /var/lib/apt/lists/*
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
RUN apt-get update && apt-get install -y \
libssl3 \
ca-certificates \
libsctp1
# Clean apt cache
RUN apt-get clean
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
libssl3 \
ca-certificates \
libsctp1 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
🤖 Prompt for AI Agents
In deploy/base/Dockerfile.executor around lines 6 to 12, the apt-get update,
install, and clean commands are split into separate RUN instructions, creating
unnecessary Docker layers and leaving the apt cache in intermediate layers.
Combine these commands into a single RUN instruction by chaining apt-get update,
apt-get install with the packages, and apt-get clean together using &&, so the
cache is cleaned in the same layer it was created, optimizing the image size and
layer count.

41 changes: 41 additions & 0 deletions deploy/gnbsim/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2021-present Open Networking Foundation
# Copyright 2024-present Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#

FROM golang:1.24.4-bookworm AS builder

RUN apt-get update && \
apt-get -y install --no-install-recommends \
vim \
ethtool \
git && \
apt-get clean

WORKDIR $GOPATH/src/gnbsim

ARG VERSION

# Clone the repository instead of copying context files
RUN git clone https://github.com/omec-project/gnbsim.git .
RUN git checkout v$VERSION
RUN make all
Comment on lines +7 to +23
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

ARG VERSION defaults to nothing – build breaks silently.

If the caller forgets to pass --build-arg VERSION=1.6.3, git checkout v errors late.

Provide a sane default and pin depth:

-ARG VERSION
+ARG VERSION=1.6.3
@@
-RUN git clone https://github.com/omec-project/gnbsim.git . 
-RUN git checkout v$VERSION
+RUN git clone --depth 1 --branch v$VERSION \
+     https://github.com/omec-project/gnbsim.git .
🤖 Prompt for AI Agents
In deploy/gnbsim/Dockerfile around lines 7 to 23, the ARG VERSION has no default
value, causing the git checkout command to fail silently if VERSION is not
passed during build. Fix this by assigning a sensible default value to VERSION
in the ARG declaration and modify the git clone command to use a shallow clone
with a pinned depth to improve build efficiency and reliability.


FROM alpine:3.22 AS gnbsim

LABEL maintainer="UnifyAir <support@unifyair.com>"

ARG DEBUG_TOOLS

RUN apk update && apk add --no-cache -U bash tcpdump

# Install debug tools ~ 50MB (if DEBUG_TOOLS is set to true)
RUN if [ "$DEBUG_TOOLS" = "true" ]; then \
apk update && apk add --no-cache -U gcompat vim strace net-tools curl netcat-openbsd bind-tools; \
fi

WORKDIR /gnbsim

# Copy executable
COPY --from=builder /go/src/gnbsim/bin /usr/local/bin/.
36 changes: 36 additions & 0 deletions deploy/omnipath/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# --- Chef base image
FROM builder-base AS chef
WORKDIR /unifyair

# --- Planner stage: generate recipe.json for dependencies
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

# --- Builder stage: build dependencies only (cached if Cargo.toml/Cargo.lock unchanged)
FROM chef AS builder
COPY --from=planner /unifyair/recipe.json recipe.json

# TODO: cleanup https://github.com/LukeMathWalker/cargo-chef/issues/271
COPY ./rust-toolchain.toml rust-toolchain.toml
ARG MODE
RUN if [ "$MODE" = "release" ]; then \
cargo chef cook --release --recipe-path recipe.json; \
else \
cargo chef cook --recipe-path recipe.json; \
fi
# --- Build application
COPY . .
ARG MODE
RUN if [ "$MODE" = "release" ]; then \
cargo build --release --package lightning-cli; \
else \
cargo build --package lightning-cli; \
fi

# --- Runtime stage
FROM executor-base AS executor
WORKDIR /unifyair
RUN mkdir -p /unifyair/config
ARG MODE
COPY --from=builder /unifyair/target/$MODE/lightning-cli /unifyair/lightning-cli
51 changes: 51 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
group "default" {
targets = [ "builder-base", "executor-base", "omnipath-debug"]
}

target "builder-base" {
context = "."
dockerfile = "deploy/base/Dockerfile.builder"
tags = ["unifyair/builder-base:latest"]
}

target "executor-base" {
context = "."
dockerfile = "deploy/base/Dockerfile.executor"
tags = ["unifyair/executor-base:latest"]
}

target "omnipath-debug" {
contexts = {
builder-base = "target:builder-base"
executor-base = "target:executor-base"
}
args = {
MODE = "debug"
}
dockerfile = "deploy/omnipath/Dockerfile"
tags = ["unifyair/omnipath-debug:latest"]
depends_on = ["builder-base", "executor-base"]
}

target "omnipath-release" {
contexts = {
builder-base = "target:builder-base"
executor-base = "target:executor-base"
}
args = {
MODE = "release"
}
dockerfile = "deploy/omnipath/Dockerfile"
tags = ["unifyair/omnipath-release:latest"]
depends_on = ["builder-base", "executor-base"]
}

target "gnbsim" {
dockerfile = "deploy/gnbsim/Dockerfile"
args = {
VERSION = "1.6.3"
DEBUG_TOOLS = "false"
}
tags = ["unifyair/omecproject-gnbsim:1.6.3"]
depends_on = ["builder-base", "executor-base"]
}
12 changes: 8 additions & 4 deletions lightning-cli/src/nf_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ impl App {
}

fn run<T: NfInstance>(config_path: &str) -> color_eyre::Result<()> {
install_tracing();
let nf_app: NfApp<T> = NfApp::new(config_path)?;
let runtime_config = nf_app.config.get_runtime_config();
let logging_config = nf_app.config.get_log_config();
Expand Down Expand Up @@ -83,7 +84,10 @@ pub enum NfError<T> {
#[source]
T,
),
#[error("RuntimeWithDeregistrationError: Runtime error and unable to deregister : \nMain App Error - {0} \nDeregisteration Error {1}")]
#[error(
"RuntimeWithDeregistrationError: Runtime error and unable to deregister : \nMain App \
Error - {0} \nDeregisteration Error {1}"
)]
RuntimeWithDeregistrationError(
#[backtrace]
#[source]
Expand Down Expand Up @@ -124,6 +128,7 @@ impl<T: NfInstance> NfApp<T> {
};
shutdown_token.cancel();
});
info!("Starting App Initialization");
let nf_app = T::initialize(self.config, self.cancellation_token)
.map_err(NfError::InitializationFailedError)?;
info!("App Initialized Successfully");
Expand All @@ -135,7 +140,7 @@ impl<T: NfInstance> NfApp<T> {
nf_app.register_nf().await?;
info!("Nf Registered Successfully");
nf_app.start().await?;
info!("Nf Started Successfully");
info!("Nf Execution Completed");
Ok(())
} => {
let dreg_res = nf_app.deregister_nf().await;
Expand All @@ -154,8 +159,7 @@ impl<T: NfInstance> NfApp<T> {
}
}

fn setup_logging(config: &LoggingConfig) -> Result<(), AppSetupError> {
install_tracing();
fn setup_logging(_config: &LoggingConfig) -> Result<(), AppSetupError> {
Ok(())
}

Expand Down
11 changes: 9 additions & 2 deletions lightning-nf/omnipath/app/src/builder/sbi/nrf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,23 @@ impl AppContext {
.iter()
.map(|e| e.plmn_id.clone())
.collect::<Vec<_>>();
let nf_profile = NfProfile1Unchecked {
let mut nf_profile = NfProfile1Unchecked {
nf_instance_id: config.nf_id,
nf_type: NfType::Amf,
nf_status: NfStatus::Registered,
amf_info: Some(amf_info),
plmn_list,
ipv4_addresses: vec![sbi.register_ipv4.into()],
nf_services: config.nf_services.clone(),
..Default::default()
};
match &sbi.register_ip {
std::net::IpAddr::V4(v4) => {
nf_profile.ipv4_addresses = vec![v4.into()];
}
std::net::IpAddr::V6(v6) => {
nf_profile.ipv6_addresses = vec![v6.into()];
}
}
trace!("NfProfile 1: {:#?}", nf_profile);
Ok(nf_profile.try_into()?)
}
Expand Down
Loading