From 85e00a195c6e5426f3ca5c326cd3b637abf8ea05 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Sat, 26 Oct 2019 11:47:08 -0700 Subject: [PATCH] docker build fixes --- Dockerfile | 34 ++++++++++++++++++++++++++++++++++ docker/Dockerfile.alpine | 2 +- ixsentry/CMakeLists.txt | 1 + makefile | 4 ++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..ab6dda67 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +FROM alpine as build + +RUN apk add --no-cache gcc g++ musl-dev linux-headers cmake openssl-dev +RUN apk add --no-cache make +RUN apk add --no-cache zlib-dev + +RUN addgroup -S app && adduser -S -G app app +RUN chown -R app:app /opt +RUN chown -R app:app /usr/local + +# There is a bug in CMake where we cannot build from the root top folder +# So we build from /opt +COPY --chown=app:app . /opt +WORKDIR /opt + +USER app +RUN [ "make", "ws_install" ] + +FROM alpine as runtime + +RUN apk add --no-cache libstdc++ + +RUN addgroup -S app && adduser -S -G app app +COPY --chown=app:app --from=build /usr/local/bin/ws /usr/local/bin/ws +RUN chmod +x /usr/local/bin/ws +RUN ldd /usr/local/bin/ws + +# Now run in usermode +USER app +WORKDIR /home/app + +ENTRYPOINT ["ws"] +EXPOSE 8008 +CMD ["--help"] diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.alpine index 02c5ac39..ab6dda67 100644 --- a/docker/Dockerfile.alpine +++ b/docker/Dockerfile.alpine @@ -14,7 +14,7 @@ COPY --chown=app:app . /opt WORKDIR /opt USER app -RUN [ "make" ] +RUN [ "make", "ws_install" ] FROM alpine as runtime diff --git a/ixsentry/CMakeLists.txt b/ixsentry/CMakeLists.txt index c0493838..438733d8 100644 --- a/ixsentry/CMakeLists.txt +++ b/ixsentry/CMakeLists.txt @@ -18,6 +18,7 @@ add_library(ixsentry STATIC set(IXSENTRY_INCLUDE_DIRS . + .. ../third_party ../third_party/spdlog/include) diff --git a/makefile b/makefile index a8911769..1fd6f47d 100644 --- a/makefile +++ b/makefile @@ -14,6 +14,9 @@ brew: ws: mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 .. ; make -j 4) +ws_install: + mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 .. ; make -j 4 install) + ws_openssl: mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_OPEN_SSL=1 .. ; make -j 4) @@ -47,6 +50,7 @@ docker_test: docker build -f docker/Dockerfile.debian -t bsergean/ixwebsocket_test:build . docker: + git clean -dfx docker build -t ${IMG} . docker tag ${IMG} ${BUILD}