Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Dockerfile #18

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
FROM debian:bookworm AS build

RUN set -eux; \
apt-get update; \
apt-get upgrade --yes; \
apt-get install --yes --no-install-recommends \
cmake \
curl \
gcc \
g++ \
git \
make \
ca-certificates \
libboost-system-dev \
libboost-program-options-dev \
; \
rm -rf /var/lib/apt/lists/*

ARG CC_CMAKE_VERSION=2024-10-01
ARG URL=https://github.com/commschamp/cc.cmake/archive/refs/tags/
RUN set -eux; \
curl -L ${URL}/${CC_CMAKE_VERSION}.tar.gz -o /tmp/cc_cmake.tar.gz \
&& mkdir /cc_cmake/ \
&& tar -zxf /tmp/cc_cmake.tar.gz -C /cc_cmake --strip-components=1

COPY config.cmake /cc_cmake/config.cmake

ARG BUILD_DIR=/cc_cmake/build
RUN set -eux; \
cd /cc_cmake/ \
&& mkdir -p ${BUILD_DIR} \
&& cmake . -B ${BUILD_DIR} -DCMAKE_PROJECT_INCLUDE=config.cmake \
&& cmake --build ${BUILD_DIR} --target cc.mqttsn.libs -- -j4

FROM debian:bookworm-slim
RUN set -eux; \
apt-get update; \
apt-get upgrade --yes; \
apt-get install --yes --no-install-recommends \
ca-certificates \
libboost-system-dev \
libboost-program-options-dev \
; \
rm -rf /var/lib/apt/lists/*

COPY --from=build /usr/local/bin/cc_mqttsn_gateway_app /usr/local/bin/cc_mqttsn_gateway_app
COPY --from=build /usr/local/etc/cc_mqttsn_gateway/cc_mqttsn_gateway.conf.example /usr/local/etc/cc_mqttsn_gateway/cc_mqttsn_gateway.conf

ENTRYPOINT ["cc_mqttsn_gateway_app"]
CMD ["-c", "/usr/local/etc/cc_mqttsn_gateway/cc_mqttsn_gateway.conf"]
9 changes: 9 additions & 0 deletions config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set (OPT_CC_MQTTSN_LIBS ON)

set (CC_MQTTSN_LIBS_GIT_TAG "v2.0.5")

list (APPEND CC_MQTTSN_LIBS_CMAKE_ARGS
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_CXX_STANDARD=17
-DCC_MQTTSN_CLIENT_DEFAULT_LIB=OFF
)