add: Docker
This commit is contained in:
parent
0a4bd51878
commit
a5496d6fe1
4 changed files with 97 additions and 1 deletions
|
@ -52,6 +52,54 @@ find_package(ZLIB REQUIRED)
|
||||||
include_directories(${ZLIB_INCLUDE_DIR})
|
include_directories(${ZLIB_INCLUDE_DIR})
|
||||||
link_libraries(${ZLIB_LIBRARIES})
|
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 sqlite3.
|
||||||
find_package (SQLite3)
|
find_package (SQLite3)
|
||||||
if (SQLITE3_FOUND)
|
if (SQLITE3_FOUND)
|
||||||
|
@ -69,4 +117,6 @@ AUX_SOURCE_DIRECTORY(helpers HELPER_SRC)
|
||||||
include_directories(/usr/local/include)
|
include_directories(/usr/local/include)
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
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})
|
add_executable(core ${SRC_DIR} ${CTL_SRC} ${FILTER_SRC} ${PLUGIN_SRC} ${MODEL_SRC} ${HELPER_SRC})
|
||||||
|
|
13
Dockerfile
Normal file
13
Dockerfile
Normal file
|
@ -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"]
|
33
build.sh
Executable file
33
build.sh
Executable file
|
@ -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/
|
2
main.cc
2
main.cc
|
@ -40,7 +40,7 @@ main()
|
||||||
}
|
}
|
||||||
|
|
||||||
//Load config file
|
//Load config file
|
||||||
drogon::app().loadConfigFile("../config.json");
|
drogon::app().loadConfigFile("config.json");
|
||||||
|
|
||||||
//drogon::app().getLoop()->runEvery(1, &test);
|
//drogon::app().getLoop()->runEvery(1, &test);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue