mirror of
https://github.com/alterware/master-server.git
synced 2025-04-19 03:52:53 +00:00
build: use GCC to compile & use alpine image for Docker (#88)
This commit is contained in:
parent
27c2b2b75b
commit
3f1d78ec10
27
.github/workflows/build.yml
vendored
27
.github/workflows/build.yml
vendored
@ -29,9 +29,12 @@ jobs:
|
|||||||
- debug
|
- debug
|
||||||
- release
|
- release
|
||||||
arch:
|
arch:
|
||||||
|
- x86
|
||||||
- x64
|
- x64
|
||||||
- arm64
|
- arm64
|
||||||
include:
|
include:
|
||||||
|
- arch: x86
|
||||||
|
platform: Win32
|
||||||
- arch: x64
|
- arch: x64
|
||||||
platform: x64
|
platform: x64
|
||||||
- arch: arm64
|
- arch: arm64
|
||||||
@ -80,6 +83,7 @@ jobs:
|
|||||||
- debug
|
- debug
|
||||||
- release
|
- release
|
||||||
arch:
|
arch:
|
||||||
|
- x86
|
||||||
- x64
|
- x64
|
||||||
steps:
|
steps:
|
||||||
- name: Check out files
|
- name: Check out files
|
||||||
@ -90,19 +94,23 @@ jobs:
|
|||||||
# NOTE - If LFS ever starts getting used during builds, switch this to true!
|
# NOTE - If LFS ever starts getting used during builds, switch this to true!
|
||||||
lfs: false
|
lfs: false
|
||||||
|
|
||||||
- name: Install dependencies (x64)
|
- name: Install dependencies (x86)
|
||||||
if: matrix.arch == 'x64'
|
if: matrix.arch == 'x86'
|
||||||
run: |
|
run: |
|
||||||
|
sudo dpkg --add-architecture i386
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install libcurl4-gnutls-dev -y
|
sudo apt-get -y install gcc-multilib g++-multilib
|
||||||
|
|
||||||
- name: Install Premake5
|
- name: Install Premake5
|
||||||
uses: diamante0018/setup-premake@master
|
uses: diamante0018/setup-premake@master
|
||||||
with:
|
with:
|
||||||
version: ${{ env.PREMAKE_VERSION }}
|
version: ${{ env.PREMAKE_VERSION }}
|
||||||
|
|
||||||
|
- name: Install Mold
|
||||||
|
uses: rui314/setup-mold@staging
|
||||||
|
|
||||||
- name: Generate project files
|
- name: Generate project files
|
||||||
run: premake5 --cc=clang gmake2
|
run: premake5 gmake2
|
||||||
|
|
||||||
- name: Set up problem matching
|
- name: Set up problem matching
|
||||||
uses: ammaraskar/gcc-problem-matcher@master
|
uses: ammaraskar/gcc-problem-matcher@master
|
||||||
@ -111,9 +119,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
pushd build
|
pushd build
|
||||||
make config=${{matrix.configuration}}_${{matrix.arch}} -j$(nproc)
|
make config=${{matrix.configuration}}_${{matrix.arch}} -j$(nproc)
|
||||||
env:
|
|
||||||
CC: clang
|
|
||||||
CXX: clang++
|
|
||||||
|
|
||||||
- name: Upload ${{matrix.arch}} ${{matrix.configuration}} binaries
|
- name: Upload ${{matrix.arch}} ${{matrix.configuration}} binaries
|
||||||
uses: actions/upload-artifact@main
|
uses: actions/upload-artifact@main
|
||||||
@ -124,7 +129,7 @@ jobs:
|
|||||||
|
|
||||||
build-macos:
|
build-macos:
|
||||||
name: Build macOS
|
name: Build macOS
|
||||||
runs-on: macos-13
|
runs-on: macos-14
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@ -224,10 +229,10 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Setup Docker Buildx
|
- name: Setup Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3.2.0
|
uses: docker/setup-buildx-action@v3.3.0
|
||||||
|
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
uses: docker/login-action@v3.1.0
|
uses: docker/login-action@v3.2.0
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USER }}
|
username: ${{ secrets.DOCKERHUB_USER }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
@ -243,7 +248,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Build and Push Docker Image
|
- name: Build and Push Docker Image
|
||||||
id: build-and-push
|
id: build-and-push
|
||||||
uses: docker/build-push-action@v5.1.0
|
uses: docker/build-push-action@v5.3.0
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
|
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -16,7 +16,3 @@
|
|||||||
path = deps/libtomcrypt
|
path = deps/libtomcrypt
|
||||||
url = https://github.com/libtom/libtomcrypt.git
|
url = https://github.com/libtom/libtomcrypt.git
|
||||||
branch = develop
|
branch = develop
|
||||||
[submodule "deps/curl"]
|
|
||||||
path = deps/curl
|
|
||||||
url = https://github.com/curl/curl.git
|
|
||||||
branch = curl-8_7_1
|
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
FROM ubuntu:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
RUN apt-get update
|
RUN apk add --no-cache gcompat libstdc++
|
||||||
RUN apt-get install -y libc++-dev libcurl4-gnutls-dev
|
|
||||||
|
|
||||||
COPY --chmod=755 ./linux-x64-release/alterware-master /usr/local/bin/
|
COPY --chmod=755 ./linux-x64-release/alterware-master /usr/local/bin/
|
||||||
|
|
||||||
RUN groupadd alterware-master && useradd -r -g alterware-master alterware-master
|
RUN addgroup -S alterware-master && adduser -S alterware-master -G alterware-master
|
||||||
USER alterware-master
|
USER alterware-master
|
||||||
|
|
||||||
EXPOSE 20810/udp
|
EXPOSE 20810/udp
|
||||||
|
1
deps/curl
vendored
1
deps/curl
vendored
@ -1 +0,0 @@
|
|||||||
Subproject commit de7b3e89218467159a7af72d58cea8425946e97d
|
|
75
deps/premake/curl.lua
vendored
75
deps/premake/curl.lua
vendored
@ -1,75 +0,0 @@
|
|||||||
curl = {
|
|
||||||
source = path.join(dependencies.basePath, "curl"),
|
|
||||||
}
|
|
||||||
|
|
||||||
function curl.import()
|
|
||||||
links { "curl" }
|
|
||||||
|
|
||||||
filter "toolset:msc*"
|
|
||||||
links { "Crypt32.lib" }
|
|
||||||
filter {}
|
|
||||||
|
|
||||||
curl.includes()
|
|
||||||
end
|
|
||||||
|
|
||||||
function curl.includes()
|
|
||||||
filter "toolset:msc*"
|
|
||||||
includedirs {
|
|
||||||
path.join(curl.source, "include"),
|
|
||||||
}
|
|
||||||
|
|
||||||
defines {
|
|
||||||
"CURL_STRICTER",
|
|
||||||
"CURL_STATICLIB",
|
|
||||||
"CURL_DISABLE_LDAP",
|
|
||||||
}
|
|
||||||
filter {}
|
|
||||||
end
|
|
||||||
|
|
||||||
function curl.project()
|
|
||||||
if not os.istarget("windows") then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
project "curl"
|
|
||||||
language "C"
|
|
||||||
|
|
||||||
curl.includes()
|
|
||||||
|
|
||||||
includedirs {
|
|
||||||
path.join(curl.source, "lib"),
|
|
||||||
}
|
|
||||||
|
|
||||||
files {
|
|
||||||
path.join(curl.source, "lib/**.c"),
|
|
||||||
path.join(curl.source, "lib/**.h"),
|
|
||||||
}
|
|
||||||
|
|
||||||
defines {
|
|
||||||
"BUILDING_LIBCURL",
|
|
||||||
}
|
|
||||||
|
|
||||||
filter "toolset:msc*"
|
|
||||||
|
|
||||||
defines {
|
|
||||||
"USE_SCHANNEL",
|
|
||||||
"USE_WINDOWS_SSPI",
|
|
||||||
"USE_THREADS_WIN32",
|
|
||||||
}
|
|
||||||
|
|
||||||
filter {}
|
|
||||||
|
|
||||||
filter "toolset:not msc*"
|
|
||||||
|
|
||||||
defines {
|
|
||||||
"USE_GNUTLS",
|
|
||||||
"USE_THREADS_POSIX",
|
|
||||||
}
|
|
||||||
|
|
||||||
filter {}
|
|
||||||
|
|
||||||
warnings "Off"
|
|
||||||
kind "StaticLib"
|
|
||||||
end
|
|
||||||
|
|
||||||
table.insert(dependencies, curl)
|
|
@ -1,59 +0,0 @@
|
|||||||
#include <std_include.hpp>
|
|
||||||
|
|
||||||
#include "http.hpp"
|
|
||||||
#include <curl/curl.h>
|
|
||||||
|
|
||||||
namespace utils::http
|
|
||||||
{
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
size_t write_callback(void* contents, const size_t size, const size_t nmemb, void* userp)
|
|
||||||
{
|
|
||||||
static_cast<std::string*>(userp)->append(static_cast<char*>(contents), size * nmemb);
|
|
||||||
return size * nmemb;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::optional<std::string> get_data(const std::string& url, const headers& headers)
|
|
||||||
{
|
|
||||||
curl_slist* header_list = nullptr;
|
|
||||||
auto* curl = curl_easy_init();
|
|
||||||
if (!curl)
|
|
||||||
{
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
auto _ = gsl::finally([&]()
|
|
||||||
{
|
|
||||||
curl_slist_free_all(header_list);
|
|
||||||
curl_easy_cleanup(curl);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
for(const auto& header : headers)
|
|
||||||
{
|
|
||||||
auto data = header.first + ": "s + header.second;
|
|
||||||
header_list = curl_slist_append(header_list, data.data());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string buffer{};
|
|
||||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header_list);
|
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, url.data());
|
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
|
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
|
|
||||||
if (curl_easy_perform(curl) == CURLE_OK)
|
|
||||||
{
|
|
||||||
return {std::move(buffer)};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::future<std::optional<std::string>> get_data_async(const std::string& url, const headers& headers)
|
|
||||||
{
|
|
||||||
return std::async(std::launch::async, [url, headers]()
|
|
||||||
{
|
|
||||||
return get_data(url, headers);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <optional>
|
|
||||||
#include <future>
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
namespace utils::http
|
|
||||||
{
|
|
||||||
using headers = std::unordered_map<std::string, std::string>;
|
|
||||||
|
|
||||||
std::optional<std::string> get_data(const std::string& url, const headers& headers = {});
|
|
||||||
std::future<std::optional<std::string>> get_data_async(const std::string& url, const headers& headers = {});
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user