Skip to content

Commit

Permalink
Merge pull request #226 from lythx/docker-publish
Browse files Browse the repository at this point in the history
Create docker-publish.yml
  • Loading branch information
felacek authored Dec 30, 2023
2 parents 89eede1 + 587f8b0 commit b45d6da
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 26 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
schedule:
- cron: '19 22 * * *'
push:
branches: [ "main" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]

env:
# github.repository as <account>/<repo>
IMAGE_NAME: borecek/trakman


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

environment:
name: docker-publish

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
with:
cosign-release: 'v2.1.1'

# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into dockerhub
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: docker.io/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,30 @@

</div>

## Prerequisites
## Installation
The recommended and fastest way to install Trakman is by using Docker, you can find the instructions [here](https://github.com/lythx/trakman/wiki/Docker-Installation)

If you prefer not to use containers and/or want to install manually, [see this page instead](https://github.com/lythx/trakman/wiki/Manual-Installation)

## Manual Installation Requirements
- Trackmania Forever dedicated server [v2011-02-21 / Latest](http://files2.trackmaniaforever.com/TrackmaniaServer_2011-02-21.zip)
- Node.js [v16.9.0+](https://nodejs.org/en/download/)
- PostgreSQL [v11+](https://www.postgresql.org/download/)
- NodeJS [v14.21.3+](https://nodejs.org/en/download/) (we recommend using the latest LTS version)
- PostgreSQL [v12+](https://www.postgresql.org/download/)

On Linux, relevant versions of Node & Postgres should be available in your distro's repositories by default (see [[1]](https://repology.org/project/nodejs/versions), [[2]](https://repology.org/project/postgresql/versions))
On Linux, relevant versions of NodeJS & PostgreSQL should be available in your distro's repositories by default (see [here](https://repology.org/project/nodejs/versions) for NodeJS and [here](https://repology.org/project/postgresql/versions) for PostgreSQL)

On Windows, the installation instructions should be covered by the projects' websites (see above)

## Installation
See the [relevant wiki page](https://github.com/lythx/trakman/wiki/Installation-Instructions) on the matter

## XASECO Migration
Information about database migration is available on [this page](https://github.com/lythx/trakman/wiki/Migration-from-other-controllers)
Information about XASECO database migration is available on [this page](https://github.com/lythx/trakman/wiki/Migration-from-other-controllers)

## Default Plugins
## Included Plugins
The default shipment of the controller is (somewhat) outlined on [the wiki](https://github.com/lythx/trakman/wiki/Included-Plugins)

## Settings
Most controller configs descriptions are available on [this wiki page](https://github.com/lythx/trakman/wiki/Controller-Configs)
Most controller configuration options are available on [this wiki page](https://github.com/lythx/trakman/wiki/Controller-Configs)

## Limitations
1. Only the TimeAttack gamemode was fully tested
2. Stunts mode is NOT supported
3. Bugs, while rare, can still happen
1. Only the TimeAttack gamemode was thoroughly tested
2. Stunts mode is currently not supported
3. Bugs, while rare, can still happen, [reports are welcome](https://github.com/lythx/trakman/issues)
2 changes: 1 addition & 1 deletion config/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default {
* translation in commands. 0.4 is the default value */
nicknameToLoginSimilarityGoal: 0.4,
/** Represents minimal similarity difference between best
* and second-best match at which translation will be successfull.
* and second-best match at which translation will be successful.
* Used in nickname to login translation in commands. 0.15 is default value */
nicknameToLoginMinimumDifferenceBetweenMatches: 0.15,
/** Current controller version */
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.0"

services:
trakman:
image: trakman
image: borecek/trakman:main
container_name: trakman-server
restart: unless-stopped
volumes:
Expand Down
22 changes: 11 additions & 11 deletions plugins/ui/dynamic_components/ServerInfo.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import { Grid, componentIds, GridCellFunction, GridCellObject, centeredText, closeButton, PopupWindow } from '../UI.js'
import config from './ServerInfo.config.js'
import * as os from 'node:os'
import * as process from 'node:process'
import { arch, cpus, loadavg, totalmem, freemem, platform } from 'node:os'
import { uptime, version, memoryUsage } from 'node:process'
import 'dotenv/config'

export default class ServerInfoWindow extends PopupWindow {
Expand Down Expand Up @@ -50,18 +50,18 @@ export default class ServerInfoWindow extends PopupWindow {

private async getHostInfo(): Promise<string[]> {
// Host system information
const osUptime: string = tm.utils.getVerboseTime(~~os.uptime() * 1000) // Seconds
const osArch: string = os.arch()
const osCPU: string = os.cpus()[0].model
const osCPULoad: string = String(os.loadavg()[0] + `%`)
const osRAM: string = String(~~((os.totalmem() - os.freemem()) / (1024 ** 2)) + ` MB`) // Bytes
const osKernel: string = os.platform().toUpperCase()
const osUptime: string = tm.utils.getVerboseTime(~~uptime() * 1000) // Seconds
const osArch: string = arch()
const osCPU: string = cpus()[0].model
const osCPULoad: string = String(loadavg()[0] + `%`)
const osRAM: string = String(~~((totalmem() - freemem()) / (1024 ** 2)) + ` MB`) // Bytes
const osKernel: string = platform().toUpperCase()
// Trakman information
const trakmanVersion: string = tm.config.controller.version
const trakmanUptime: string = tm.utils.getVerboseTime(~~process.uptime() * 1000) // Seconds
const trakmanUptime: string = tm.utils.getVerboseTime(~~uptime() * 1000) // Seconds
// Node information
const nodeVersion: string = process.version
const nodeRAMUsage: string = String(~~(process.memoryUsage().heapTotal / (1024 ** 2)) + ` MB`)
const nodeVersion: string = version
const nodeRAMUsage: string = String(~~(memoryUsage().heapTotal / (1024 ** 2)) + ` MB`)
// Postgres information
const postgresVersion: string = String(`v` + (await tm.db.query(`select version();`) as any)[0].version).split(` `)[1]
const postgresDBSize: string = String((await tm.db.query(`select pg_size_pretty(pg_database_size('${process.env.DB_NAME}'));`) as any)[0].pg_size_pretty)
Expand Down

0 comments on commit b45d6da

Please sign in to comment.