Skip to content
Open
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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
config.json
66 changes: 66 additions & 0 deletions .github/workflows/build-on-demand.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build image (on demand)

on:
workflow_dispatch:
inputs:
ref:
description: "Git ref to build (branch, tag, or SHA)"
default: "main"
required: true
extra_tag:
description: "Optional extra image tag (e.g., v1.2.3)"
required: false
push_latest:
description: "Also tag/push as :latest"
type: boolean
default: false
no_cache:
description: "Build without cache"
type: boolean
default: false

permissions:
contents: read
packages: write

env:
IMAGE_NAME: steam-presence

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.ref }}

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
# Always produce ref + sha tags; optionally add latest and/or a custom tag
tags: |
type=ref,event=branch
type=ref,event=tag
type=sha
${{ inputs.push_latest && 'type=raw,value=latest' || '' }}
${{ inputs.extra_tag != '' && format('type=raw,value={0}', inputs.extra_tag) || '' }}

- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
no-cache: ${{ inputs.no_cache }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

83 changes: 83 additions & 0 deletions .github/workflows/sync-and-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Sync upstream and build image

on:
schedule:
- cron: "23 4 * * 1" # Mondays 04:23 UTC
workflow_dispatch: {}

permissions:
contents: write # to push to main
packages: write # to push to GHCR

env:
UPSTREAM_REPO: JustTemmie/steam-presence
BRANCH: main
IMAGE_NAME: steam-presence

jobs:
sync:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.check.outputs.changed }}
steps:
- name: Checkout fork
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Add upstream and fetch
run: |
git remote add upstream https://github.com/${{ env.UPSTREAM_REPO }}.git || true
git fetch upstream ${{ env.BRANCH }}

- name: Check behind/ahead and merge if needed
id: check
run: |
git checkout $BRANCH
read BEHIND AHEAD < <(git rev-list --left-right --count upstream/$BRANCH...$BRANCH | awk '{print $1" "$2}')
echo "Behind: $BEHIND Ahead: $AHEAD"
if [ "$BEHIND" -gt 0 ]; then
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git merge --no-edit upstream/$BRANCH
git push origin $BRANCH
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "No changes to sync."
echo "changed=false" >> $GITHUB_OUTPUT
fi

build:
needs: sync
if: needs.sync.outputs.changed == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout updated main
uses: actions/checkout@v4
with:
ref: main

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=ref,event=branch
type=sha

- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,6 @@ dmypy.json

# Pyre type checker
.pyre/

# Docker
docker-compose.yaml
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.10-alpine

RUN apk update && apk --no-cache add build-base linux-headers python3-dev

WORKDIR /app

COPY requirements.txt .

RUN pip install -U -r requirements.txt --no-cache-dir

COPY . .

ENTRYPOINT ["python", "main.py"]
65 changes: 64 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,70 @@ follow the **setup** guide

and for linux users, run the [Installer](#automatic-installer)

for Nix/NixOS users, see the [Nix/NixOS](#nixnixos) section at the bottom.
### Docker

Alternatively you can build a docker image after cloning the repository.

```
docker build -t steam-presence:latest .
```

To run it you need to mount the path where the Discord socket file is. This might vary depending on your setup (and I'm not sure what the steps in Windows would be) but in a Linux install you can echo the content of `$XDG_RUNTIME_DIR` then mount that in the container.

You should also mount your `config.json` file.

```
docker run -e XDG_RUNTIME_DIR='/run/app' -v ~/path/to/steam-presence/config.json:/app/config.json -v /run/user/1000:/run/app:ro steam-presence:latest
```

Here we are assuming `$XDG_RUNTIME_DIR=/run/user/1000`.

#### Docker + Discord in Docker as well

You can run Discord itself in a docker container as an alternative to not have to install the Discord client on the host system. Be aware though that depending on the container you use resource usage can vary wildly.

Here's an example using the Discord container provided by KASM.

```
services:
kasm-discord:
container_name: kasm-discord
image: kasmweb/discord:1.14.0
restart: unless-stopped
ports:
- 6901:6901
shm_size: 512m
environment:
VNC_PW: password
XDG_RUNTIME_DIR: /run/user/1000
volumes:
- ./docker-data/kasm-discord/socket:/run/user/1000
- ./docker-data/kasm-discord/config/discord:/home/kasm-user/.config/discord
user: "0"
entrypoint: sh -c "chmod 700 /run/user/1000 && chown -R kasm-user:kasm-user /run/user/1000 && su kasm-user -c '/dockerstartup/kasm_default_profile.sh /dockerstartup/vnc_startup.sh /dockerstartup/kasm_startup.sh'"

steam-presence:
container_name: steam-presence
build:
context: ./
dockerfile: Dockerfile
restart: unless-stopped
environment:
XDG_RUNTIME_DIR: /run/user/1000
volumes:
- ./docker-data/steam-presence/config.json:/app/config.json
- ./docker-data/kasm-discord/socket:/run/user/1000:ro
depends_on:
- kasm-discord
```

Save that into a `docker-compose.yaml` file then do `docker compose up -d` to run it, dettach it and set it so that it auto-runs on system startup.

After that go into `https://<IP>:6901`, log in with `kasm_user` and the password you used in `VNC_PW`. From there you can log into your Discord account and it should work.

For the `steam-presence` container you need to mount your `config.json` file as indicated in the example.

For Nix/NixOS users, see the [Nix/NixOS](#nixnixos) section at the bottom.

## Setup
### Minimal
Expand Down
30 changes: 30 additions & 0 deletions docker-compose.yaml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
services:
kasm-discord:
container_name: kasm-discord
image: kasmweb/discord:1.14.0
restart: unless-stopped
ports:
- 6901:6901
shm_size: 512m
environment:
VNC_PW: password
XDG_RUNTIME_DIR: /run/user/1000
volumes:
- ./docker-data/kasm-discord/socket:/run/user/1000
- ./docker-data/kasm-discord/config/discord:/home/kasm-user/.config/discord
user: "0"
entrypoint: sh -c "chmod 700 /run/user/1000 && chown -R kasm-user:kasm-user /run/user/1000 && su kasm-user -c '/dockerstartup/kasm_default_profile.sh /dockerstartup/vnc_startup.sh /dockerstartup/kasm_startup.sh'"

steam-presence:
container_name: steam-presence
build:
context: ./
dockerfile: Dockerfile
restart: unless-stopped
environment:
XDG_RUNTIME_DIR: /run/user/1000
volumes:
- ./docker-data/steam-presence/config.json:/app/config.json
- ./docker-data/kasm-discord/socket:/run/user/1000:ro
depends_on:
- kasm-discord