Home » free5GC containers/images

free5GC containers/images

Introduction

In this article we will go through the steps in preparing free5GC containers using Dockerfile.

Following this article, it is assumed that you already have a repository. Otherwise, you can follow our other article setting up a private repository

Preparing Container Images

The Base OS will be Ubuntu 20.04 (builder), Alpine linux is addedd (option) to keep the container size small.

FROM ubuntu:20.04 AS builder

LABEL maintainer="Subok Tech <subok.tech@gmail.com>"

ARG GIT_TAG=latest
LABEL name="subokf5gc" \
      version="${GIT_TAG}.ubuntu" \
      io.k8s.description="Image containing all build dependencies for free5gc."

RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
    apt-get install -y \
        autoconf \
        cmake \
        tzdata \
        gcc \
        git \
        g++ \
        gcc \
        libtool \
        pkg-config \
        libmnl-dev \
        libyaml-dev \
        apt-transport-https \
        ca-certificates \
        make \
        upx-ucl \
        net-tools \
        nano \
        nodejs \
        yarn \
        curl \
        gnupg* \
        wget && \
    apt-get clean && \
    curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
    curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
    echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
    apt-get update && \
    apt-get install -y nodejs yarn

# Clean apt cache
RUN apt-get clean
    
# Installing Golang
ARG GO_VERSION=1.14.4

WORKDIR /go
RUN wget https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \
    tar -C /usr/local -zxvf go${GO_VERSION}.linux-amd64.tar.gz && \
    mkdir -p {bin,pkg,src}

ENV GOPATH=/go
ENV GOROOT=/usr/local/go
ENV PATH=${PATH}:${GOPATH}/bin:${GOROOT}/bin
ENV GO111MODULE=on

WORKDIR /go/src

# Get Free5GC
RUN cd $GOPATH/src \
    && git clone --recursive -b v3.0.6 -j `nproc` https://github.com/free5gc/free5gc.git

# Build Free5GC NFs & WebUI
RUN cd $GOPATH/src/free5gc \
    && make all

# Alpine is used for debug purpose. You can use scratch for a smaller footprint.
FROM alpine
RUN apk update
RUN apk add bash nano net-tools tcpdump

WORKDIR /free5gc
RUN mkdir -p config/ support/TLS/ public

# Copy executables
COPY --from=builder /go/src/free5gc/bin/* ./
COPY --from=builder /go/src/free5gc/NFs/upf/build/bin/* ./
COPY --from=builder /go/src/free5gc/webconsole/bin/webconsole ./webui

# Copy static files (webui frontend)
COPY --from=builder /go/src/free5gc/webconsole/public ./public

# Copy linked libs
COPY --from=builder /go/src/free5gc/NFs/upf/build/updk/src/third_party/libgtp5gnl/lib/libgtp5gnl.so.0 ./
COPY --from=builder /go/src/free5gc/NFs/upf/build/utlt_logger/liblogger.so ./

# Copy configuration files (not used for now)
COPY --from=builder /go/src/free5gc/config/* ./config/
COPY --from=builder /go/src/free5gc/NFs/upf/build/config/* ./config/

# Copy default certificates (not used for now)
COPY --from=builder /go/src/free5gc/support/TLS/* ./support/TLS/
# Build free5GC base image

# Change to the dockerfile "Dockerfile" working directory
# e.g. cd f5gc-build-base/
#  
$ docker build .
$ docker ps -a
$ docker images
$ docker tag subokf5gc-alpine-base subok-docker-registry:5000/subokf5gc-alpine-base:3.0.6

# Push image to repository
$ docker push subok-docker-registry:5000/subokf5gc-alpine-base:3.0.6


Building free5GC containers

After the successful base container build, we can proceed building 5G core images. 

# Build AMF 
#
#Dockerfile
FROM subok-docker-registry:5000/subokf5gc-alpine-base:3.0.6 AS builder
FROM alpine:latest

LABEL description="Free5GC open source 5G Core Network" \
    version="Stage 3"

ENV F5GC_MODULE amf
ARG DEBUG_TOOLS

# Install debug tools ~ 100MB (if DEBUG_TOOLS is set to true)
RUN if [ "$DEBUG_TOOLS" = "true" ] ; then apk add -U vim nano strace net-tools curl netcat-openbsd ; fi

# Set working dir
WORKDIR /free5gc
RUN mkdir -p config/ log/ support/TLS/ ${F5GC_MODULE}/

# Copy executable and default certs
COPY --from=builder /free5gc/${F5GC_MODULE} ./${F5GC_MODULE}
COPY --from=builder /free5gc/support/TLS/${F5GC_MODULE}.pem ./support/TLS/
COPY --from=builder /free5gc/support/TLS/${F5GC_MODULE}.key ./support/TLS/

# Move to the binary path
WORKDIR /free5gc/${F5GC_MODULE}

# Config files volume
VOLUME [ "/free5gc/config" ]

# Certificates (if not using default) volume
VOLUME [ "/free5gc/support/TLS" ]

# Exposed ports
EXPOSE 8000
# Change to the dockerfile "Dockerfile" working directory
# e.g. cd  cd f5gc-amf/
#  
$ docker build .
$ docker commit $(docker ps -lq) subokf5gc-amf
$ docker tag subokf5gc-amf subok-docker-registry:5000/subokf5gc-amf

# Push image to repository
$ docker push subok-docker-registry:5000/subokf5gc-amf
# Build AUSF
#
#Dockerfile
FROM subok-docker-registry:5000/subokf5gc-alpine-base:3.0.6 AS builder
FROM alpine:latest

LABEL description="Free5GC open source 5G Core Network" \
    version="Stage 3"

ENV F5GC_MODULE ausf
ARG DEBUG_TOOLS

# Install debug tools ~ 100MB (if DEBUG_TOOLS is set to true)
RUN if [ "$DEBUG_TOOLS" = "true" ] ; then apk add -U vim strace net-tools curl netcat-openbsd ; fi

# Set working dir
WORKDIR /free5gc
RUN mkdir -p config/ log/ support/TLS/ ${F5GC_MODULE}/

# Copy executable and default certs
COPY --from=builder /free5gc/${F5GC_MODULE} ./${F5GC_MODULE}
COPY --from=builder /free5gc/support/TLS/${F5GC_MODULE}.pem ./support/TLS/
COPY --from=builder /free5gc/support/TLS/${F5GC_MODULE}.key ./support/TLS/

# Move to the binary path
WORKDIR /free5gc/${F5GC_MODULE}

# Config files volume
VOLUME [ "/free5gc/config" ]

# Certificates (if not using default) volume
VOLUME [ "/free5gc/support/TLS" ]

# Exposed ports
EXPOSE 8000
# Change to the dockerfile "Dockerfile" working directory
# e.g. cd  cd f5gc-ausf/
#  
$ docker build .
$ docker commit $(docker ps -lq) subokf5gc-ausf
$ docker tag subokf5gc-ausf subok-docker-registry:5000/subokf5gc-ausf

# Push image to repository
$ docker push subok-docker-registry:5000/subokf5gc-ausf
# Build NRF
#
#Dockerfile
FROM subok-docker-registry:5000/subokf5gc-alpine-base:3.0.6 AS builder
FROM alpine:latest

LABEL description="Free5GC open source 5G Core Network" \
    version="Stage 3"

ENV F5GC_MODULE nrf
ARG DEBUG_TOOLS

# Install debug tools ~ 100MB (if DEBUG_TOOLS is set to true)
RUN if [ "$DEBUG_TOOLS" = "true" ] ; then apk add -U vim strace net-tools curl netcat-openbsd ; fi

# Set working dir
WORKDIR /free5gc
RUN mkdir -p config/ log/ support/TLS/ ${F5GC_MODULE}/

# Copy executable and default certs
COPY --from=builder /free5gc/${F5GC_MODULE} ./${F5GC_MODULE}
COPY --from=builder /free5gc/support/TLS/${F5GC_MODULE}.pem ./support/TLS/
COPY --from=builder /free5gc/support/TLS/${F5GC_MODULE}.key ./support/TLS/

# Move to the binary path
WORKDIR /free5gc/${F5GC_MODULE}

# Config files volume
VOLUME [ "/free5gc/config" ]

# Certificates (if not using default) volume
VOLUME [ "/free5gc/support/TLS" ]

# Exposed ports
EXPOSE 8000
# Change to the dockerfile "Dockerfile" working directory
# e.g. cd  cd f5gc-nrf/
#  
$ docker build .
$ docker commit $(docker ps -lq) subokf5gc-nrf
$ docker tag subokf5gc-nrf subok-docker-registry:5000/subokf5gc-nrf

# Push image to repository
$ docker push subok-docker-registry:5000/subokf5gc-nrf
# Build NSSF
#
#Dockerfile
FROM subok-docker-registry:5000/subokf5gc-alpine-base:3.0.6 AS builder
FROM alpine:latest

LABEL description="Free5GC open source 5G Core Network" \
    version="Stage 3"

ENV F5GC_MODULE nssf
ARG DEBUG_TOOLS

# Install debug tools ~ 100MB (if DEBUG_TOOLS is set to true)
RUN if [ "$DEBUG_TOOLS" = "true" ] ; then apk add -U vim nano strace net-tools curl netcat-openbsd ; fi

# Set working dir
WORKDIR /free5gc
RUN mkdir -p config/ log/ support/TLS/ ${F5GC_MODULE}/

# Copy executable and default certs
COPY --from=builder /free5gc/${F5GC_MODULE} ./${F5GC_MODULE}
COPY --from=builder /free5gc/support/TLS/${F5GC_MODULE}.pem ./support/TLS/
COPY --from=builder /free5gc/support/TLS/${F5GC_MODULE}.key ./support/TLS/

# Move to the binary path
WORKDIR /free5gc/${F5GC_MODULE}

# Config files volume
VOLUME [ "/free5gc/config" ]

# Certificates (if not using default) volume
VOLUME [ "/free5gc/support/TLS" ]

# Exposed ports
EXPOSE 8000
# Change to the dockerfile "Dockerfile" working directory
# e.g. cd  cd f5gc-nssf/
#  
$ docker build .
$ docker commit $(docker ps -lq) subokf5gc-nssf
$ docker tag subokf5gc-nssf subok-docker-registry:5000/subokf5gc-nssf

# Push image to repository
$ docker push subok-docker-registry:5000/subokf5gc-nssf
# Build PCF
#
#Dockerfile
FROM subok-docker-registry:5000/subokf5gc-alpine-base:3.0.6 AS builder
FROM alpine:latest

LABEL description="Free5GC open source 5G Core Network" \
    version="Stage 3"

ENV F5GC_MODULE pcf
ARG DEBUG_TOOLS

# Install debug tools ~ 100MB (if DEBUG_TOOLS is set to true)
RUN if [ "$DEBUG_TOOLS" = "true" ] ; then apk add -U vim nano strace net-tools curl netcat-openbsd ; fi

# Set working dir
WORKDIR /free5gc
RUN mkdir -p config/ log/ support/TLS/ ${F5GC_MODULE}/

# Copy executable and default certs
COPY --from=builder /free5gc/${F5GC_MODULE} ./${F5GC_MODULE}
COPY --from=builder /free5gc/support/TLS/${F5GC_MODULE}.pem ./support/TLS/
COPY --from=builder /free5gc/support/TLS/${F5GC_MODULE}.key ./support/TLS/

# Move to the binary path
WORKDIR /free5gc/${F5GC_MODULE}

# Config files volume
VOLUME [ "/free5gc/config" ]

# Certificates (if not using default) volume
VOLUME [ "/free5gc/support/TLS" ]

# Exposed ports
EXPOSE 8000
# Change to the dockerfile "Dockerfile" working directory
# e.g. cd  cd f5gc-pcf/
#  
$ docker build .
$ docker commit $(docker ps -lq) subokf5gc-pcf
$ docker tag subokf5gc-pcf subok-docker-registry:5000/subokf5gc-pcf

# Push image to repository
$ docker push subok-docker-registry:5000/subokf5gc-pcf
# Build SMF
#
#Dockerfile
FROM subok-docker-registry:5000/subokf5gc-alpine-base:3.0.6 AS builder
FROM alpine:latest

LABEL description="Free5GC open source 5G Core Network" \
    version="Stage 3"

ENV F5GC_MODULE smf
ARG DEBUG_TOOLS

# Install debug tools ~ 100MB (if DEBUG_TOOLS is set to true)
RUN if [ "$DEBUG_TOOLS" = "true" ] ; then apk add -U vim nano strace net-tools curl netcat-openbsd ; fi

# Set working dir
WORKDIR /free5gc
RUN mkdir -p config/ log/ support/TLS/ ${F5GC_MODULE}/

# Copy executable and default certs
COPY --from=builder /free5gc/${F5GC_MODULE} ./${F5GC_MODULE}
COPY --from=builder /free5gc/support/TLS/${F5GC_MODULE}.pem ./support/TLS/
COPY --from=builder /free5gc/support/TLS/${F5GC_MODULE}.key ./support/TLS/

# Move to the binary path
WORKDIR /free5gc/${F5GC_MODULE}

# Config files volume
VOLUME [ "/free5gc/config" ]

# Certificates (if not using default) volume
VOLUME [ "/free5gc/support/TLS" ]

# Exposed ports
EXPOSE 8000
# Change to the dockerfile "Dockerfile" working directory
# e.g. cd  cd f5gc-smf/
#  
$ docker build .
$ docker commit $(docker ps -lq) subokf5gc-smf
$ docker tag subokf5gc-smf subok-docker-registry:5000/subokf5gc-smf

# Push image to repository
$ docker push subok-docker-registry:5000/subokf5gc-smf
# Build UDM
#
#Dockerfile
FROM subok-docker-registry:5000/subokf5gc-alpine-base:3.0.6 AS builder
FROM alpine:latest

LABEL description="Free5GC open source 5G Core Network" \
    version="Stage 3"

ENV F5GC_MODULE udm
ARG DEBUG_TOOLS

# Install debug tools ~ 100MB (if DEBUG_TOOLS is set to true)
RUN if [ "$DEBUG_TOOLS" = "true" ] ; then apk add -U vim nano strace net-tools curl netcat-openbsd ; fi

# Set working dir
WORKDIR /free5gc
RUN mkdir -p config/ log/ support/TLS/ ${F5GC_MODULE}/

# Copy executable and default certs
COPY --from=builder /free5gc/${F5GC_MODULE} ./${F5GC_MODULE}
COPY --from=builder /free5gc/support/TLS/${F5GC_MODULE}.pem ./support/TLS/
COPY --from=builder /free5gc/support/TLS/${F5GC_MODULE}.key ./support/TLS/

# Move to the binary path
WORKDIR /free5gc/${F5GC_MODULE}

# Config files volume
VOLUME [ "/free5gc/config" ]

# Certificates (if not using default) volume
VOLUME [ "/free5gc/support/TLS" ]

# Exposed ports
EXPOSE 8000
# Change to the dockerfile "Dockerfile" working directory
# e.g. cd  cd f5gc-udm/
#  
$ docker build .
$ docker commit $(docker ps -lq) subokf5gc-udm
$ docker tag subokf5gc-udm subok-docker-registry:5000/subokf5gc-udm

# Push image to repository
$ docker push subok-docker-registry:5000/subokf5gc-udm
# Build UDR
#
#Dockerfile
FROM subok-docker-registry:5000/subokf5gc-alpine-base:3.0.6 AS builder
FROM alpine:latest

LABEL description="Free5GC open source 5G Core Network" \
    version="Stage 3"

ENV F5GC_MODULE udr
ARG DEBUG_TOOLS

# Install debug tools ~ 100MB (if DEBUG_TOOLS is set to true)
RUN if [ "$DEBUG_TOOLS" = "true" ] ; then apk add -U vim strace net-tools curl netcat-openbsd ; fi

# Set working dir
WORKDIR /free5gc
RUN mkdir -p config/ log/ support/TLS/ ${F5GC_MODULE}/

# Copy executable and default certs
COPY --from=builder /free5gc/${F5GC_MODULE} ./${F5GC_MODULE}
COPY --from=builder /free5gc/support/TLS/${F5GC_MODULE}.pem ./support/TLS/
COPY --from=builder /free5gc/support/TLS/${F5GC_MODULE}.key ./support/TLS/

# Move to the binary path
WORKDIR /free5gc/${F5GC_MODULE}

# Config files volume
VOLUME [ "/free5gc/config" ]

# Certificates (if not using default) volume
VOLUME [ "/free5gc/support/TLS" ]

# Exposed ports
EXPOSE 8000
# Change to the dockerfile "Dockerfile" working directory
# e.g. cd  cd f5gc-udr/
#  
$ docker build .
$ docker commit $(docker ps -lq) subokf5gc-udr
$ docker tag subokf5gc-udr subok-docker-registry:5000/subokf5gc-udr

# Push image to repository
$ docker push subok-docker-registry:5000/subokf5gc-udr

Building UPF Base Image

# Build UPF Base images
#
#Dockerfile
FROM ubuntu:20.04 AS builder

LABEL maintainer="Subok Tech <subok.tech@gmail.com>"

ARG GIT_TAG=latest
LABEL name="subokf5gc UPF" \
      version="${GIT_TAG}.ubuntu" \
      io.k8s.description="Image containing all build dependencies for UPF."

RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
    apt-get install -y \
        autoconf \
        cmake \
        tzdata \
        gcc \
        git \
        g++ \
        gcc \
        libtool \
        pkg-config \
        libmnl-dev \
        libyaml-dev \
        apt-transport-https \
        ca-certificates \
        make \
        upx-ucl \
        net-tools \
        nano \
        nodejs \
        yarn \
        curl \
        gnupg* \
        wget && \
    apt-get clean 
#     curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
#     curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
#     echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
#     apt-get update && \
#     apt-get install -y nodejs yarn

# Clean apt cache
RUN apt-get clean
    
# Installing Golang
ARG GO_VERSION=1.14.4

WORKDIR /go
RUN wget https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \
    tar -C /usr/local -zxvf go${GO_VERSION}.linux-amd64.tar.gz && \
    mkdir -p {bin,pkg,src}

ENV GOPATH=/go
ENV GOROOT=/usr/local/go
ENV PATH=${PATH}:${GOPATH}/bin:${GOROOT}/bin
ENV GO111MODULE=on

WORKDIR /go/src

# Get UPF and Build
RUN cd $GOPATH/src \
    && go get github.com/sirupsen/logrus \
    && git clone https://github.com/free5gc/upf.git \
    && cd gtp5g \
    && make \
    && make install \
    && mkdir build \
    && cd build \
    && cmake .. \
    && make -j`nproc`




# Change to the dockerfile "Dockerfile" working directory
# e.g. cd  cd f5gc-upf-base/
#  
$ docker build .
$ docker commit $(docker ps -lq) subokf5gc-upf-base
$ docker tag subokf5gc-upf-base subok-docker-registry:5000/subokf5gc-upf-base

# Push image to repository
$ docker push subok-docker-registry:5000/subokf5gc-upf-base

Building UPF Container Image

# Build UPF images
#
#Dockerfile
FROM subok-docker-registry:5000/subokf5gc-alpine-base:3.0.6 AS builder
FROM bitnami/minideb:stretch

LABEL description="Free5GC open source 5G Core Network" \
    version="Stage 3"

ENV F5GC_MODULE free5gc-upfd
ENV DEBIAN_FRONTEND noninteractive
ARG DEBUG_TOOLS

# Install debug tools ~ 100MB (if DEBUG_TOOLS is set to true)
RUN if [ "$DEBUG_TOOLS" = "true" ] ; then apt-get update && apt-get install -y vim nano strace net-tools iputils-ping curl netcat ; fi

# Install UPF dependencies
RUN apt-get update \
    && apt-get install -y libmnl0 libyaml-0-2 iproute2 iptables \
    && apt-get clean

# Set working dir
WORKDIR /free5gc
RUN mkdir -p ${F5GC_MODULE}/config/

# Copy executable and default configuration
COPY --from=builder /free5gc/${F5GC_MODULE} ./${F5GC_MODULE}/

# Copy linked libs
COPY --from=builder /free5gc/libgtp5gnl.so.0 /usr/local/lib
COPY --from=builder /free5gc/liblogger.so /usr/local/lib

# Move to the executable location
WORKDIR /free5gc/${F5GC_MODULE}

# Update links
RUN ldconfig
# Change to the dockerfile "Dockerfile" working directory
# e.g. cd  cd f5gc-upf/
#  
$ docker build .
$ docker commit $(docker ps -lq) subokf5gc-upf
$ docker tag subokf5gc-upf subok-docker-registry:5000/subokf5gc-upf

# Push image to repository
$ docker push subok-docker-registry:5000/subokf5gc-upf

Building WebUI Container Image

# Build UPF images
#
#Dockerfile
FROM ubuntu:20.04 AS builder

LABEL maintainer="Subok Tech <subok.tech@gmail.com>"

ARG GIT_TAG=latest
LABEL name="subokf5gc" \
      version="${GIT_TAG}.ubuntu" \
      io.k8s.description="Image containing all build dependencies for free5gc."

RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
    apt-get install -y \
        autoconf \
        cmake \
        tzdata \
        gcc \
        git \
        g++ \
        gcc \
        libtool \
        pkg-config \
        libmnl-dev \
        libyaml-dev \
        apt-transport-https \
        ca-certificates \
        make \
        upx-ucl \
        net-tools \
        nano \
        nodejs \
        yarn \
        curl \
        gnupg* \
        wget && \
    apt-get clean && \
    curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
    curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
    echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
    apt-get update && \
    apt-get install -y nodejs yarn

# Clean apt cache
RUN apt-get clean
    
# Installing Golang
ARG GO_VERSION=1.14.4

WORKDIR /go
RUN wget https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \
    tar -C /usr/local -zxvf go${GO_VERSION}.linux-amd64.tar.gz && \
    mkdir -p {bin,pkg,src}

ENV GOPATH=/go
ENV GOROOT=/usr/local/go
ENV PATH=${PATH}:${GOPATH}/bin:${GOROOT}/bin
ENV GO111MODULE=on

WORKDIR /go/src

# Get Free5GC
RUN cd $GOPATH/src \
    && git clone --recursive -b v3.0.6 -j `nproc` https://github.com/free5gc/free5gc.git

# Build Free5GC WebUI
RUN cd $GOPATH/src/free5gc \
    && make webconsole

###########
# ENV F5GC_MODULE webui
# ARG DEBUG_TOOLS
# 
# Install debug tools ~ 100MB (if DEBUG_TOOLS is set to true)
#  RUN if [ "$DEBUG_TOOLS" = "true" ] ; then apk add -U vim strace net-tools nano curl netcat-openbsd ; fi

# Set working dir
#  WORKDIR /free5gc
#  RUN mkdir -p config/ webconsole/public

# Copy executable, frontend static files and default configuration
#  COPY --from=builder /free5gc/${F5GC_MODULE} ./webconsole
#  COPY --from=builder /free5gc/public ./webconsole/public

# Move to the executable location
#  WORKDIR /free5gc/webconsole

# Config files volume
#  VOLUME [ "/free5gc/config" ]

# ENTRYPOINT [ "./webui" ]

# WebUI uses the port 5000
EXPOSE 5000
# Change to the dockerfile "Dockerfile" working directory
# e.g. cd  cd f5gc-webui/
#  
$ docker build .
$ docker commit $(docker ps -lq) subokf5gc-webui
$ docker tag subokf5gc-webui subok-docker-registry:5000/subokf5gc-webui

# Push image to repository
$ docker push subok-docker-registry:5000/subokf5gc-webui

Leave a Reply

Your email address will not be published. Required fields are marked *