Add docker file for running on server.
This commit is contained in:
33
Dockerfile
Normal file
33
Dockerfile
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Use an official Ubuntu as a parent image
|
||||||
|
FROM ubuntu:latest
|
||||||
|
|
||||||
|
# Set the working directory in the container to /app
|
||||||
|
WORKDIR /server
|
||||||
|
|
||||||
|
# Install necessary packages, including CMake, a C++ compiler, and wget
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y cmake g++ make wget && \
|
||||||
|
apt-get clean;
|
||||||
|
|
||||||
|
# Copy the current directory contents into the container at /app
|
||||||
|
COPY . /server
|
||||||
|
|
||||||
|
# Download Crow library
|
||||||
|
RUN wget https://github.com/CrowCpp/Crow/archive/refs/heads/master.zip -O crow.zip && \
|
||||||
|
unzip crow.zip && \
|
||||||
|
mv Crow-master/crow/include/crow.h /usr/local/include/
|
||||||
|
|
||||||
|
# Make the build directory
|
||||||
|
RUN mkdir -p build && cd build
|
||||||
|
|
||||||
|
# Run CMake to configure the build
|
||||||
|
RUN cmake ..
|
||||||
|
|
||||||
|
# Build the project
|
||||||
|
RUN make
|
||||||
|
|
||||||
|
# Expose port 8888 for the web server
|
||||||
|
EXPOSE 8888
|
||||||
|
|
||||||
|
# Command to run the executable
|
||||||
|
CMD ["./douwco_web"]
|
||||||
@@ -6,16 +6,17 @@
|
|||||||
namespace Douwco {
|
namespace Douwco {
|
||||||
|
|
||||||
class Server {
|
class Server {
|
||||||
|
|
||||||
|
private:
|
||||||
|
static constexpr int port = 8888;
|
||||||
|
crow::SimpleApp crowApp;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Server() = default;
|
Server() = default;
|
||||||
~Server() = default;
|
~Server() = default;
|
||||||
|
|
||||||
void setup();
|
void setup();
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
private:
|
|
||||||
static constexpr int port = 8080;
|
|
||||||
crow::SimpleApp crowApp;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,18 @@
|
|||||||
|
|
||||||
#include "server.hpp"
|
#include "server.hpp"
|
||||||
|
|
||||||
void Douwco::Server::setup() {
|
#define CREATE_ROUTE(route_path, html_path) \
|
||||||
CROW_ROUTE(crowApp, "/")([](){
|
CROW_ROUTE(this->crowApp, route_path) \
|
||||||
std::string page = crow::mustache::load("home.html").render_string();
|
([]() { \
|
||||||
return page;
|
std::string page = crow::mustache::load(html_path).render_string(); \
|
||||||
|
return page; \
|
||||||
});
|
});
|
||||||
|
|
||||||
|
void Douwco::Server::setup() {
|
||||||
|
CREATE_ROUTE("/", "home.html");
|
||||||
|
CREATE_ROUTE("/about_me", "about_me.html");
|
||||||
|
CREATE_ROUTE("/about_douwco", "about_douwco.html");
|
||||||
|
CREATE_ROUTE("/games", "games.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Douwco::Server::start() {
|
void Douwco::Server::start() {
|
||||||
@@ -15,4 +22,4 @@ void Douwco::Server::start() {
|
|||||||
.multithreaded()
|
.multithreaded()
|
||||||
// .ssl_file("dev_cert/certificate.pem","dev_cert/private.key")
|
// .ssl_file("dev_cert/certificate.pem","dev_cert/private.key")
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
28
templates/about_douwco.html
Normal file
28
templates/about_douwco.html
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="../static/css/douwco_styling.css">
|
||||||
|
</head>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div style="
|
||||||
|
margin-left: 50px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: row;
|
||||||
|
align-content: center;">
|
||||||
|
|
||||||
|
<img src="../static/img/douwco_logo.png" alt="douwco_logo" style="
|
||||||
|
width:150px;
|
||||||
|
height: 150px;
|
||||||
|
margin-right: 50px;">
|
||||||
|
|
||||||
|
<h1 style="
|
||||||
|
font-family: righteous;
|
||||||
|
font-size: 120px;">
|
||||||
|
douwco</h1>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
28
templates/about_me.html
Normal file
28
templates/about_me.html
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="../static/css/douwco_styling.css">
|
||||||
|
</head>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div style="
|
||||||
|
margin-left: 50px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: row;
|
||||||
|
align-content: center;">
|
||||||
|
|
||||||
|
<img src="../static/img/douwco_logo.png" alt="douwco_logo" style="
|
||||||
|
width:150px;
|
||||||
|
height: 150px;
|
||||||
|
margin-right: 50px;">
|
||||||
|
|
||||||
|
<h1 style="
|
||||||
|
font-family: righteous;
|
||||||
|
font-size: 120px;">
|
||||||
|
douwco</h1>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
28
templates/games.html
Normal file
28
templates/games.html
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="../static/css/douwco_styling.css">
|
||||||
|
</head>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div style="
|
||||||
|
margin-left: 50px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: row;
|
||||||
|
align-content: center;">
|
||||||
|
|
||||||
|
<img src="../static/img/douwco_logo.png" alt="douwco_logo" style="
|
||||||
|
width:150px;
|
||||||
|
height: 150px;
|
||||||
|
margin-right: 50px;">
|
||||||
|
|
||||||
|
<h1 style="
|
||||||
|
font-family: righteous;
|
||||||
|
font-size: 120px;">
|
||||||
|
douwco</h1>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -29,7 +29,9 @@
|
|||||||
douwco</h1>
|
douwco</h1>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button class="menu_button" style="
|
<button class="menu_button" s
|
||||||
|
onclick="location.href='/games'"
|
||||||
|
style="
|
||||||
margin-left: 50px;
|
margin-left: 50px;
|
||||||
padding-left: 50px;
|
padding-left: 50px;
|
||||||
padding-right: 50px;">
|
padding-right: 50px;">
|
||||||
@@ -42,8 +44,9 @@
|
|||||||
<span style="color: #88d4d4;">My Games</span>
|
<span style="color: #88d4d4;">My Games</span>
|
||||||
</p>
|
</p>
|
||||||
</button>
|
</button>
|
||||||
|
<button class="menu_button"
|
||||||
<button class="menu_button" style="
|
onclick="location.href='/about_me'"
|
||||||
|
style="
|
||||||
margin-left: 50px;
|
margin-left: 50px;
|
||||||
padding-left: 50px;
|
padding-left: 50px;
|
||||||
padding-right: 50px;">
|
padding-right: 50px;">
|
||||||
@@ -58,7 +61,9 @@
|
|||||||
</p>
|
</p>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button class="menu_button" style="
|
<button class="menu_button"
|
||||||
|
onclick="location.href='/about_douwco'"
|
||||||
|
style="
|
||||||
margin-left: 50px;
|
margin-left: 50px;
|
||||||
padding-left: 50px;
|
padding-left: 50px;
|
||||||
padding-right: 50px;">
|
padding-right: 50px;">
|
||||||
@@ -147,7 +152,6 @@
|
|||||||
">Go to Designer</p>
|
">Go to Designer</p>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user