-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bdd76ab
commit 00e0f03
Showing
8 changed files
with
237 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Docker Image CI - NRF | ||
|
||
on: | ||
schedule: | ||
- cron: '00 04 * * Sun' | ||
push: | ||
paths: | ||
- 'nrf/**' | ||
branches: [ master ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Get current date | ||
id: date | ||
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | ||
- | ||
name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
${{ vars.DOCKERHUB_USERNAME }}/${{ vars.DOCKERHUB_REPO_NRF }} | ||
tags: | | ||
type=raw,enable=true,priority=100,prefix=bookworm-,suffix=-slim,value={{date 'YYYY-MM-DD'}}-{{sha}} | ||
flavor: | | ||
latest=true | ||
prefix= | ||
suffix= | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- | ||
name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ vars.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: "{{defaultContext}}:nrf" | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
build-args: BUILD_DATE=${{ steps.date.outputs.date }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
platforms: linux/amd64 | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2024 Louis Royer. All rights reserved. | ||
# Use of this source code is governed by a MIT-style license that can be | ||
# found in the LICENSE file. | ||
# SPDX-License-Identifier: MIT | ||
|
||
FROM golang:1.21 AS builder | ||
ARG COMMIT=26fb5a1a5a60ce87127862a14c3727dcca161fde | ||
RUN : ${COMMIT:? Missing build-arg COMMIT.} && go install github.com/free5gc/nrf/cmd@${COMMIT} | ||
|
||
|
||
FROM louisroyer/base-irit:latest | ||
|
||
LABEL maintainer="Louis Royer <[email protected]>" \ | ||
org.opencontainers.image.authors="Louis Royer <[email protected]>" \ | ||
org.opencontainers.image.source="https://github.com/louisroyer-docker/free5gc" | ||
|
||
# Used to disable caching of next steps, if not build since 1 day, | ||
# allowing to search and apply security upgrades | ||
ARG BUILD_DATE="" | ||
|
||
RUN apt-get update -q && DEBIAN_FRONTEND=non-interactive apt-get install -qy --no-install-recommends --no-install-suggests \ | ||
docker-setup \ | ||
&& apt-get upgrade -qy \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY --from=builder /go/bin/cmd /usr/local/bin/nrf | ||
|
||
COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh | ||
ENV ROUTING_SCRIPT="docker-setup" | ||
|
||
COPY ./template-script.sh /usr/local/bin/template-script.sh | ||
ENV TEMPLATE_SCRIPT="template-script.sh" | ||
ENV TEMPLATE_SCRIPT_ARGS="" | ||
|
||
COPY ./template-nrf.yaml /etc/free5gc/template-nrf.yaml | ||
ENV CONFIG_FILE="/etc/free5gc/nrf.yaml" | ||
ENV CONFIG_TEMPLATE="/etc/free5gc/template-nrf.yaml" | ||
|
||
ENTRYPOINT ["entrypoint.sh"] | ||
CMD ["--help"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2024 Louis Royer. All rights reserved. | ||
# Use of this source code is governed by a MIT-style license that can be | ||
# found in the LICENSE file. | ||
# SPDX-License-Identifier: MIT | ||
|
||
set -e | ||
savedargs=( "$@" ) | ||
config_opt=1 | ||
while [ $# -gt 0 ]; do | ||
if [[ $1 == "--config" || $1 == "-c" ]]; then | ||
config_opt=0 | ||
fi | ||
shift | ||
done | ||
set -- "${savedargs[@]}" | ||
|
||
if [[ -n "${CONFIG_TEMPLATE}" && -n "${CONFIG_FILE}" ]]; then | ||
if [ -n "${TEMPLATE_SCRIPT}" ]; then | ||
echo "[$(date --iso-8601=s)] Running ${TEMPLATE_SCRIPT}${TEMPLATE_SCRIPT_ARGS:+ }${TEMPLATE_SCRIPT_ARGS} for building ${CONFIG_FILE} from ${CONFIG_TEMPLATE}." > /dev/stderr | ||
"$TEMPLATE_SCRIPT" "$TEMPLATE_SCRIPT_ARGS" | ||
fi | ||
else | ||
config_opt=0 | ||
fi | ||
|
||
if [ -n "${ROUTING_SCRIPT}" ]; then | ||
"${ROUTING_SCRIPT}" & | ||
fi | ||
|
||
if [[ $config_opt -eq 1 ]]; then | ||
exec nrf --config "$CONFIG_FILE" "$@" | ||
else | ||
exec nrf "$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
info: | ||
version: 1.0.1 | ||
description: NRF initial local configuration | ||
|
||
configuration: | ||
MongoDBName: %MONGO_NAME # database name in MongoDB | ||
MongoDBUrl: mongodb://%MONGO_HOST:%MONGO_PORT # a valid URL of the mongodb | ||
sbi: # Service-based interface information | ||
scheme: http # the protocol for sbi (http or https) | ||
registerIPv4: %SBI_REGISTER_IP # IP used to serve NFs or register to another NRF | ||
bindingIPv4: %SBI_BINDING_IP # IP used to bind the service | ||
port: %SBI_BINDING_PORT # port used to bind the service | ||
tls: | ||
pem: config/TLS/nrf.pem | ||
key: config/TLS/nrf.key | ||
DefaultPlmnId: | ||
mcc: %MCC # Mobile Country Code (3 digits string, digit: 0~9) | ||
mnc: %MNC # Mobile Network Code (2 or 3 digits string, digit: 0~9) | ||
serviceNameList: # the SBI services provided by this NRF, refer to TS 29.510 | ||
- nnrf-nfm # Nnrf_NFManagement service | ||
- nnrf-disc # Nnrf_NFDiscovery service | ||
|
||
# the kind of log output | ||
# debugLevel: how detailed to output, value: trace, debug, info, warn, error, fatal, panic | ||
# ReportCaller: enable the caller report or not, value: true or false | ||
logger: | ||
NRF: | ||
debugLevel: info | ||
ReportCaller: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2024 Louis Royer. All rights reserved. | ||
# Use of this source code is governed by a MIT-style license that can be | ||
# found in the LICENSE file. | ||
# SPDX-License-Identifier: MIT | ||
|
||
set -e | ||
if [ -z "$MONGO_HOST" ]; then | ||
echo "Missing mandatory environment variable (MONGO_HOST)." > /dev/stderr | ||
exit 1 | ||
fi | ||
if [ -z "$SBI_REGISTER_IP" ]; then | ||
echo "Missing mandatory environment variable (SBI_REGISTER_IP)." > /dev/stderr | ||
exit 1 | ||
fi | ||
if [ -z "$SBI_BINDING_IP" ]; then | ||
echo "Missing mandatory environment variable (SBI_BINDING_IP)." > /dev/stderr | ||
exit 1 | ||
fi | ||
|
||
awk \ | ||
-v MONGO_HOST="${MONGO_HOST}" \ | ||
-v MONGO_PORT="${MONGO_PORT:-27017}" \ | ||
-v MONGO_NAME="${MONGO_NAME:-free5gc}" \ | ||
-v SBI_REGISTER_IP="${SBI_REGISTER_IP}" \ | ||
-v SBI_BINDING_IP="${SBI_BINDING_IP}" \ | ||
-v SBI_BINDING_PORT="${SBI_BINDING_PORT:-8000}" \ | ||
-v MCC="${MCC:-001}" \ | ||
-v MNC="${MNC:-01}" \ | ||
'{ | ||
sub(/%MONGO_HOST/, MONGO_HOST); | ||
sub(/%MONGO_PORT/, MONGO_PORT); | ||
sub(/%MONGO_NAME/, MONGO_NAME); | ||
sub(/%SBI_REGISTER_IP/, SBI_REGISTER_IP); | ||
sub(/%SBI_BINDING_IP/, SBI_BINDING_IP); | ||
sub(/%SBI_BINDING_PORT/, SBI_BINDING_PORT); | ||
sub(/%MCC/, MCC); | ||
sub(/%MNC/, MNC); | ||
print; | ||
}' \ | ||
"${CONFIG_TEMPLATE}" > "${CONFIG_FILE}" |