Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
/build/
.git/
*build*/
/tags
/.dockerignore
*~
*.swp
11 changes: 10 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
[submodule "ww-deal"]
path = ww-deal
url = git@github.com:woefulwabbit/ww-deal.git
url = ../../woefulwabbit/ww-deal.git
branch = master
[submodule "pistache"]
path = pistache
url = ../../oktal/pistache.git
branch = master
[submodule "json"]
path = json
url = ../../nlohmann/json.git
branch = master
23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
cmake_minimum_required (VERSION 2.6)

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()

project (ww-deal-server)

find_package(Pistache 0.0.2)
find_package(nlohmann_json)
if (NOT Pistache_FOUND)
add_subdirectory(${CMAKE_SOURCE_DIR}/pistache)
endif ()
if (NOT nlohmann_json_FOUND)
if (NOT DEFINED JSON_BuildTests)
set(JSON_BuildTests OFF)
endif ()
add_subdirectory(json)
endif ()

include(GNUInstallDirs)

add_subdirectory(server)
add_subdirectory(ww-deal)

install(TARGETS api-server
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT Runtime
)
71 changes: 58 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,66 @@
FROM debian:stretch as deal-builder
FROM debian:buster as deal-builder

# Install build dependecies
RUN apt-get update
RUN apt-get install -y \
git \
build-essential \
cmake
RUN apt-get install -y --no-install-recommends \
g++ \
cmake \
ninja-build

RUN git clone https://github.com/online-bridge-hackathon/Deal.git && \
cd /Deal

WORKDIR /Deal
ARG PREFIX=/usr/local
ARG BUILD_TYPE=RelWithDepInfo

RUN git clone https://github.com/woefulwabbit/ww-deal.git
RUN mkdir -p /build/pistache && mkdir -p /build/json

RUN cmake . && \
make
# Fetch source from the build context
ADD pistache /sources/pistache
# Build the pistache library
RUN cmake -DCMAKE_INSTALL_PREFIX=$PREFIX \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-G Ninja \
-S /sources/pistache \
-B /build/pistache && \
ninja install -C /build/pistache

WORKDIR /Deal/server
ADD json /sources/json
# Build the json library
RUN cmake -DCMAKE_INSTALL_PREFIX=$PREFIX \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DJSON_BuildTests=Off \
-G Ninja \
-S /sources/json \
-B /build/json && \
ninja install -C /build/json

ADD ww-deal /sources/ww-deal
ADD server /sources/server
ADD CMakeLists.txt /sources/

# Build sources
RUN cmake -DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-G Ninja \
-S /sources \
-B /build && \
ninja install -C /build

# Create a clean server image
FROM debian:buster as deal-image

# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libatomic1

# Copy required runtime files
COPY --from=deal-builder /usr/local/lib/libpistache.so.0.* /usr/local/lib/
COPY --from=deal-builder /usr/local/bin/api-server /usr/local/bin/api-server

# Add the library to the lookup cache
RUN ln -s /usr/local/lib/libpistache.so.0.* /usr/local/lib/libpistache.so.0 && \
ldconfig

# Setup runtime options for the server
WORKDIR /usr/local/bin
EXPOSE 8080/tcp
CMD ./api-server
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
DOCKER_REPO ?= gcr.io/online-bridge-hackathon-2020
VERSION ?= $(shell cat VERSION)
DOCKER_TAG=${DOCKER_REPO}/deal-api:${VERSION}
DEV_DOCKER_TAG=local/deal-api:${VERSION}
GIT_REPO ?= https://github.com/online-bridge-hackathon/Deal.git

EXTERNAL_ADDRES ?= deal.hackathon.globalbridge.app

Expand All @@ -9,12 +11,22 @@ GCP_PROJECT ?= online-bridge-hackathon-2020
GKE_CLUSTER_NAME ?= hackathon-cluster
GKE_ZONE ?= europe-west3-b

release: build push
all: build
@echo
@echo "Run local test server using: docker run -t ${DEV_DOCKER_TAG}"

build:
docker build -t ${DOCKER_TAG} .
release: push

push:
.dockerignore: .gitignore
sed 's#^[^/]#**/\0#' < $< > $@

build: .dockerignore
docker build -t ${DEV_DOCKER_TAG} .

build-release: .dockerignore
docker build -t ${DOCKER_TAG} "${GIT_REPO}#${VERSION}"

push: build-release
docker push ${DOCKER_TAG}

deploy: set_gcp_context ensure_ns
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ A web service that accepts request by APIs and returns 1+ bridge deals

# Build
```
git submodule update --init
mkdir build
cd build
cmake ..
Expand Down
1 change: 1 addition & 0 deletions json
Submodule json added at efcc82
1 change: 1 addition & 0 deletions pistache
Submodule pistache added at bcad66
1 change: 0 additions & 1 deletion server/.gitignore

This file was deleted.

32 changes: 7 additions & 25 deletions server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
cmake_minimum_required (VERSION 3.2)

project(api-server)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pg -g3" )

include(ExternalProject)

set(EXTERNAL_INSTALL_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/external)

ExternalProject_Add(PISTACHE
GIT_REPOSITORY https://github.com/oktal/pistache.git
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION}
)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

ExternalProject_Add(NLOHMANN
GIT_REPOSITORY https://github.com/nlohmann/json.git
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION} -DJSON_BuildTests=Off

)
include_directories(${EXTERNAL_INSTALL_LOCATION}/include)
link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)

include_directories(model)
include_directories(api)
include_directories(impl)
project(api-server)

file(GLOB SRCS
${CMAKE_CURRENT_SOURCE_DIR}/api/*.cpp
Expand All @@ -33,5 +14,6 @@ file(GLOB SRCS
)

add_executable(${PROJECT_NAME} ${SRCS} )
add_dependencies(${PROJECT_NAME} PISTACHE NLOHMANN)
target_link_libraries(${PROJECT_NAME} pistache pthread wwdeal)
target_include_directories(${PROJECT_NAME} PRIVATE model api impl)
target_link_libraries(${PROJECT_NAME} pistache_shared wwdeal nlohmann_json)