diff --git a/CMakeLists.txt b/CMakeLists.txt index f3d00fd..b91d5a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,54 @@ find_package(ZLIB REQUIRED) include_directories(${ZLIB_INCLUDE_DIR}) link_libraries(${ZLIB_LIBRARIES}) +#find postgres +find_package(PostgreSQL) +if(PostgreSQL_FOUND) + message(STATUS "libpq inc path:" ${PostgreSQL_INCLUDE_DIR}) + message(STATUS "libpq lib:" ${PostgreSQL_LIBRARIES}) + include_directories(${PostgreSQL_INCLUDE_DIR}) + link_libraries(${PostgreSQL_LIBRARIES}) + set(DROGON_SOURCES ${DROGON_SOURCES} + orm_lib/src/postgresql_impl/PostgreSQLResultImpl.cc) + if(LIBPQ_BATCH_MODE) + try_compile(libpq_supports_batch + ${CMAKE_BINARY_DIR}/cmaketest + ${PROJECT_SOURCE_DIR}/cmake/tests/test_libpq_batch_mode.cc + LINK_LIBRARIES ${PostgreSQL_LIBRARIES} + CMAKE_FLAGS "-Dinclude_directories=${PostgreSQL_INCLUDE_DIR}") + endif() + if(libpq_supports_batch) + message(STATUS "The libpq supports fatch mode") + OPTION(LIBPQ_SUPPORTS_BATCH_MODE "ibpq fatch mode" ON) + set(DROGON_SOURCES ${DROGON_SOURCES} + orm_lib/src/postgresql_impl/PgBatchConnection.cc) + else() + OPTION(LIBPQ_SUPPORTS_BATCH_MODE "ibpq fatch mode" OFF) + set(DROGON_SOURCES ${DROGON_SOURCES} + orm_lib/src/postgresql_impl/PgConnection.cc) + endif() +endif() + +#Find mysql, only mariadb client liberary is supported +find_package(MySQL) +if(MYSQL_FOUND) + message(STATUS "inc:" ${MYSQL_INCLUDE_DIR}) + message(STATUS "libs:" ${MYSQL_CLIENT_LIBS}) + message(STATUS "version:" ${MYSQL_VERSION_STRING}) + if(MYSQL_VERSION_STRING STREQUAL "") + set(MYSQL_FOUND false) + message(STATUS "The mysql in your system is not the mariadb, so we can't use it in drogon") + else() + message(STATUS "Ok! We find the mariadb!") + include_directories(${MYSQL_INCLUDE_DIR}) + link_libraries(${MYSQL_CLIENT_LIBS}) + set(DROGON_SOURCES ${DROGON_SOURCES} + orm_lib/src/mysql_impl/MysqlConnection.cc + orm_lib/src/mysql_impl/MysqlResultImpl.cc) + endif() +endif() + + #Find sqlite3. find_package (SQLite3) if (SQLITE3_FOUND) @@ -69,4 +117,6 @@ AUX_SOURCE_DIRECTORY(helpers HELPER_SRC) include_directories(/usr/local/include) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +configure_file("config.json" "config.json" COPYONLY) add_executable(core ${SRC_DIR} ${CTL_SRC} ${FILTER_SRC} ${PLUGIN_SRC} ${MODEL_SRC} ${HELPER_SRC}) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..653fa2a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM drogonframework/drogon + +ENV CORE_ROOT=$IROOT/core + +WORKDIR $IROOT + +COPY . $CORE_ROOT + +WORKDIR $CORE_ROOT + +RUN ./build.sh + +ENTRYPOINT ["/srv/core"] diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..936aed8 --- /dev/null +++ b/build.sh @@ -0,0 +1,33 @@ +current_dir="${PWD}" + +#The folder in which we will build emgauwa +build_dir='./build' +if [ -d $build_dir ]; then + echo "Deleted folder: ${build_dir}" + rm -rf $build_dir +fi + +#Create building folder +echo "Created building folder: ${build_dir}" +mkdir $build_dir + +echo "Entering folder: ${build_dir}" +cd $build_dir + +echo "Start building emgauwa ..." +cmake .. + +#If errors then exit +if [ "$?" != "0" ]; then + exit -1 +fi + +make + +#If errors then exit +if [ "$?" != "0" ]; then + exit -1 +fi + +cp core /srv/ +cp config.json /srv/ diff --git a/main.cc b/main.cc index 5a4f649..c61f0ea 100644 --- a/main.cc +++ b/main.cc @@ -40,7 +40,7 @@ main() } //Load config file - drogon::app().loadConfigFile("../config.json"); + drogon::app().loadConfigFile("config.json"); //drogon::app().getLoop()->runEvery(1, &test);