From 5267ff11bed8ff4d676bc2cba9f7d8cd87a3089e Mon Sep 17 00:00:00 2001 From: phobos665 Date: Mon, 17 Nov 2025 15:39:13 +0000 Subject: [PATCH 1/3] feat(): Created Docker dev environment to be easily able to run samples and test code without having configured those dependencies locally. --- .dockerignore | 35 +++++++++++++++ Dockerfile | 40 +++++++++++++++++ docker-compose.yml | 28 ++++++++++++ javasteam-samples/build.gradle.kts | 12 ++++++ run-sample.sh | 69 ++++++++++++++++++++++++++++++ 5 files changed, 184 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100755 run-sample.sh 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..f54c5f64 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._031_get_categories_games.SampleGameCategories") +} + +// 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..46c625ea --- /dev/null +++ b/run-sample.sh @@ -0,0 +1,69 @@ +#!/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 031 myuser mypass" + echo "" + echo "Available samples:" + echo " 000 - Authentication" + echo " 001 - Authentication with QR Code" + echo " 015 - Achievements" + echo " 020 - Friends" + echo " 031 - Game Categories and Favorites" + 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" + ;; + "031") + SAMPLE_CLASS="in.dragonbra.javasteamsamples._031_get_categories_games.SampleGameCategories" + ;; + *) + 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 From d2f0e3dd914e2bbe53e4592686b1b10a71e9f35b Mon Sep 17 00:00:00 2001 From: phobos665 Date: Mon, 17 Nov 2025 15:43:55 +0000 Subject: [PATCH 2/3] feat(): removed testing sample --- run-sample.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/run-sample.sh b/run-sample.sh index 46c625ea..cfd72c98 100755 --- a/run-sample.sh +++ b/run-sample.sh @@ -5,14 +5,13 @@ set -e if [ -z "$1" ]; then echo "Usage: ./run-sample.sh [username] [password]" - echo "Example: ./run-sample.sh 031 myuser mypass" + 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 " 031 - Game Categories and Favorites" 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" @@ -43,9 +42,6 @@ case $SAMPLE_NUM in "020") SAMPLE_CLASS="in.dragonbra.javasteamsamples._020_friends.SampleFriends" ;; - "031") - SAMPLE_CLASS="in.dragonbra.javasteamsamples._031_get_categories_games.SampleGameCategories" - ;; *) echo "Unknown sample number: $SAMPLE_NUM" exit 1 From abd5eaa2e01f74ff7edad58860925f02f783ac99 Mon Sep 17 00:00:00 2001 From: phobos665 Date: Mon, 17 Nov 2025 15:45:33 +0000 Subject: [PATCH 3/3] feat(): adjusted the gradle --- javasteam-samples/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javasteam-samples/build.gradle.kts b/javasteam-samples/build.gradle.kts index f54c5f64..2c9bc0d0 100644 --- a/javasteam-samples/build.gradle.kts +++ b/javasteam-samples/build.gradle.kts @@ -29,7 +29,7 @@ dependencies { // 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._031_get_categories_games.SampleGameCategories") + mainClass.set(project.findProperty("mainClass") as String? ?: "in.dragonbra.javasteamsamples._000_authentication.SampleLogonAuthentication") } // Enable stdin for interactive 2FA input