Skip to content
Draft
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
35 changes: 35 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Git
.git
.gitignore
.gitattributes

# Build outputs
build/
*/build/
.gradle/
out/

# IDE
.idea/
*.iml
.vscode/
*.swp
*.swo
*~

# OS
.DS_Store
Thumbs.db

# Documentation
*.md
!README.md
docs/

# CI/CD
.github/

# Docker
.dockerignore
Dockerfile
docker-compose.yml
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# JavaSteam Development Container
# Provides a consistent environment with Java 11 and all build tools

FROM eclipse-temurin:11-jdk

# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
unzip \
&& rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /workspace

# Copy gradle wrapper and build files first (for better caching)
COPY gradlew gradlew.bat ./
COPY gradle ./gradle
COPY build.gradle.kts settings.gradle.kts gradle.properties ./
COPY gradle/libs.versions.toml ./gradle/

# Copy buildSrc
COPY buildSrc ./buildSrc

# Download dependencies (cached layer)
RUN ./gradlew --no-daemon dependencies || true

# Copy source code
COPY src ./src
COPY javasteam-samples ./javasteam-samples
COPY javasteam-cs ./javasteam-cs
COPY javasteam-tf ./javasteam-tf
COPY javasteam-dota2 ./javasteam-dota2
COPY javasteam-deadlock ./javasteam-deadlock

# Build the project (generates proto and steamlanguage classes)
RUN ./gradlew build -x test -x signMavenJavaPublication --no-daemon

# Keep container running for development
CMD ["tail", "-f", "/dev/null"]
28 changes: 28 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: '3.8'

services:
javasteam-dev:
build:
context: .
dockerfile: Dockerfile
container_name: javasteam-dev
volumes:
# Mount source code for live development
- .:/workspace
# Preserve gradle cache between container restarts
- gradle-cache:/root/.gradle
environment:
# Set Java options if needed
- JAVA_OPTS=-Xmx2g
# Steam credentials (optional - can be passed at runtime)
- STEAM_USER=${STEAM_USER:-}
- STEAM_PASS=${STEAM_PASS:-}
working_dir: /workspace
stdin_open: true
tty: true
# Override command for interactive shell
command: /bin/bash

volumes:
gradle-cache:
driver: local
12 changes: 12 additions & 0 deletions javasteam-samples/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
`java-library`
application
}

repositories {
Expand All @@ -24,3 +25,14 @@ dependencies {
implementation(libs.zstd) // Content Downloading.
implementation(libs.xz) // Content Downloading.
}

// Allow running samples from command line
// Usage: ./gradlew :javasteam-samples:run -PmainClass=<fully.qualified.ClassName> --args="username password"
application {
mainClass.set(project.findProperty("mainClass") as String? ?: "in.dragonbra.javasteamsamples._000_authentication.SampleLogonAuthentication")
}

// Enable stdin for interactive 2FA input
tasks.named<JavaExec>("run") {
standardInput = System.`in`
}
65 changes: 65 additions & 0 deletions run-sample.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash
# Helper script to run JavaSteam samples inside Docker container

set -e

if [ -z "$1" ]; then
echo "Usage: ./run-sample.sh <sample_number> [username] [password]"
echo "Example: ./run-sample.sh 001 myuser mypass"
echo ""
echo "Available samples:"
echo " 000 - Authentication"
echo " 001 - Authentication with QR Code"
echo " 015 - Achievements"
echo " 020 - Friends"
echo ""
echo "If username/password not provided, will use STEAM_USER and STEAM_PASS env vars"
echo "Note: You will be prompted for 2FA code interactively after login attempt"
exit 1
fi

SAMPLE_NUM=$1
USERNAME=$2
PASSWORD=$3

if [ -z "$USERNAME" ] || [ -z "$PASSWORD" ]; then
echo "Error: Steam credentials not provided"
echo "Either pass them as arguments or set STEAM_USER and STEAM_PASS environment variables"
exit 1
fi

# Map sample numbers to class names
case $SAMPLE_NUM in
"000")
SAMPLE_CLASS="in.dragonbra.javasteamsamples._000_authentication.SampleLogonAuthentication"
;;
"001")
SAMPLE_CLASS="in.dragonbra.javasteamsamples._001_authenticationwithqrcode.SampleLogonAuthenticationQRCode"
;;
"015")
SAMPLE_CLASS="in.dragonbra.javasteamsamples._015_achievements.SampleAchievements"
;;
"020")
SAMPLE_CLASS="in.dragonbra.javasteamsamples._020_friends.SampleFriends"
;;
*)
echo "Unknown sample number: $SAMPLE_NUM"
exit 1
;;
esac

echo "Building project..."
./gradlew :javasteam-samples:classes --no-daemon

echo ""
echo "Running sample $SAMPLE_NUM: $SAMPLE_CLASS"
echo "Username: $USERNAME"
echo "========================================"
echo ""

# Run the sample with interactive stdin for 2FA codes
./gradlew :javasteam-samples:run \
-PmainClass="$SAMPLE_CLASS" \
--args="$USERNAME $PASSWORD" \
--console=plain \
--no-daemon