diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..12ebbd1c --- /dev/null +++ b/.dockerignore @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..a5316b1a --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..b512d693 --- /dev/null +++ b/docker-compose.yml @@ -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 diff --git a/javasteam-samples/build.gradle.kts b/javasteam-samples/build.gradle.kts index 9deffead..2c9bc0d0 100644 --- a/javasteam-samples/build.gradle.kts +++ b/javasteam-samples/build.gradle.kts @@ -1,5 +1,6 @@ plugins { `java-library` + application } repositories { @@ -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= --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("run") { + standardInput = System.`in` +} diff --git a/run-sample.sh b/run-sample.sh new file mode 100755 index 00000000..cfd72c98 --- /dev/null +++ b/run-sample.sh @@ -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 [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