Skip to content

Commit

Permalink
build: add Docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
diamante0018 committed Mar 22, 2024
1 parent bb66931 commit d43455a
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 7 deletions.
67 changes: 63 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ name: Build
on:
push:
branches:
- "*"
- "**"
tags:
- '[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- "*"
- "**"
types: [opened, synchronize, reopened]

concurrency:
Expand Down Expand Up @@ -168,10 +170,9 @@ jobs:
name: Deploy artifacts
needs: [build-win, build-linux, build-macos]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
if: github.ref_type == 'tag'
steps:
- name: Setup main environment
if: github.ref == 'refs/heads/master'
run: echo "ALTERWARE_MASTER_SERVER_PATH=${{ secrets.ALTERWARE_MASTER_SERVER_SSH_PATH }}" >> $GITHUB_ENV

- name: Download Release binaries
Expand All @@ -193,3 +194,61 @@ jobs:

- name: Publish changes
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/[email protected]

- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- id: meta
uses: docker/[email protected]
with:
images: |
alterware/master-server
tags: |
${{ github.ref_name }}
latest
- name: Build and Push Docker Image
id: build-and-push
uses: docker/[email protected]
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 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
# AlterWare: Master Server
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
- Install [Premake5][premake5-link] and add it to your system PATH
- Clone this repository using [Git][git-link]
Expand All @@ -18,6 +25,7 @@ Requirements for Unix systems:
- Customization: Modifications to the Premake5.lua script may be required
- 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
[git-link]: https://git-scm.com
[mold-link]: https://github.com/rui314/mold
Expand Down
2 changes: 1 addition & 1 deletion src/crypto_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace crypto_key

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());
Expand Down
10 changes: 8 additions & 2 deletions src/services/kill_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,14 @@ void kill_list::write_to_disk()
stream << entry.ip_address_ << " " << entry.reason_ << "\n";
}

utils::io::write_file(kill_file, stream.str(), false);
console::info("Wrote %s to disk (%zu entries)", kill_file, entries.size());
if (utils::io::write_file(kill_file, stream.str(), false))
{
console::info("Wrote %s to disk (%zu entries)", kill_file, entries.size());
}
else
{
console::error("Failed to write %s!", kill_file);
}
});
}

Expand Down

0 comments on commit d43455a

Please sign in to comment.