diff --git a/scripts/Dockerfile.alpine b/scripts/Dockerfile.alpine index df8a411..39dc496 100755 --- a/scripts/Dockerfile.alpine +++ b/scripts/Dockerfile.alpine @@ -14,11 +14,15 @@ # limitations under the License. # -ARG BASE=alpine:3.18 +# Use alpine:3.16 as the base image because starting from alpine:3.17, the execinfo library has been removed. +# The execinfo library is required by the current implementation of the handle_sig function in device-can.c. +# If switching to a newer alpine version, modifications to the handle_sig function will be necessary +# to eliminate the dependency on execinfo (e.g., by replacing it with libunwind or similar). +ARG BASE=alpine:3.16 FROM ${BASE} as builder RUN wget https://iotech.jfrog.io/artifactory/api/security/keypair/public/repositories/alpine-release -O /etc/apk/keys/alpine.dev.rsa.pub RUN echo 'https://iotech.jfrog.io/artifactory/alpine-release/v3.16/main' >> /etc/apk/repositories -RUN apk add --update --no-cache build-base git gcc cmake make linux-headers yaml-dev libmicrohttpd-dev curl-dev util-linux-dev ncurses-dev paho-mqtt-c-dev-1.3 hiredis-dev libcbor-dev iotech-iot-1.5-dev +RUN apk add --update --no-cache build-base git gcc cmake make linux-headers yaml-dev libmicrohttpd-dev curl-dev util-linux-dev ncurses-dev iotech-paho-mqtt-c-dev-1.3 hiredis-dev libcbor-dev iotech-iot-1.5-dev libexecinfo-dev COPY scripts /device-can/scripts COPY src /device-can/src/ @@ -28,14 +32,14 @@ WORKDIR /device-can RUN /device-can/scripts/build_deps.sh 1 -RUN /device-can/scripts/build.sh +RUN /device-can/scripts/build.sh && test -f /device-can/build/release/device-can -FROM alpine:3.18 +FROM alpine:3.16 MAINTAINER hcltech RUN wget https://iotech.jfrog.io/artifactory/api/security/keypair/public/repositories/alpine-release -O /etc/apk/keys/alpine.dev.rsa.pub RUN echo 'https://iotech.jfrog.io/artifactory/alpine-release/v3.16/main' >> /etc/apk/repositories -RUN apk add --update --no-cache linux-headers yaml libmicrohttpd curl libuuid paho-mqtt-c-dev-1.3 hiredis libcbor iotech-iot-1.5 dumb-init +RUN apk add --update --no-cache linux-headers yaml libmicrohttpd curl libuuid iotech-paho-mqtt-c-dev-1.3 hiredis libcbor iotech-iot-1.5 dumb-init libexecinfo # Ensure using latest versions of all installed packages to avoid any recent CVEs RUN apk --no-cache upgrade @@ -52,4 +56,4 @@ LABEL license='SPDX-License-Identifier: Apache-2.0' \ EXPOSE 59980 ENTRYPOINT ["/device-can"] -CMD ["-cp=consul://edgex-core-consul:8500", "--registry", "--confdir=/res"] +CMD ["-cp=keeper://edgex-core-keeper:59890", "--registry", "--confdir=/res"] diff --git a/scripts/Dockerfile.alpine-base b/scripts/Dockerfile.alpine-base index ebbeadf..bb3717b 100755 --- a/scripts/Dockerfile.alpine-base +++ b/scripts/Dockerfile.alpine-base @@ -14,12 +14,16 @@ # limitations under the License. # -ARG BASE=alpine:3.8 +# Use alpine:3.16 as the base image because starting from alpine:3.17, the execinfo library has been removed. +# The execinfo library is required by the current implementation of the handle_sig function in device-can.c. +# If switching to a newer alpine version, modifications to the handle_sig function will be necessary +# to eliminate the dependency on execinfo (e.g., by replacing it with libunwind or similar). +ARG BASE=alpine:3.16 FROM ${BASE} RUN wget https://iotech.jfrog.io/artifactory/api/security/keypair/public/repositories/alpine-release -O /etc/apk/keys/alpine.dev.rsa.pub RUN echo 'https://iotech.jfrog.io/artifactory/alpine-release/v3.16/main' >> /etc/apk/repositories -RUN apk add --update --no-cache build-base git gcc cmake make linux-headers yaml-dev libmicrohttpd-dev curl-dev util-linux-dev ncurses-dev paho-mqtt-c-dev-1.3 hiredis-dev libcbor-dev iotech-iot-1.5-dev dumb-init +RUN apk add --update --no-cache build-base git gcc cmake make linux-headers yaml-dev libmicrohttpd-dev curl-dev util-linux-dev ncurses-dev iotech-paho-mqtt-c-dev-1.3 hiredis-dev libcbor-dev iotech-iot-1.5-dev dumb-init libexecinfo-dev # Ensure using latest versions of all installed packages to avoid any recent CVEs RUN apk --no-cache upgrade diff --git a/scripts/build_deps.sh b/scripts/build_deps.sh index a666be4..799a27b 100755 --- a/scripts/build_deps.sh +++ b/scripts/build_deps.sh @@ -12,7 +12,7 @@ set -e -x BUILD_CSDK=$1 -CSDK_VERSION=3.0.2 +CSDK_VERSION=4.0.0-dev.14 if [ -d deps ] then diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 39ade92..b2d1893 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,10 +35,12 @@ file (GLOB C_FILES c/*.c) find_library(EDGEX_CSDK_RELEASE_LIB NAMES csdk) #find_library(IOT_LIBRARIES NAMES iot) find_library (IOT_LIBRARY iot PATHS /opt/iotech/iot/${IOT_VER}/lib) +find_library(EXECINFO_LIBRARY NAMES execinfo) add_executable(device-can ${C_FILES}) target_compile_definitions(device-can PRIVATE VERSION="${CAN_DOT_VERSION}") target_include_directories (device-can PRIVATE .) target_include_directories (device-can PRIVATE ${IOT_INCLUDE_DIRS}) target_link_libraries (device-can PUBLIC m PRIVATE ${EDGEX_CSDK_RELEASE_LIB}) target_link_libraries (device-can PUBLIC m PRIVATE ${IOT_LIBRARY}) +target_link_libraries (device-can PRIVATE ${EXECINFO_LIBRARY}) install(TARGETS device-can DESTINATION bin)