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