Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 145 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: CI

on:
push:
branches: [ "main", "develop" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

env:
BUILD_TYPE: Release

jobs:
build-linux:
name: Build (Linux)
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [gcc, clang]
include:
- compiler: gcc
cc: gcc-12
cxx: g++-12
- compiler: clang
cc: clang-15
cxx: clang++-15

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
cmake \
ninja-build \
libssl-dev \
zlib1g-dev \
${{ matrix.compiler == 'clang' && 'clang-15' || '' }}

- name: Configure CMake
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
run: |
cmake -B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DENABLE_TELEMETRY=ON \
-DENABLE_SCRIPTING=OFF \
-DENABLE_COMPRESSION=ON \
-DBUILD_TESTS=ON

- name: Build
run: cmake --build build --parallel $(nproc)

- name: Run tests
working-directory: build
run: ctest --output-on-failure --timeout 120

- name: Upload build artifact
if: matrix.compiler == 'gcc'
uses: actions/upload-artifact@v4
with:
name: rs2v-server-linux
path: build/rs2v_server
retention-days: 7

build-windows:
name: Build (Windows)
runs-on: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Configure CMake
run: |
cmake -B build `
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} `
-DENABLE_TELEMETRY=ON `
-DENABLE_SCRIPTING=OFF `
-DENABLE_COMPRESSION=ON `
-DBUILD_TESTS=ON

- name: Build
run: cmake --build build --config ${{ env.BUILD_TYPE }} --parallel

- name: Run tests
working-directory: build
run: ctest -C ${{ env.BUILD_TYPE }} --output-on-failure --timeout 120

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: rs2v-server-windows
path: build/${{ env.BUILD_TYPE }}/rs2v_server.exe
retention-days: 7

static-analysis:
name: Static Analysis
runs-on: ubuntu-latest
needs: build-linux

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install cppcheck
run: sudo apt-get update && sudo apt-get install -y cppcheck

- name: Run cppcheck
run: |
cppcheck \
--enable=warning,performance,portability \
--suppress=missingIncludeSystem \
--inline-suppr \
--error-exitcode=1 \
-I src/ -I include/ -I telemetry/ \
--std=c++17 \
src/ telemetry/

docker:
name: Docker Build
runs-on: ubuntu-latest
needs: build-linux

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
push: false
tags: rs2v-server:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
74 changes: 74 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# RS2V Server - Multi-stage Docker build
# Stage 1: Build
FROM ubuntu:22.04 AS builder

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y \
build-essential \
cmake \
libssl-dev \
zlib1g-dev \
git \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /build

# Copy source code
COPY CMakeLists.txt ./
COPY src/ src/
COPY include/ include/
COPY telemetry/ telemetry/
COPY config/ config/
COPY data/ data/

# Build release
RUN mkdir -p build && cd build && \
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_TELEMETRY=ON \
-DENABLE_SCRIPTING=OFF \
-DENABLE_COMPRESSION=ON \
-DBUILD_TESTS=OFF && \
cmake --build . --parallel $(nproc) && \
cmake --install . --prefix /install

# Stage 2: Runtime
FROM ubuntu:22.04 AS runtime

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y \
libssl3 \
zlib1g \
ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& useradd -r -s /bin/false -m rs2v

WORKDIR /opt/rs2v

# Copy built binary and configuration
COPY --from=builder /install/bin/rs2v_server ./bin/
COPY --from=builder /install/etc/rs2v/ ./config/
COPY --from=builder /install/share/rs2v/data/ ./data/

# Create required directories
RUN mkdir -p logs telemetry/output protocol_analysis && \
chown -R rs2v:rs2v /opt/rs2v

# Environment configuration
ENV RS2V_CONFIG_FILE=/opt/rs2v/config/server.ini
ENV RS2V_LOG_DIR=/opt/rs2v/logs
ENV RS2V_TELEMETRY_DIR=/opt/rs2v/telemetry/output

# Expose game port, query port, EAC port, Prometheus metrics
EXPOSE 7777/udp 27015/udp 7957/tcp 9090/tcp

# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD test -f /opt/rs2v/logs/*.log || exit 1

USER rs2v

ENTRYPOINT ["./bin/rs2v_server"]
CMD ["-c", "config/server.ini"]
Loading
Loading