From 945c69222724c027d753f62fb11a9f5512eae883 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Sat, 30 May 2020 11:16:26 -0700 Subject: [PATCH] build ixhttpd on docker with centos7 --- Dockerfile | 2 +- docker/Dockerfile.centos7_httpd | 33 +++++++++++++++++++++++++++++++++ httpd.cpp | 2 +- makefile | 6 +++--- 4 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 docker/Dockerfile.centos7_httpd diff --git a/Dockerfile b/Dockerfile index 197ac830..ddf70978 120000 --- a/Dockerfile +++ b/Dockerfile @@ -1 +1 @@ -docker/Dockerfile.alpine \ No newline at end of file +docker/Dockerfile.centos7_httpd \ No newline at end of file diff --git a/docker/Dockerfile.centos7_httpd b/docker/Dockerfile.centos7_httpd new file mode 100644 index 00000000..ef553d07 --- /dev/null +++ b/docker/Dockerfile.centos7_httpd @@ -0,0 +1,33 @@ +FROM centos:7 as build + +RUN yum install -y gcc-c++ make zlib-devel redhat-rpm-config + +RUN groupadd app && useradd -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", "httpd_linux" ] +RUN [ "rm", "-rf", "build" ] + +FROM centos:8 as runtime + +RUN groupadd app && useradd -g app app +COPY --chown=app:app --from=build /usr/local/bin/ixhttpd /usr/local/bin/ixhttpd +RUN chmod +x /usr/local/bin/ixhttpd +RUN ldd /usr/local/bin/ixhttpd + +# Copy source code for gcc +COPY --chown=app:app --from=build /opt /opt + +# Now run in usermode +USER app +WORKDIR /home/app + +ENTRYPOINT ["ixhttpd"] +EXPOSE 9999 diff --git a/httpd.cpp b/httpd.cpp index 1fa60e53..d09ffbb8 100644 --- a/httpd.cpp +++ b/httpd.cpp @@ -6,7 +6,7 @@ * Buid with make httpd */ -#include +#include "IXHttpServer.h" #include #include diff --git a/makefile b/makefile index 6583d87a..b849ab4d 100644 --- a/makefile +++ b/makefile @@ -170,7 +170,7 @@ autobahn_report: cp -rvf ~/sandbox/reports/clients/* ../bsergean.github.io/IXWebSocket/autobahn/ httpd: - clang++ --std=c++11 --stdlib=libc++ httpd.cpp \ + clang++ --std=c++11 --stdlib=libc++ -Iixwebsocket httpd.cpp \ ixwebsocket/IXSelectInterruptFactory.cpp \ ixwebsocket/IXCancellationRequest.cpp \ ixwebsocket/IXSocketTLSOptions.cpp \ @@ -192,7 +192,7 @@ httpd: ixwebsocket/apple/IXSetThreadName_apple.cpp -lz httpd_linux: - g++ --std=c++11 httpd.cpp \ + g++ --std=c++11 -o /usr/local/bin/ixhttpd httpd.cpp -Iixwebsocket \ ixwebsocket/IXSelectInterruptFactory.cpp \ ixwebsocket/IXCancellationRequest.cpp \ ixwebsocket/IXSocketTLSOptions.cpp \ @@ -211,7 +211,7 @@ httpd_linux: ixwebsocket/IXConnectionState.cpp \ ixwebsocket/IXUrlParser.cpp \ ixwebsocket/IXSelectInterrupt.cpp \ - ixwebsocket/apple/IXSetThreadName_linux.cpp -lz + ixwebsocket/linux/IXSetThreadName_linux.cpp -lz -lpthread # For the fork that is configured with appveyor rebase_upstream: