Skip to content

Commit 5c02314

Browse files
authored
Merge pull request #3 from airbornelamb/master
added docker support
2 parents ca22f6a + 8e18ab3 commit 5c02314

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
From python:3
2+
COPY main.py entrypoint.sh ./
3+
RUN pip install simpleobsws aiohttp
4+
ENTRYPOINT [ "sh", "./entrypoint.sh" ]

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ A Python-based program that provides HTTP endpoints for obs-websocket
99
- CD into the `obs-websocket-http` directory
1010
- Run with `python3.7 main.py`
1111

12+
## Running with Docker
13+
14+
- Clone/download the repository
15+
- Edit `docker-compose.yml` to have the correct IPs and ports for this machine and the one running OBS Studio (it may be the same machine). You do NOT need to edit `config.ini` if using docker because it will be created by the container from the values in `docker-compose.yml`.
16+
- Start obs-websocket-http by running `docker-compose up -d && docker-compose logs -f`. This will give you log output and you can press `Ctrl-C` when you wish to return to terminal and the container will run in the background.
17+
1218
## Protocol:
1319
This code contains two request endpoints. `/emit/{requesttype}` and `/call/{requesttype}`.
1420
- `/emit/{requesttype}` sends off a websocket event without waiting for a response, and immediately returns a generic `{"status":"ok"}` json response after sending the event, regardless of whether it errors out on the OBS instance.

docker-compose.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: '2.1'
2+
3+
services:
4+
obswebsocket:
5+
build: .
6+
restart: unless-stopped
7+
environment:
8+
- API_ADDRESS=127.0.0.1 # Address of this machine
9+
- API_PORT=4445 # Port you wish to use for API
10+
- API_KEY= # Auth key you wish to set
11+
- OBS_ADDRESS=127.0.0.1 # IP of machine running OBS Studio
12+
- OBS_PORT=4444 # OBS port
13+
- OBS_PASSWORD= # OBS password, if used
14+
ports:
15+
- "4445:4445" # Set to same value as API_PORT

entrypoint.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env sh
2+
3+
# Create config.ini
4+
cat << EOF > ./config.ini
5+
[http]
6+
bind_to_address = @api_address@
7+
bind_to_port = @api_port@
8+
authentication_key = @api_key@
9+
10+
[obsws]
11+
ws_address = @obs_address@
12+
ws_port = @obs_port@
13+
ws_password = @obs_password@
14+
EOF
15+
sed -i "s|@api_address@|${API_ADDRESS}|" ./config.ini
16+
sed -i "s|@api_port@|${API_PORT}|" ./config.ini
17+
sed -i "s|@api_key@|${API_KEY}|" ./config.ini
18+
19+
sed -i "s|@obs_address@|${OBS_ADDRESS}|" ./config.ini
20+
sed -i "s|@obs_port@|${OBS_PORT}|" ./config.ini
21+
sed -i "s|@obs_password@|${OBS_PASSWORD}|" ./config.ini
22+
23+
# Start the server
24+
python3 ./main.py

0 commit comments

Comments
 (0)