хозяйственная работа: оптимизируйте файл докера, удалите характеры перевода каретки из переведенного текста
This commit is contained in:
parent
1b4792998a
commit
c6653e6113
4 changed files with 40 additions and 13 deletions
|
|
@ -6,12 +6,16 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteracive apt-get install -y \
|
|||
apt-get clean && rm -rf /var/lib/apt/lists/*;
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
COPY app/healthcheck.cpp app/healthcheck.cpp
|
||||
COPY include/httplib.hpp include/httplib.hpp
|
||||
RUN g++ -o healthcheck -I./include ./app/healthcheck.cpp;
|
||||
|
||||
COPY app app
|
||||
COPY include include
|
||||
COPY src src
|
||||
COPY CMakeLists.txt .
|
||||
|
||||
RUN g++ -o healthcheck -I./include ./app/healthcheck.cpp;
|
||||
|
||||
RUN --mount=type=cache,target=cmake-build cmake -B cmake-build \
|
||||
-DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++ && cmake --build cmake-build -j$(nproc) && \
|
||||
|
|
@ -38,6 +42,7 @@ HEALTHCHECK CMD ./healthcheck;
|
|||
|
||||
EXPOSE 80/tcp
|
||||
VOLUME /cache
|
||||
STOPSIGNAL SIGINT
|
||||
|
||||
COPY docker-entrypoint.sh /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
#include "httplib.hpp"
|
||||
|
||||
#include <csignal>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <locale>
|
||||
#include <mutex>
|
||||
|
||||
#include "PromtCtlDocument.hpp"
|
||||
|
|
@ -10,9 +13,9 @@
|
|||
|
||||
static inline std::string random_filename(int len = 65) {
|
||||
static const char ASCII_PRINTABLE[] = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
std::random_device random_device;
|
||||
std::mt19937 generator(random_device());
|
||||
std::uniform_int_distribution distribution(0, static_cast<int>(strlen(ASCII_PRINTABLE) - 1));
|
||||
static std::random_device random_device;
|
||||
static std::mt19937 generator(random_device());
|
||||
static std::uniform_int_distribution distribution(0, static_cast<int>(strlen(ASCII_PRINTABLE) - 1));
|
||||
std::string random_string;
|
||||
random_string.reserve(len);
|
||||
for (int i = 0; i < len; ++i)
|
||||
|
|
@ -61,11 +64,20 @@ static inline auto read_file(const std::string &filename) {
|
|||
|
||||
size = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, 0, 0);
|
||||
std::string out;
|
||||
out.resize(size);
|
||||
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, out.data(), size, 0, 0);
|
||||
out.resize(size - 1);
|
||||
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, out.data(), size - 1, 0, 0);
|
||||
delete[] wstr;
|
||||
|
||||
return out;
|
||||
std::string out_lf;
|
||||
out_lf.reserve(out.size());
|
||||
|
||||
for (auto c : out) {
|
||||
if (c == '\r')
|
||||
continue;
|
||||
out_lf.push_back(c);
|
||||
}
|
||||
|
||||
return out_lf;
|
||||
}
|
||||
|
||||
class WebServer {
|
||||
|
|
@ -160,7 +172,7 @@ class WebServer {
|
|||
}
|
||||
|
||||
void listen(const char *host = "0.0.0.0", unsigned short port = 80) {
|
||||
print("Started!");
|
||||
print("started!");
|
||||
m_svr.listen(host, port);
|
||||
}
|
||||
|
||||
|
|
@ -171,12 +183,21 @@ class WebServer {
|
|||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
print("Starting...");
|
||||
static std::function<void(int)> signal_action;
|
||||
|
||||
void signal_handler(int signal) {
|
||||
signal_action(signal);
|
||||
}
|
||||
|
||||
int main() {
|
||||
CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||
CoInitializeSecurity(nullptr, -1, nullptr, nullptr, RPC_C_AUTHN_LEVEL_NONE, RPC_C_IMP_LEVEL_IDENTIFY, nullptr, EOAC_NONE, nullptr);
|
||||
|
||||
WebServer ws;
|
||||
|
||||
signal_action = [&](int x) { ws.stop(); };
|
||||
std::signal(SIGTERM, signal_handler);
|
||||
std::signal(SIGINT, signal_handler);
|
||||
|
||||
ws.listen();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo 'initializing wine...'
|
||||
wineboot -i
|
||||
echo 'copying registy values...'
|
||||
wine regedit $WINEPREFIX/drive_c/registry.reg
|
||||
echo 'starting...'
|
||||
exec wine /app/promt-puppy.exe
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue