From ea8cb566e9d385ff4d4f0ab56c418812f25493a2 Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Thu, 22 Aug 2019 22:11:06 +0200 Subject: [PATCH] fix: less packages in docker --- CMakeLists.txt | 48 -------------- Dockerfile | 6 +- build_drogon.sh | 57 +++++++++++++++++ cmake_modules/FindMySQL.cmake | 114 ---------------------------------- 4 files changed, 60 insertions(+), 165 deletions(-) create mode 100755 build_drogon.sh delete mode 100644 cmake_modules/FindMySQL.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index b91d5a2..1852058 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,54 +52,6 @@ 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) diff --git a/Dockerfile b/Dockerfile index 2727ca1..2a5824f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,8 @@ FROM ubuntu:18.04 RUN apt-get update -yqq \ && apt-get install -yqq --no-install-recommends software-properties-common \ - sudo curl wget cmake locales git gcc-8 g++-8 \ - openssl libssl-dev libjsoncpp-dev uuid-dev zlib1g-dev \ - postgresql-server-dev-all libmariadbclient-dev libsqlite3-dev \ + sudo curl wget cmake make locales git gcc-8 g++-8 \ + openssl libssl-dev libjsoncpp-dev uuid-dev zlib1g-dev libsqlite3-dev \ && rm -rf /var/lib/apt/lists/* \ && locale-gen en_US.UTF-8 \ && cd /opt/ \ @@ -25,6 +24,7 @@ ENV DROGON_ROOT=$IROOT/drogon \ ADD https://api.github.com/repos/an-tao/drogon/git/refs/heads/master $IROOT/version.json RUN git clone https://github.com/an-tao/drogon $DROGON_ROOT +COPY ./build_drogon.sh $DROGON_ROOT/build.sh WORKDIR $DROGON_ROOT diff --git a/build_drogon.sh b/build_drogon.sh new file mode 100755 index 0000000..1e32e24 --- /dev/null +++ b/build_drogon.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +#build drogon +function build_drogon() { + + #Update the submodule and initialize + git submodule update --init + + #Save current directory + current_dir="${PWD}" + + #The folder in which we will build drogon + 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 drogon ..." + if [ $1 -eq 1 ]; then + cmake .. -DMAKETEST=YES + else + cmake .. -DBUILD_ORM=NO + fi + + #If errors then exit + if [ "$?" != "0" ]; then + exit -1 + fi + + make + + #If errors then exit + if [ "$?" != "0" ]; then + exit -1 + fi + + echo "Installing ..." + sudo make install + + #Go back to the current directory + cd $current_dir + #Ok! +} + +if [ "$1" = "-t" ]; then + build_drogon 1 +else + build_drogon 0 +fi diff --git a/cmake_modules/FindMySQL.cmake b/cmake_modules/FindMySQL.cmake deleted file mode 100644 index 98fa5d3..0000000 --- a/cmake_modules/FindMySQL.cmake +++ /dev/null @@ -1,114 +0,0 @@ -#-------------------------------------------------------- -# Copyright (C) 1995-2007 MySQL AB -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of version 2 of the GNU General Public License as -# published by the Free Software Foundation. -# -# There are special exceptions to the terms and conditions of the GPL -# as it is applied to this software. View the full text of the exception -# in file LICENSE.exceptions in the top-level directory of this software -# distribution. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -# -# The MySQL Connector/ODBC is licensed under the terms of the -# GPL, like most MySQL Connectors. There are special exceptions -# to the terms and conditions of the GPL as it is applied to -# this software, see the FLOSS License Exception available on -# mysql.com. - -########################################################################## - - -#-------------- FIND MYSQL_INCLUDE_DIR ------------------ -FIND_PATH(MYSQL_INCLUDE_DIR mysql.h - /usr/include/mysql - /usr/local/include/mysql - /opt/mysql/mysql/include - /opt/mysql/mysql/include/mysql - /opt/mysql/include - /opt/local/include/mysql5 - /usr/local/mysql/include - /usr/local/mysql/include/mysql - $ENV{ProgramFiles}/MySQL/*/include - $ENV{SystemDrive}/MySQL/*/include) - -#----------------- FIND MYSQL_LIB_DIR ------------------- -IF (WIN32) - # Set lib path suffixes - # dist = for mysql binary distributions - # build = for custom built tree - IF (CMAKE_BUILD_TYPE STREQUAL Debug) - SET(libsuffixDist debug) - SET(libsuffixBuild Debug) - ELSE (CMAKE_BUILD_TYPE STREQUAL Debug) - SET(libsuffixDist opt) - SET(libsuffixBuild Release) - ADD_DEFINITIONS(-DDBUG_OFF) - ENDIF (CMAKE_BUILD_TYPE STREQUAL Debug) - - FIND_LIBRARY(MYSQL_LIB NAMES mysqlclient - PATHS - $ENV{MYSQL_DIR}/lib/${libsuffixDist} - $ENV{MYSQL_DIR}/libmysql - $ENV{MYSQL_DIR}/libmysql/${libsuffixBuild} - $ENV{MYSQL_DIR}/client/${libsuffixBuild} - $ENV{MYSQL_DIR}/libmysql/${libsuffixBuild} - $ENV{ProgramFiles}/MySQL/*/lib/${libsuffixDist} - $ENV{SystemDrive}/MySQL/*/lib/${libsuffixDist}) -ELSE (WIN32) - FIND_LIBRARY(MYSQL_LIB NAMES mysqlclient_r mariadbclient - PATHS - /usr/lib/mysql - /usr/local/lib/mysql - /usr/local/mysql/lib - /usr/local/mysql/lib/mysql - /opt/local/mysql5/lib - /opt/local/lib/mysql5/mysql - /opt/mysql/mysql/lib/mysql - /opt/mysql/lib/mysql) -ENDIF (WIN32) - -IF(MYSQL_LIB) - GET_FILENAME_COMPONENT(MYSQL_LIB_DIR ${MYSQL_LIB} PATH) -ENDIF(MYSQL_LIB) - -set(MYSQL_VERSION_STRING "") - -EXEC_PROGRAM (grep ARGS "MARIADB_BASE_VERSION ${MYSQL_INCLUDE_DIR}/*.h|awk '{print $3}'" OUTPUT_VARIABLE MYSQL_VERSION_STRING) - -IF (MYSQL_INCLUDE_DIR AND MYSQL_LIB_DIR) - SET(MYSQL_FOUND TRUE) - - FIND_LIBRARY(MYSQL_ZLIB zlib PATHS ${MYSQL_LIB_DIR}) - FIND_LIBRARY(MYSQL_TAOCRYPT taocrypt PATHS ${MYSQL_LIB_DIR}) - IF (MYSQL_LIB) - SET(MYSQL_CLIENT_LIBS ${MYSQL_LIB}) - ELSE() - SET(MYSQL_CLIENT_LIBS mysqlclient_r) - ENDIF() - IF (MYSQL_ZLIB) - SET(MYSQL_CLIENT_LIBS ${MYSQL_CLIENT_LIBS} zlib) - ENDIF (MYSQL_ZLIB) - IF (MYSQL_TAOCRYPT) - SET(MYSQL_CLIENT_LIBS ${MYSQL_CLIENT_LIBS} taocrypt) - ENDIF (MYSQL_TAOCRYPT) - # Added needed mysqlclient dependencies on Windows - IF (WIN32) - SET(MYSQL_CLIENT_LIBS ${MYSQL_CLIENT_LIBS} ws2_32) - ENDIF (WIN32) - - MESSAGE(STATUS "MySQL Include dir: ${MYSQL_INCLUDE_DIR} library dir: ${MYSQL_LIB_DIR}") - MESSAGE(STATUS "MySQL client libraries: ${MYSQL_CLIENT_LIBS}") -ELSEIF (MySQL_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Cannot find MySQL. Include dir: ${MYSQL_INCLUDE_DIR} library dir: ${MYSQL_LIB_DIR}") -ENDIF (MYSQL_INCLUDE_DIR AND MYSQL_LIB_DIR)