From 9192d7ee0721c5685bb32c0a05e3e66d88f8439f Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 15 May 2023 20:21:00 +0300 Subject: [PATCH] add docker --- .dockerignore | 6 +++ Dockerfile | 60 ++++++++++++------------- Makefile | 32 +++++++++++++ server/cmd/main.cpp | 4 +- server/internal/entities/CMakeLists.txt | 2 - server/pkg/antlr/CMakeLists.txt | 1 + 6 files changed, 71 insertions(+), 34 deletions(-) create mode 100644 .dockerignore create mode 100644 Makefile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..10be693 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +/cmake-build-debug/ +/build/ +/build1/ +.vscode +.idea +CMakeUserPresets.json \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index fd9957b..e9f5099 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,44 +1,42 @@ -FROM ubuntu:20.04 AS base +FROM ubuntu:20.04 AS base ENV TZ=Europe/Moscow RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone -RUN apt update -y -RUN apt install -y gcc -RUN apt install -y libpqxx-dev -RUN apt install -y clang-tidy -RUN apt install -y nlohmann-json3-dev -RUN apt install -y python3-pip -RUN apt install -y cppcheck -RUN apt install -y git -RUN apt-get update -y -RUN apt install -y xvfb -RUN pip install gcovr -RUN pip install cpplint +RUN apt update -y +RUN apt install -y gcc +RUN apt install -y libpqxx-dev +RUN apt install -y clang-tidy +RUN apt install -y python3-pip +RUN apt install -y cppcheck +RUN apt-get update +RUN apt install -y cmake +RUN apt-get update +RUN apt install -y libboost-all-dev +RUN apt install -y nlohmann-json3-dev +RUN apt install -y git +RUN apt install -y qt5-default +RUN apt-get update +RUN apt install -y default-jre +RUN apt -y install curl + +RUN pwd +WORKDIR /usr/local/lib +RUN curl -O https://www.antlr.org/download/antlr-4.12.0-complete.jar + +RUN apt install -y xvfb +RUN pip install gcovr +RUN pip install cpplint -RUN apt-get install wget -RUN apt-get install libssl-dev - -RUN wget https://github.com/Kitware/CMake/releases/download/v3.26.3/cmake-3.26.3.tar.gz -RUN tar -zxvf cmake-3.26.3.tar.gz -WORKDIR cmake-3.26.3 -RUN ./bootstrap -RUN make -RUN make install -RUN cd .. - -RUN wget https://boostorg.jfrog.io/artifactory/main/release/1.82.0/source/boost_1_82_0.tar.gz -RUN tar xvf boost_1_82_0.tar.gz -WORKDIR boost_1_82_0 -RUN ./bootstrap.sh --prefix=/usr/ -RUN ./b2 install RUN git clone https://github.com/google/googletest.git -b release-1.11.0 WORKDIR googletest/build -RUN cmake .. -DBUILD_GMOCK=OFF +RUN cmake .. -DBUILD_GMOCK=ON RUN make RUN make install WORKDIR /project -COPY . . \ No newline at end of file +COPY . . + +EXPOSE 8080 \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b226212 --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +generate: + mkdir build + cmake -B build/ + +build-project: + cd ./build && make + +clean: + rm -rf build + +rebuild: clean generate build-project + +server-run: + ./build/server/cmd/Server + +test: + ctest --verbose --output-on-failure --test-dir build/ + +build-docker: + docker build . -f Dockerfile -t ddt-project + +dev: + docker run --rm -it \ + -v $(PWD):/project \ + --name app \ + ddt-project + +stop-docker: + docker stop app + + + diff --git a/server/cmd/main.cpp b/server/cmd/main.cpp index 938c0a1..685eb7a 100644 --- a/server/cmd/main.cpp +++ b/server/cmd/main.cpp @@ -4,7 +4,8 @@ int main(int argc, const char* argv[]) { // ifstream ins("/home/denis/2023_1_DDT/antlr/test.py"); - std::ifstream ins("/home/denis/2023_1_DDT/server/pkg/antlr/testprogs/python/test.py"); + std::ifstream ins( + "/home/denis/2023_1_DDT/server/pkg/antlr/testprogs/python/test.py"); PythonAntlr pA = PythonAntlr(ins); @@ -16,6 +17,7 @@ int main(int argc, const char* argv[]) { } std::cout << pA.getTreeString() << std::endl; + std::cout << "test" << std::endl; return 0; } \ No newline at end of file diff --git a/server/internal/entities/CMakeLists.txt b/server/internal/entities/CMakeLists.txt index 08858c7..7b6ad66 100644 --- a/server/internal/entities/CMakeLists.txt +++ b/server/internal/entities/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 3.19) - project("EntitiesLib") set(LIB_NAME libEntities) diff --git a/server/pkg/antlr/CMakeLists.txt b/server/pkg/antlr/CMakeLists.txt index bcf317f..7c69be3 100644 --- a/server/pkg/antlr/CMakeLists.txt +++ b/server/pkg/antlr/CMakeLists.txt @@ -10,6 +10,7 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) include(ExternalAntlr4Cpp) include_directories(${ANTLR4_INCLUDE_DIRS}) + set(ANTLR_EXECUTABLE /usr/local/lib/antlr-4.12.0-complete.jar) find_package(ANTLR REQUIRED) -- GitLab