Skip to content

Commit 9d6c300

Browse files
Add support for MDAD playbook templates
1 parent 96534e8 commit 9d6c300

File tree

7 files changed

+86
-25
lines changed

7 files changed

+86
-25
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ phase*
1616
# Test binary, built with `go test -c`
1717
*.test
1818

19-
# Output of the go build
19+
# Output of the Go build
2020
/steam
2121
/build/
2222
steam-*
2323

24+
# Output of C# build
25+
steamkit-service
26+
2427
# Go workspace file
2528
go.work
2629

Dockerfile

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ WORKDIR /src/SteamBridge
1616
RUN if [ "$TARGETARCH" = "arm64" ]; then \
1717
export Protobuf_ProtocFullPath=$(which protoc); \
1818
dotnet restore --runtime linux-arm64; \
19-
dotnet publish -c Release --runtime linux-arm64 --self-contained false -o /app/SteamBridge/bin/Release/net8.0; \
19+
dotnet publish -c Release --runtime linux-arm64 --self-contained true -o /app; \
2020
else \
2121
dotnet restore --runtime linux-x64; \
22-
dotnet publish -c Release --runtime linux-x64 --self-contained false -o /app/SteamBridge/bin/Release/net8.0; \
23-
fi
22+
dotnet publish -c Release --runtime linux-x64 --self-contained true -o /app; \
23+
fi && \
24+
mv /app/SteamBridge /app/steamkit-service
2425

2526
# Stage 2: Build Go bridge
2627
FROM golang:1.24.6-alpine AS go-builder
@@ -57,12 +58,12 @@ RUN adduser -D -s /bin/sh -u 1000 bridge
5758

5859
# Create application directories
5960
WORKDIR /app
60-
RUN mkdir -p /app/SteamBridge/bin/Release/net8.0 /app/logs /app/data && \
61+
RUN mkdir -p /app/logs /app/data /app/config && \
6162
chown -R bridge:bridge /app
6263

6364
# Copy built applications
6465
COPY --from=go-builder /src/steam /app/steam
65-
COPY --from=dotnet-builder /app/SteamBridge/bin/Release/net8.0/ /app/SteamBridge/bin/Release/net8.0/
66+
COPY --from=dotnet-builder /app/ /app/
6667

6768
# Set proper permissions
6869
RUN chmod +x /app/steam && \
@@ -93,24 +94,18 @@ if [ ! -w /app/data ]; then
9394
fi
9495

9596
# Check if config exists
96-
if [ ! -f /app/data/config.yaml ]; then
97-
echo "No config file found at /app/data/config.yaml"
98-
echo "Please mount your config file to /app/data/config.yaml"
97+
if [ ! -f /app/config/config.yaml ]; then
98+
echo "No config file found at /app/config/config.yaml"
99+
echo "Please mount your config file to /app/config/config.yaml"
99100
echo "You can use the example config as a starting point:"
100-
echo " docker run -v /path/to/config.yaml:/app/data/config.yaml ..."
101+
echo " docker run -v /path/to/config.yaml:/app/config/config.yaml ..."
101102
exit 1
102103
fi
103104

104105
# Start the bridge
105106
echo "Starting Matrix Steam Bridge..."
106107

107-
# Check if config needs steam_bridge_path fix for Docker
108-
if grep -q "steam_bridge_path: ./SteamBridge" /app/data/config.yaml 2>/dev/null; then
109-
echo "Fixing steam_bridge_path for Docker environment..."
110-
sed -i 's|steam_bridge_path: ./SteamBridge|steam_bridge_path: /app/SteamBridge|g' /app/data/config.yaml
111-
fi
112-
113-
exec /app/steam -c /app/data/config.yaml "$@"
108+
exec /app/steam -c /app/config/config.yaml "$@"
114109
EOF
115110

116111
RUN chmod +x /app/entrypoint.sh && chown bridge:bridge /app/entrypoint.sh
@@ -119,9 +114,9 @@ RUN chmod +x /app/entrypoint.sh && chown bridge:bridge /app/entrypoint.sh
119114
USER bridge
120115

121116
# Set volumes
122-
VOLUME ["/app/data", "/app/logs"]
117+
VOLUME ["/app/config", "/app/data", "/app/logs"]
123118

124-
# Default working directory for mounted configs
125-
WORKDIR /app/data
119+
# Default working directory
120+
WORKDIR /app
126121

127122
ENTRYPOINT ["/app/entrypoint.sh"]

SteamBridge/SteamBridge.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<TargetFramework>net8.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8+
<PublishSingleFile>true</PublishSingleFile>
9+
<SelfContained>true</SelfContained>
810
</PropertyGroup>
911

1012
<ItemGroup>

build.sh

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,51 @@ fi
1111

1212
echo "Building SteamBridge C# service..."
1313
cd SteamBridge
14-
dotnet build --configuration Release
14+
15+
# Detect platform and set appropriate runtime and executable name
16+
case "$(uname -s)" in
17+
MINGW*|CYGWIN*|MSYS*)
18+
RUNTIME="win-x64"
19+
EXEC_NAME="steamkit-service.exe"
20+
SOURCE_BINARY="SteamBridge.exe"
21+
;;
22+
Darwin*)
23+
case "$(uname -m)" in
24+
arm64)
25+
RUNTIME="osx-arm64"
26+
;;
27+
*)
28+
RUNTIME="osx-x64"
29+
;;
30+
esac
31+
EXEC_NAME="steamkit-service"
32+
SOURCE_BINARY="SteamBridge"
33+
;;
34+
*)
35+
case "$(uname -m)" in
36+
aarch64|arm64)
37+
RUNTIME="linux-arm64"
38+
;;
39+
*)
40+
RUNTIME="linux-x64"
41+
;;
42+
esac
43+
EXEC_NAME="steamkit-service"
44+
SOURCE_BINARY="SteamBridge"
45+
;;
46+
esac
47+
48+
echo "Building for runtime: $RUNTIME"
49+
dotnet publish --configuration Release --self-contained true --runtime "$RUNTIME"
1550
if [ $? -ne 0 ]; then
1651
echo "Failed to build SteamBridge service"
1752
exit 1
1853
fi
1954
cd ..
2055

56+
echo "Moving SteamBridge binary to root level..."
57+
mv "SteamBridge/bin/Release/net8.0/$RUNTIME/publish/$SOURCE_BINARY" "./$EXEC_NAME"
58+
2159
echo "Build completed successfully!"
2260
echo " - Go bridge: steam"
23-
echo " - C# service: SteamBridge/bin/Release/net8.0/SteamBridge.dll"
61+
echo " - C# service: $EXEC_NAME"

docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ services:
33
image: ghcr.io/jasonlaguidice/matrix-steam-bridge:latest
44
restart: unless-stopped
55
volumes:
6-
# Mount config and data directory
6+
# Mount config directory
7+
- ./config:/app/config
8+
# Mount data directory
79
- ./data:/app/data
810
# Mount logs directory
911
- ./logs:/app/logs

pkg/connector/connector.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import (
66
"fmt"
77
"os"
88
"os/exec"
9+
"path/filepath"
10+
"runtime"
911
"strconv"
12+
"strings"
1013
"sync"
1114
"syscall"
1215
"time"
@@ -395,7 +398,25 @@ func (sc *SteamConnector) startSteamBridgeService(ctx context.Context) error {
395398
sc.steamProcessCancel = cancel
396399

397400
// Prepare the command to run the compiled executable
398-
cmd := exec.CommandContext(processCtx, "dotnet", "SteamBridge.dll")
401+
// Determine platform-specific executable name
402+
execName := "steamkit-service"
403+
if runtime.GOOS == "windows" {
404+
execName += ".exe"
405+
}
406+
407+
// Ensure we have an absolute path or explicit relative path
408+
var execPath string
409+
if filepath.IsAbs(sc.Config.Path) {
410+
execPath = filepath.Join(sc.Config.Path, execName)
411+
} else {
412+
// For relative paths, ensure we have an explicit "./" prefix
413+
execPath = filepath.Join(sc.Config.Path, execName)
414+
if !strings.HasPrefix(execPath, "./") && !strings.HasPrefix(execPath, "../") {
415+
execPath = "./" + execPath
416+
}
417+
}
418+
419+
cmd := exec.CommandContext(processCtx, execPath)
399420
cmd.Dir = sc.Config.Path
400421

401422
// Set environment variables including parent PID for monitoring

pkg/connector/example-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
steam_bridge_path: ./SteamBridge/bin/Release/net8.0
1+
steam_bridge_path: ./
22
steam_bridge_address: localhost:50051
33
steam_bridge_auto_start: true
44
steam_bridge_startup_timeout: 30

0 commit comments

Comments
 (0)