build: add Docker support

This commit is contained in:
Future 2024-03-22 16:13:30 +01:00
parent bb66931250
commit d43455a1d9
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
5 changed files with 93 additions and 7 deletions

View File

@ -3,10 +3,12 @@ name: Build
on: on:
push: push:
branches: branches:
- "*" - "**"
tags:
- '[0-9]+.[0-9]+.[0-9]+'
pull_request: pull_request:
branches: branches:
- "*" - "**"
types: [opened, synchronize, reopened] types: [opened, synchronize, reopened]
concurrency: concurrency:
@ -168,10 +170,9 @@ jobs:
name: Deploy artifacts name: Deploy artifacts
needs: [build-win, build-linux, build-macos] needs: [build-win, build-linux, build-macos]
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master' if: github.ref_type == 'tag'
steps: steps:
- name: Setup main environment - name: Setup main environment
if: github.ref == 'refs/heads/master'
run: echo "ALTERWARE_MASTER_SERVER_PATH=${{ secrets.ALTERWARE_MASTER_SERVER_SSH_PATH }}" >> $GITHUB_ENV run: echo "ALTERWARE_MASTER_SERVER_PATH=${{ secrets.ALTERWARE_MASTER_SERVER_SSH_PATH }}" >> $GITHUB_ENV
- name: Download Release binaries - name: Download Release binaries
@ -193,3 +194,61 @@ jobs:
- name: Publish changes - name: Publish changes
run: ssh ${{ secrets.ALTERWARE_MASTER_SERVER_SSH_USER }}@${{ secrets.ALTERWARE_MASTER_SERVER_SSH_ADDRESS }} ${{ secrets.ALTERWARE_SSH_SERVER_PUBLISH_COMMAND }} run: ssh ${{ secrets.ALTERWARE_MASTER_SERVER_SSH_USER }}@${{ secrets.ALTERWARE_MASTER_SERVER_SSH_ADDRESS }} ${{ secrets.ALTERWARE_SSH_SERVER_PUBLISH_COMMAND }}
docker:
name: Create Docker Image
needs: [build-win, build-linux, build-macos]
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
steps:
- name: Check out files
uses: actions/checkout@main
with:
sparse-checkout: |
Dockerfile
README.md
sparse-checkout-cone-mode: false
- name: Download Release binaries
uses: actions/download-artifact@main
- name: Compress Binaries
run: |
for dir in */; do
if [[ $dir == *"windows"* ]]; then
cd "$dir" && zip -r "../${dir%/}.zip" . && cd ..
else
tar -czvf "${dir%/}.tar.gz" -C "$dir" .
fi
done
shell: bash
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3.2.0
- name: Login to DockerHub
uses: docker/login-action@v3.1.0
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@v5.5.1
with:
images: |
alterware/master-server
tags: |
${{ github.ref_name }}
latest
- name: Build and Push Docker Image
id: build-and-push
uses: docker/build-push-action@v5.1.0
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

13
Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y libc++-dev libcurl4-gnutls-dev
COPY --chmod=755 ./linux-x64-release/alterware-master /usr/local/bin/
RUN groupadd alterware-master && useradd -r -g alterware-master alterware-master
USER alterware-master
EXPOSE 20810/udp
ENTRYPOINT ["/usr/local/bin/alterware-master"]

View File

@ -4,6 +4,13 @@
# AlterWare: Master Server # AlterWare: Master Server
This is the master server our clients use. It is based on the DP Master Server (ID Tech) protocol This is the master server our clients use. It is based on the DP Master Server (ID Tech) protocol
## Usage
Run using [Docker][docker-link]
```bash
docker run -p 20810:20810/udp alterware/master-server:latest
```
## Build ## Build
- Install [Premake5][premake5-link] and add it to your system PATH - Install [Premake5][premake5-link] and add it to your system PATH
- Clone this repository using [Git][git-link] - Clone this repository using [Git][git-link]
@ -18,6 +25,7 @@ Requirements for Unix systems:
- Customization: Modifications to the Premake5.lua script may be required - Customization: Modifications to the Premake5.lua script may be required
- Platform support: Details regarding supported platforms are available in [build.yml][build-link] - Platform support: Details regarding supported platforms are available in [build.yml][build-link]
[docker-link]: https://www.docker.com
[premake5-link]: https://premake.github.io [premake5-link]: https://premake.github.io
[git-link]: https://git-scm.com [git-link]: https://git-scm.com
[mold-link]: https://github.com/rui314/mold [mold-link]: https://github.com/rui314/mold

View File

@ -36,7 +36,7 @@ namespace crypto_key
if (!utils::io::write_file("./private.key", key.serialize())) if (!utils::io::write_file("./private.key", key.serialize()))
{ {
throw std::runtime_error("Failed to write server key!"); console::error("Failed to write server key!");
} }
console::info("Generated cryptographic key: %llX", key.get_hash()); console::info("Generated cryptographic key: %llX", key.get_hash());

View File

@ -142,8 +142,14 @@ void kill_list::write_to_disk()
stream << entry.ip_address_ << " " << entry.reason_ << "\n"; stream << entry.ip_address_ << " " << entry.reason_ << "\n";
} }
utils::io::write_file(kill_file, stream.str(), false); if (utils::io::write_file(kill_file, stream.str(), false))
{
console::info("Wrote %s to disk (%zu entries)", kill_file, entries.size()); console::info("Wrote %s to disk (%zu entries)", kill_file, entries.size());
}
else
{
console::error("Failed to write %s!", kill_file);
}
}); });
} }