Skip to content

Commit 9fd3577

Browse files
author
robled
committed
added container - resolves #94
* Dockerfile for image build * GitHub actions pushes to GitHub container registry * Example docker-compose.yml with integrated Discord client for headless operation * Updated README with info about it
1 parent c70155d commit 9fd3577

File tree

4 files changed

+157
-0
lines changed

4 files changed

+157
-0
lines changed

.github/workflows/container.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# https://docs.github.com/en/actions/tutorials/publish-packages/publish-docker-images#publishing-images-to-github-packages
2+
name: Create and publish a Docker image
3+
4+
# Configures this workflow to run every time a change is pushed to the branch called `main`.
5+
on:
6+
push:
7+
branches: ['main']
8+
9+
# Defines two custom environment variables for the workflow. These are used for the Container
10+
# registry domain, and a name for the Docker image that this workflow builds.
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
# There is a single job in this workflow. It's configured to run on the latest available version of
16+
# Ubuntu.
17+
jobs:
18+
build-and-push-image:
19+
runs-on: ubuntu-latest
20+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
21+
permissions:
22+
contents: read
23+
packages: write
24+
attestations: write
25+
id-token: write
26+
#
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v5
30+
# Uses the `docker/login-action` action to log in to the Container registry registry using the
31+
# account and password that will publish the packages. Once published, the packages are scoped
32+
# to the account defined here.
33+
- name: Log in to the Container registry
34+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
35+
with:
36+
registry: ${{ env.REGISTRY }}
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to
40+
# extract tags and labels that will be applied to the specified image. The `id` "meta" allows
41+
# the output of this step to be referenced in a subsequent step. The `images` value provides
42+
# the base name for the tags and labels.
43+
- name: Extract metadata (tags, labels) for Docker
44+
id: meta
45+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
46+
with:
47+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
48+
tags: |
49+
# Tag as 'latest' only on default branch
50+
type=raw,value=latest,enable={{is_default_branch}}
51+
# Tag with branch name
52+
type=ref,event=branch
53+
# Tag with git SHA
54+
type=sha,prefix={{branch}}-
55+
# Tag with the git tag that triggered the workflow
56+
type=ref,event=tag
57+
# This step uses the `docker/build-push-action` action to build the image, based on your
58+
# repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
59+
# It uses the `context` parameter to define the build's context as the set of files located in
60+
# the specified path. For more information, see
61+
# [Usage](https://github.com/docker/build-push-action#usage) in the README of the
62+
# `docker/build-push-action` repository.
63+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from
64+
# the "meta" step.
65+
- name: Build and push Docker image
66+
id: push
67+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
68+
with:
69+
context: .
70+
push: true
71+
tags: ${{ steps.meta.outputs.tags }}
72+
labels: ${{ steps.meta.outputs.labels }}
73+
74+
# This step generates an artifact attestation for the image, which is an unforgeable statement
75+
# about where and how it was built. It increases supply chain security for people who consume
76+
# the image. For more information, see [Using artifact attestations to establish provenance
77+
# for
78+
# builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
79+
- name: Generate artifact attestation
80+
uses: actions/attest-build-provenance@v3
81+
with:
82+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
83+
subject-digest: ${{ steps.push.outputs.digest }}
84+
push-to-registry: true
85+

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM python:3.14-slim
2+
3+
# Create a non-root user
4+
RUN groupadd -r app -g 1000 && \
5+
useradd -r -u 1000 -g app app
6+
7+
WORKDIR /app
8+
9+
# Copy requirements first (better layer caching)
10+
COPY requirements.txt .
11+
12+
# Install dependencies as root
13+
RUN pip install --no-cache-dir -r requirements.txt
14+
15+
# Copy application code and set ownership
16+
COPY --chown=app:app . .
17+
18+
# Make /app writable by appuser (for runtime file creation)
19+
RUN chown -R app:app /app
20+
21+
# Switch to non-root user
22+
USER app
23+
24+
# Run the application
25+
CMD ["python", "-u", "main.py"]

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ follow the **setup** guide
9090

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

93+
for Docker users, see the [Docker](#docker) section at the bottom.
94+
9395
for Nix/NixOS users, see the [Nix/NixOS](#nixnixos) section at the bottom.
9496

9597
## Setup
@@ -476,6 +478,14 @@ then run `crontab -e` and add `@reboot /home/USER/startup.sh` to the end of the
476478

477479
if you've done these steps the script should launch itself after your computer turns on.
478480

481+
## Docker
482+
483+
A Compose file example is available [here](docker-compose.yml). The example includes the desktop
484+
Discord client provided by [kasmweb](https://hub.docker.com/r/kasmweb/discord) which will allow you
485+
to run a headless stack on a server without requiring a traditional desktop Discord client.
486+
487+
The [config.json](#minimal) file is bind-mounted from the host filesystem to the necessary path in the `steam-presence` container.
488+
479489
## Nix/NixOS
480490

481491
If you use Nix flakes, this repository provides a package and a NixOS module.

docker-compose.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
services:
2+
steam-presence:
3+
image: ghcr.io/JustTemmie/steam-presence:latest
4+
container_name: steam-presence
5+
restart: unless-stopped
6+
depends_on:
7+
discord:
8+
condition: service_healthy # wait until discord passes its health‑check
9+
volumes:
10+
- tmp:/tmp
11+
- ./config.json:/app/config.json
12+
13+
# https://hub.docker.com/r/kasmweb/discord
14+
discord:
15+
image: kasmweb/discord:1.16.0
16+
container_name: discord
17+
restart: unless-stopped
18+
ports:
19+
- 6901:6901/tcp
20+
environment:
21+
# username is 'kasm_user'
22+
VNC_PW: changeme
23+
shm_size: 512m
24+
# check if the discord desktop app is running
25+
healthcheck:
26+
test: ["CMD", "curl", "127.0.0.1:6463"]
27+
interval: 5s
28+
timeout: 2s
29+
retries: 6
30+
start_period: 10s
31+
volumes:
32+
- tmp:/tmp
33+
- kasm-user:/home/kasm-user
34+
35+
volumes:
36+
tmp: # discord IPC socket is located in /tmp, so we share that dir to both containers
37+
kasm-user: # persist home directory of kasm user

0 commit comments

Comments
 (0)