From 95beac7d346c609e32fcd84d875a3610a1525e22 Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Thu, 8 Sep 2022 22:30:53 -0700 Subject: [PATCH] Update to v2.7.0 Signed-off-by: stephb9959 --- microservice_sample_cpp/Dockerfile | 122 ++++++++++++++++++ microservice_sample_cpp/docker-entrypoint.sh | 52 ++++++++ .../ow_helloworld.properties | 2 +- .../ow_helloworld.properties.tmpl | 92 +++++++++++++ 4 files changed, 267 insertions(+), 1 deletion(-) create mode 100644 microservice_sample_cpp/Dockerfile create mode 100755 microservice_sample_cpp/docker-entrypoint.sh create mode 100644 microservice_sample_cpp/ow_helloworld.properties.tmpl diff --git a/microservice_sample_cpp/Dockerfile b/microservice_sample_cpp/Dockerfile new file mode 100644 index 0000000..06b1ce6 --- /dev/null +++ b/microservice_sample_cpp/Dockerfile @@ -0,0 +1,122 @@ +ARG ALPINE_VERSION=3.16.2 +ARG POCO_VERSION=poco-tip-v1 +ARG FMTLIB_VERSION=9.0.0 +ARG CPPKAFKA_VERSION=tip-v1 +ARG JSON_VALIDATOR_VERSION=2.1.0 + +FROM alpine:$ALPINE_VERSION AS build-base + +RUN apk add --update --no-cache \ + make cmake g++ git \ + postgresql-dev mariadb-dev \ + librdkafka-dev boost-dev openssl-dev \ + zlib-dev nlohmann-json + +FROM build-base AS poco-build + +ARG POCO_VERSION +ADD https://api.github.com/repos/AriliaWireless/poco/git/refs/tags/${POCO_VERSION} version.json +RUN git clone https://github.com/AriliaWireless/poco --branch ${POCO_VERSION} /poco + +WORKDIR /poco +RUN mkdir cmake-build +WORKDIR cmake-build +RUN cmake .. +RUN cmake --build . --config Release -j8 +RUN cmake --build . --target install + +FROM build-base AS fmtlib-build + +ARG FMTLIB_VERSION +ADD https://api.github.com/repos/fmtlib/fmt/git/refs/tags/${FMTLIB_VERSION} version.json +RUN git clone https://github.com/fmtlib/fmt --branch ${FMTLIB_VERSION} /fmtlib + +WORKDIR /fmtlib +RUN mkdir cmake-build +WORKDIR cmake-build +RUN cmake .. +RUN make +RUN make install + +FROM build-base AS cppkafka-build + +ARG CPPKAFKA_VERSION +ADD https://api.github.com/repos/AriliaWireless/cppkafka/git/refs/tags/${CPPKAFKA_VERSION} version.json +RUN git clone https://github.com/AriliaWireless/cppkafka --branch ${CPPKAFKA_VERSION} /cppkafka + +WORKDIR /cppkafka +RUN mkdir cmake-build +WORKDIR cmake-build +RUN cmake .. +RUN cmake --build . --config Release -j8 +RUN cmake --build . --target install + +FROM build-base AS json-schema-validator-build + +ARG JSON_VALIDATOR_VERSION +ADD https://api.github.com/repos/pboettch/json-schema-validator/git/refs/tags/${JSON_VALIDATOR_VERSION} version.json +RUN git clone https://github.com/pboettch/json-schema-validator --branch ${JSON_VALIDATOR_VERSION} /json-schema-validator + +WORKDIR /json-schema-validator +RUN mkdir cmake-build +WORKDIR cmake-build +RUN cmake .. +RUN make +RUN make install + +FROM build-base AS ow_helloworld-build + +ADD CMakeLists.txt build /ow_helloworld/ +ADD cmake /ow_helloworld/cmake +ADD src /ow_helloworld/src +ADD .git /ow_helloworld/.git + +COPY --from=poco-build /usr/local/include /usr/local/include +COPY --from=poco-build /usr/local/lib /usr/local/lib +COPY --from=cppkafka-build /usr/local/include /usr/local/include +COPY --from=cppkafka-build /usr/local/lib /usr/local/lib +COPY --from=json-schema-validator-build /usr/local/include /usr/local/include +COPY --from=json-schema-validator-build /usr/local/lib /usr/local/lib +COPY --from=fmtlib-build /usr/local/include /usr/local/include +COPY --from=fmtlib-build /usr/local/lib /usr/local/lib + +WORKDIR /ow_helloworld +RUN mkdir cmake-build +WORKDIR /ow_helloworld/cmake-build +RUN cmake .. +RUN cmake --build . --config Release -j8 + +FROM alpine:$ALPINE_VERSION + +ENV OWHELLOWORLD_USER=ow_helloworld \ + OWHELLOWORLD_ROOT=/ow_helloworld-data \ + OWHELLOWORLD_CONFIG=/ow_helloworld-data + +RUN addgroup -S "OWHELLOWORLD_USER" && \ + adduser -S -G "OWHELLOWORLD_USER" "OWHELLOWORLD_USER" + +RUN mkdir /openwifi +RUN mkdir -p "$OWHELLOWORLD_ROOT" "$OWHELLOWORLD_CONFIG" && \ + chown "$OWHELLOWORLD_USER": "$OWHELLOWORLD_ROOT" "$OWHELLOWORLD_CONFIG" + +RUN apk add --update --no-cache librdkafka su-exec gettext ca-certificates bash jq curl \ + mariadb-connector-c libpq unixodbc postgresql-client + +COPY readiness_check /readiness_check +COPY test_scripts/curl/cli /cli + +COPY ow_helloworld.properties.tmpl / +COPY docker-entrypoint.sh / +COPY wait-for-postgres.sh / +COPY rtty_ui /dist/rtty_ui +RUN wget https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-ucentral-deploy/main/docker-compose/certs/restapi-ca.pem \ + -O /usr/local/share/ca-certificates/restapi-ca-selfsigned.pem + +COPY --from=ow_helloworld-build /ow_helloworld/cmake-build/ow_helloworld /openwifi/ow_helloworld +COPY --from=cppkafka-build /cppkafka/cmake-build/src/lib /usr/local/lib/ +COPY --from=poco-build /poco/cmake-build/lib /usr/local/lib + +EXPOSE 16051 16151 17051 + +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["/openwifi/ow_helloworld"] diff --git a/microservice_sample_cpp/docker-entrypoint.sh b/microservice_sample_cpp/docker-entrypoint.sh new file mode 100755 index 0000000..2b0f8c0 --- /dev/null +++ b/microservice_sample_cpp/docker-entrypoint.sh @@ -0,0 +1,52 @@ +#!/bin/sh +set -e + +if [ "$SELFSIGNED_CERTS" = 'true' ]; then + update-ca-certificates +fi + +if [[ "$TEMPLATE_CONFIG" = 'true' ]]; then + RESTAPI_HOST_ROOTCA=${RESTAPI_HOST_ROOTCA:-"\$OWHELLOWORLD_ROOT/certs/restapi-ca.pem"} \ + RESTAPI_HOST_PORT=${RESTAPI_HOST_PORT:-"16051"} \ + RESTAPI_HOST_CERT=${RESTAPI_HOST_CERT:-"\$OWHELLOWORLD_ROOT/certs/restapi-cert.pem"} \ + RESTAPI_HOST_KEY=${RESTAPI_HOST_KEY:-"\$OWHELLOWORLD_ROOT/certs/restapi-key.pem"} \ + RESTAPI_HOST_KEY_PASSWORD=${RESTAPI_HOST_KEY_PASSWORD:-"mypassword"} \ + INTERNAL_RESTAPI_HOST_ROOTCA=${INTERNAL_RESTAPI_HOST_ROOTCA:-"\$OWHELLOWORLD_ROOT/certs/restapi-ca.pem"} \ + INTERNAL_RESTAPI_HOST_PORT=${INTERNAL_RESTAPI_HOST_PORT:-"17051"} \ + INTERNAL_RESTAPI_HOST_CERT=${INTERNAL_RESTAPI_HOST_CERT:-"\$OWHELLOWORLD_ROOT/certs/restapi-cert.pem"} \ + INTERNAL_RESTAPI_HOST_KEY=${INTERNAL_RESTAPI_HOST_KEY:-"\$OWHELLOWORLD_ROOT/certs/restapi-key.pem"} \ + INTERNAL_RESTAPI_HOST_KEY_PASSWORD=${INTERNAL_RESTAPI_HOST_KEY_PASSWORD:-"mypassword"} \ + SERVICE_KEY=${SERVICE_KEY:-"\$OWHELLOWORLD_ROOT/certs/restapi-key.pem"} \ + SERVICE_KEY_PASSWORD=${SERVICE_KEY_PASSWORD:-"mypassword"} \ + SYSTEM_DATA=${SYSTEM_DATA:-"\$OWHELLOWORLD_ROOT/data"} \ + SYSTEM_URI_PRIVATE=${SYSTEM_URI_PRIVATE:-"https://localhost:17051"} \ + SYSTEM_URI_PUBLIC=${SYSTEM_URI_PUBLIC:-"https://myhost.domand.com:16051"} \ + SYSTEM_URI_UI=${SYSTEM_URI_UI:-"http://myui.domain.com"} \ + KAFKA_ENABLE=${KAFKA_ENABLE:-"true"} \ + KAFKA_BROKERLIST=${KAFKA_BROKERLIST:-"localhost:9092"} \ + KAFKA_SSL_CA_LOCATION=${KAFKA_SSL_CA_LOCATION:-""} \ + KAFKA_SSL_CERTIFICATE_LOCATION=${KAFKA_SSL_CERTIFICATE_LOCATION:-""} \ + KAFKA_SSL_KEY_LOCATION=${KAFKA_SSL_KEY_LOCATION:-""} \ + KAFKA_SSL_KEY_PASSWORD=${KAFKA_SSL_KEY_PASSWORD:-""} \ + STORAGE_TYPE=${STORAGE_TYPE:-"sqlite"} \ + STORAGE_TYPE_POSTGRESQL_HOST=${STORAGE_TYPE_POSTGRESQL_HOST:-"localhost"} \ + STORAGE_TYPE_POSTGRESQL_USERNAME=${STORAGE_TYPE_POSTGRESQL_USERNAME:-"owhelloworld"} \ + STORAGE_TYPE_POSTGRESQL_PASSWORD=${STORAGE_TYPE_POSTGRESQL_PASSWORD:-"owhelloworld"} \ + STORAGE_TYPE_POSTGRESQL_DATABASE=${STORAGE_TYPE_POSTGRESQL_DATABASE:-"owhelloworld"} \ + STORAGE_TYPE_POSTGRESQL_PORT=${STORAGE_TYPE_POSTGRESQL_PORT:-"5432"} \ + STORAGE_TYPE_MYSQL_HOST=${STORAGE_TYPE_MYSQL_HOST:-"localhost"} \ + STORAGE_TYPE_MYSQL_USERNAME=${STORAGE_TYPE_MYSQL_USERNAME:-"owhelloworld"} \ + STORAGE_TYPE_MYSQL_PASSWORD=${STORAGE_TYPE_MYSQL_PASSWORD:-"owhelloworld"} \ + STORAGE_TYPE_MYSQL_DATABASE=${STORAGE_TYPE_MYSQL_DATABASE:-"owhelloworld"} \ + STORAGE_TYPE_MYSQL_PORT=${STORAGE_TYPE_MYSQL_PORT:-"3306"} \ + envsubst < /ow_helloworld.properties.tmpl > $OWHELLOWORLD_CONFIG/ow_helloworld.properties +fi + +if [ "$1" = '/openwifi/ow_helloworld' -a "$(id -u)" = '0' ]; then + if [ "$RUN_CHOWN" = 'true' ]; then + chown -R "$OWHELLOWORLD_USER": "$OWHELLOWORLD_ROOT" "$OWHELLOWORLD_CONFIG" + fi + exec su-exec "$OWHELLOWORLD_USER" "$@" +fi + +exec "$@" diff --git a/microservice_sample_cpp/ow_helloworld.properties b/microservice_sample_cpp/ow_helloworld.properties index 03505ea..82325ac 100644 --- a/microservice_sample_cpp/ow_helloworld.properties +++ b/microservice_sample_cpp/ow_helloworld.properties @@ -43,7 +43,7 @@ openwifi.system.commandchannel = /tmp/app.owhelloworld # NLB Support # alb.enable = true -alb.port = 16102 +alb.port = 16151 # # Kafka diff --git a/microservice_sample_cpp/ow_helloworld.properties.tmpl b/microservice_sample_cpp/ow_helloworld.properties.tmpl new file mode 100644 index 0000000..def1911 --- /dev/null +++ b/microservice_sample_cpp/ow_helloworld.properties.tmpl @@ -0,0 +1,92 @@ +# +# REST API access +# +openwifi.restapi.host.0.backlog = 100 +openwifi.restapi.host.0.security = relaxed +openwifi.restapi.host.0.rootca = ${RESTAPI_HOST_ROOTCA} +openwifi.restapi.host.0.address = * +openwifi.restapi.host.0.port = ${RESTAPI_HOST_PORT} +openwifi.restapi.host.0.cert = ${RESTAPI_HOST_CERT} +openwifi.restapi.host.0.key = ${RESTAPI_HOST_KEY} +openwifi.restapi.host.0.key.password = ${RESTAPI_HOST_KEY_PASSWORD} + +openwifi.internal.restapi.host.0.backlog = 100 +openwifi.internal.restapi.host.0.security = relaxed +openwifi.internal.restapi.host.0.rootca = ${INTERNAL_RESTAPI_HOST_ROOTCA} +openwifi.internal.restapi.host.0.address = * +openwifi.internal.restapi.host.0.port = ${INTERNAL_RESTAPI_HOST_PORT} +openwifi.internal.restapi.host.0.cert = ${INTERNAL_RESTAPI_HOST_CERT} +openwifi.internal.restapi.host.0.key = ${INTERNAL_RESTAPI_HOST_KEY} +openwifi.internal.restapi.host.0.key.password = ${INTERNAL_RESTAPI_HOST_KEY_PASSWORD} + +# +# Generic section that all microservices must have +# +openwifi.service.key = ${SERVICE_KEY} +openwifi.service.key.password = ${SERVICE_KEY_PASSWORD} +openwifi.system.data = ${SYSTEM_DATA} +openwifi.system.debug = true +openwifi.system.uri.private = ${SYSTEM_URI_PRIVATE} +openwifi.system.uri.public = ${SYSTEM_URI_PUBLIC} +openwifi.system.uri.ui = ${SYSTEM_URI_UI} +openwifi.system.commandchannel = /tmp/app.ucentralgw + +############################# +# Generic information for all micro services +############################# +# +# NLB Support +# +alb.enable = true +alb.port = 16151 + +# +# Kafka +# +openwifi.kafka.group.id = ow_helloworld +openwifi.kafka.client.id = ow_helloworld1 +openwifi.kafka.enable = ${KAFKA_ENABLE} +openwifi.kafka.brokerlist = ${KAFKA_BROKERLIST} +openwifi.kafka.auto.commit = false +openwifi.kafka.queue.buffering.max.ms = 50 +openwifi.kafka.ssl.ca.location = ${KAFKA_SSL_CA_LOCATION} +openwifi.kafka.ssl.certificate.location = ${KAFKA_SSL_CERTIFICATE_LOCATION} +openwifi.kafka.ssl.key.location = ${KAFKA_SSL_KEY_LOCATION} +openwifi.kafka.ssl.key.password = ${KAFKA_SSL_KEY_PASSWORD} + +# +# This section select which form of persistence you need +# Only one selected at a time. If you select multiple, this service will die if a horrible +# death and might make your beer flat. +# +storage.type = ${STORAGE_TYPE} +storage.type.sqlite.idletime = 120 +storage.type.sqlite.maxsessions = 128 + +storage.type.postgresql.maxsessions = 64 +storage.type.postgresql.idletime = 60 +storage.type.postgresql.host = ${STORAGE_TYPE_POSTGRESQL_HOST} +storage.type.postgresql.username = ${STORAGE_TYPE_POSTGRESQL_USERNAME} +storage.type.postgresql.password = ${STORAGE_TYPE_POSTGRESQL_PASSWORD} +storage.type.postgresql.database = ${STORAGE_TYPE_POSTGRESQL_DATABASE} +storage.type.postgresql.port = ${STORAGE_TYPE_POSTGRESQL_PORT} +storage.type.postgresql.connectiontimeout = 60 + +storage.type.mysql.maxsessions = 64 +storage.type.mysql.idletime = 60 +storage.type.mysql.host = ${STORAGE_TYPE_MYSQL_HOST} +storage.type.mysql.username = ${STORAGE_TYPE_MYSQL_USERNAME} +storage.type.mysql.password = ${STORAGE_TYPE_MYSQL_PASSWORD} +storage.type.mysql.database = ${STORAGE_TYPE_MYSQL_DATABASE} +storage.type.mysql.port = ${STORAGE_TYPE_MYSQL_PORT} +storage.type.mysql.connectiontimeout = 60 + +######################################################################## +######################################################################## +# +# Logging: please leave as is for now. +# +######################################################################## +logging.type = console +logging.path = $OWHELLOWORLD_ROOT/logs +logging.level = debug