diff --git a/Dockerfile b/Dockerfile index 4fdc622..2727ca1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,34 @@ -FROM drogonframework/drogon-arm AS installer +FROM ubuntu:18.04 -ENV CORE_ROOT=$IROOT/core +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 \ + && rm -rf /var/lib/apt/lists/* \ + && locale-gen en_US.UTF-8 \ + && cd /opt/ \ + && wget -qO- https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/6.0.0/flyway-commandline-6.0.0-linux-x64.tar.gz | tar xvz \ + && sudo ln -s /opt/flyway-6.0.0/flyway /usr/local/bin + +ENV LANG=en_US.UTF-8 \ + LANGUAGE=en_US:en \ + LC_ALL=en_US.UTF-8 \ + CC=gcc-8 \ + CXX=g++-8 \ + AR=gcc-ar-8 \ + RANLIB=gcc-ranlib-8 \ + IROOT=/install + +ENV DROGON_ROOT=$IROOT/drogon \ + CORE_ROOT=$IROOT/core + +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 + +WORKDIR $DROGON_ROOT + +RUN ./build.sh COPY . $CORE_ROOT @@ -8,9 +36,6 @@ WORKDIR $CORE_ROOT RUN ./build.sh -FROM drogonframework/drogon-arm - -COPY --from=installer /bin/core /bin/core - +WORKDIR /srv/core EXPOSE 5000 -ENTRYPOINT ["core"] +ENTRYPOINT ["./core"] diff --git a/build.sh b/build.sh index d0dc97a..2f29055 100755 --- a/build.sh +++ b/build.sh @@ -31,5 +31,6 @@ fi cp core /bin/ -mkdir /srv/core +mkdir /srv/core/ cp config.json /srv/core +cp core /srv/core/ diff --git a/config.cc b/config.cc index 9b8fd7b..1ac905b 100644 --- a/config.cc +++ b/config.cc @@ -2,10 +2,12 @@ namespace config { - int discover_max_client_backlog = 20; + char version[] = "0.0.1"; + + uint16_t discover_max_client_backlog = 20; uint16_t discover_port_dev = 4420; uint16_t discover_port = 4419; - int discover_timeout_ms = 2000; + uint16_t discover_timeout_ms = 2000; uint8_t discover_code_accept = 0; uint8_t discover_code_reject = 100; diff --git a/config.h b/config.h index d7ea5c8..49102cd 100644 --- a/config.h +++ b/config.h @@ -5,10 +5,12 @@ namespace config { - extern int discover_max_client_backlog; + extern char version[]; + + extern uint16_t discover_max_client_backlog; extern uint16_t discover_port_dev; extern uint16_t discover_port; - extern int discover_timeout_ms; + extern uint16_t discover_timeout_ms; extern uint8_t discover_code_accept; extern uint8_t discover_code_reject; diff --git a/docker-compose.yml b/docker-compose.yml index 3f1d89e..8f75c99 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,11 +2,6 @@ version: '3.2' volumes: v-core-data: services: - drogon-arm: - image: drogonframework/drogon-arm - build: - context: . - dockerfile: Dockerfile.drogon core: image: registry.gitlab.com/emgauwa/core build: diff --git a/main.cc b/main.cc index c61f0ea..522b52b 100644 --- a/main.cc +++ b/main.cc @@ -5,6 +5,7 @@ #include #include "globals.h" +#include "config.h" static void terminate(int signum) @@ -45,6 +46,9 @@ main() //drogon::app().getLoop()->runEvery(1, &test); //Run HTTP framework,the method will block in the internal event loop + + LOG_INFO << "Starting Emgauwa Core (" << config::version << ")"; + drogon::app().run(); return 0; }