build: obuspa agent

This commit is contained in:
leandrofars 2024-03-31 23:02:19 -03:00
parent 15bc760fbc
commit 716496073d
5 changed files with 89 additions and 2 deletions

1
agent/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
obuspa/

54
agent/Dockerfile Normal file
View File

@ -0,0 +1,54 @@
#
# file Dockerfile
#
# Base docker image with all required dependencies for OB-USP-A
#
# Based on Ubuntu 22.10 (Kinetic Kudu), which provides libmosquitto 2.0.11 and libwebsockets 4.1.6
# This image includes some basic compilation tools (automake, autoconf)
#
# One-liner execution line (straightforward build for OB-USP-A execution):
# > docker build -f Dockerfile -t obuspa:latest .
#
# Multi-stage builds execution lines (to tag build stages):
# 1) Create the build environment image:
# > docker build -f Dockerfile -t obuspa:build-env --target build-env .
# 2) Create the OB-USP-A image, then build the application
# > docker build -f Dockerfile -t obuspa:latest --target runner .
#
FROM ubuntu:lunar AS build-env
# Install dependencies
RUN apt-get update && apt-get -y install \
libssl-dev \
libcurl4-openssl-dev\
libsqlite3-dev \
libz-dev \
autoconf \
automake \
libtool \
libmosquitto-dev \
libwebsockets-dev \
pkg-config \
make \
&& apt-get clean
FROM build-env AS runner
ENV MAKE_JOBS=8
ENV OBUSPA_ARGS="-v4"
# Copy in all of the code
# Then compile, as root.
COPY obuspa /obuspa
RUN cd /obuspa/ && \
autoreconf -fi && \
./configure && \
make -j${MAKE_JOBS} && \
make install
# Then delete the code
# that's no longer needed
RUN rm -rf /obuspa
# Run obuspa with args expanded
CMD obuspa ${OBUSPA_ARGS}

33
agent/Makefile Normal file
View File

@ -0,0 +1,33 @@
.PHONY: help build release
DOCKER_USER ?= oktopusp
DOCKER_APP ?= obuspa
DOCKER_TAG ?= $(shell git log --format="%h" -n 1)
GIT_REPO ?= https://github.com/BroadbandForum/obuspa
.DEFAULT_GOAL := help
help:
@echo "Makefile arguments:"
@echo ""
@echo "DOCKER_USER - docker user to build image"
@echo "DOCKER_APP - docker image name"
@echo "DOCKER_TAG - docker image tag"
@echo ""
@echo "Makefile commands:"
@echo ""
@echo "build - docker image build"
@echo "release - tag image as latest and push to registry"
build:
if [ -d "obuspa" ]; then \
git -C obuspa pull; \
else \
git clone ${GIT_REPO} ; \
fi
@docker build -t ${DOCKER_USER}/${DOCKER_APP}:${DOCKER_TAG} -f Dockerfile .
release: build
@docker push ${DOCKER_USER}/${DOCKER_APP}:${DOCKER_TAG}
@docker tag ${DOCKER_USER}/${DOCKER_APP}:${DOCKER_TAG} ${DOCKER_USER}/${DOCKER_APP}:latest
@docker push ${DOCKER_USER}/${DOCKER_APP}:latest

View File

@ -33,7 +33,7 @@ Device.LocalAgent.Subscription.1.Persistent true
Device.LocalAgent.MTP.1.MQTT.ResponseTopicConfigured "oktopus/usp/v1/controller"
Device.LocalAgent.MTP.1.MQTT.Reference "Device.MQTT.Client.1"
Device.MQTT.Client.1.BrokerAddress "localhost"
Device.MQTT.Client.1.BrokerAddress "127.0.0.1"
Device.MQTT.Client.1.ProtocolVersion "5.0"
Device.MQTT.Client.1.BrokerPort "1883"
Device.MQTT.Client.1.TransportProtocol "TCP/IP"

View File

@ -1 +0,0 @@
obuspa -p -v 4 -r ./oktopus-mqtt-obuspa.txt -i lo