diff --git a/agent/.gitignore b/agent/.gitignore new file mode 100644 index 0000000..4ecdcdb --- /dev/null +++ b/agent/.gitignore @@ -0,0 +1 @@ +obuspa/ \ No newline at end of file diff --git a/agent/Dockerfile b/agent/Dockerfile new file mode 100644 index 0000000..2a09979 --- /dev/null +++ b/agent/Dockerfile @@ -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} diff --git a/agent/Makefile b/agent/Makefile new file mode 100644 index 0000000..7dd4d16 --- /dev/null +++ b/agent/Makefile @@ -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 \ No newline at end of file diff --git a/agent/oktopus-mqtt-obuspa.txt b/agent/oktopus-mqtt-obuspa.txt index f49caa0..c79d9bf 100644 --- a/agent/oktopus-mqtt-obuspa.txt +++ b/agent/oktopus-mqtt-obuspa.txt @@ -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" diff --git a/agent/run.sh b/agent/run.sh deleted file mode 100644 index 996e4a4..0000000 --- a/agent/run.sh +++ /dev/null @@ -1 +0,0 @@ -obuspa -p -v 4 -r ./oktopus-mqtt-obuspa.txt -i lo \ No newline at end of file