Commit 08ebe2db authored by Denis's avatar Denis
Browse files

change docker-compose

2 merge requests!24MVP+,!18RK: MVP
Showing with 28 additions and 15 deletions
+28 -15
...@@ -4,27 +4,38 @@ volumes: ...@@ -4,27 +4,38 @@ volumes:
database-volume: database-volume:
services: services:
postgres: db:
image: postgres
container_name: db
restart: always
build: build:
context: ./Docker context: ./Docker
dockerfile: db.Dockerfile dockerfile: db.Dockerfile
restart: always
image: postgres
environment: environment:
POSTGRES_DB: "tmp" POSTGRES_DB: "temp"
POSTGRES_USER: "tmp" POSTGRES_USER: "temp"
POSTGRES_PASSWORD: "tmp" POSTGRES_PASSWORD: "temp"
volumes:
- database-volume:/var/lib/postgresql/data
ports: ports:
- "5432:5432" - "5432:5432"
volumes: networks:
- database-volume:/var/lib/postgresql/data - db-network
server: server:
image: raiden454/cpp-app:latest image: raiden454/cpp-app:latest
networks:
- db-network
volumes: volumes:
- .:/project - .:/project
command: make server-run command: make server-run
restart: always
ports: ports:
- "8081:8081" - "8080:8080"
depends_on: depends_on:
- postgres - db
links:
- db:db
networks:
db-network:
driver: bridge
name: db_network
...@@ -14,7 +14,7 @@ std::shared_ptr<pqxx::connection> dbConnection::connection() const { ...@@ -14,7 +14,7 @@ std::shared_ptr<pqxx::connection> dbConnection::connection() const {
} }
void dbConnection::establish_connection() { void dbConnection::establish_connection() {
pqxx::connection c("dbname =mydb" "user = postgres password =root hostaddr =127.0.0.1 port = 5432"); pqxx::connection c("dbname =mydb" "user = temp password =temp hostaddr =db port = 5432");
m_connection.reset(&c); m_connection.reset(&c);
} }
...@@ -11,7 +11,7 @@ void dbManager::createPool() { ...@@ -11,7 +11,7 @@ void dbManager::createPool() {
for (auto i = 0; i < POOL_SIZE; i++) { for (auto i = 0; i < POOL_SIZE; i++) {
connection_pool.emplace(std::make_shared<pqxx::connection>( connection_pool.emplace(std::make_shared<pqxx::connection>(
"dbname =mydb user = postgres password =root hostaddr =172.28.224.1 port = 5432")); "dbname =mydb user = temp password =temp hostaddr =db port = 5432"));
} }
} }
......
...@@ -19,13 +19,15 @@ int main(int argc, char* argv[]) ...@@ -19,13 +19,15 @@ int main(int argc, char* argv[])
// return EXIT_FAILURE; // return EXIT_FAILURE;
// } // }
std::cout << "SERVER RUN" << std::endl; std::cout << "SERVER RUN12" << std::endl;
auto const address = net::ip::make_address("0.0.0.0"); auto const address = net::ip::make_address("0.0.0.0");
auto const port = static_cast<unsigned short>(std::atoi("8080")); auto const port = static_cast<unsigned short>(std::atoi("8080"));
auto const doc_root = std::make_shared<std::string>("."); auto const doc_root = std::make_shared<std::string>(".");
auto const threads = std::max<int>(1, std::atoi("1")); auto const threads = std::max<int>(1, std::atoi("1"));
std::cout << "SERVER INIT" << std::endl;
// The io_context is required for all I/O // The io_context is required for all I/O
net::io_context ioc{threads}; net::io_context ioc{threads};
......
...@@ -13,7 +13,7 @@ Router::Router(std::string_view doc_root_) : ...@@ -13,7 +13,7 @@ Router::Router(std::string_view doc_root_) :
http::message_generator Router::handleRequest(http::request<http::string_body> &&req) { http::message_generator Router::handleRequest(http::request<http::string_body> &&req) {
std::cout << req << std::endl;
if(req.method() != http::verb::get && req.method() != http::verb::post) if(req.method() != http::verb::get && req.method() != http::verb::post)
return getBadRequest(req, "Unknown HTTP-method"); return getBadRequest(req, "Unknown HTTP-method");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment