Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Seeking Advice: Dreambot installation in Unix Docker Container, configuring Quickstart to recognize local scripts


    send_splits

    Recommended Posts

    I'm trying to build a Docker image with CLI access using Quickstart. There is a tutorial out there for doing this in Windows, but I would like to use a Linux image. I would love to have a cluster with multiple images running different accounts.

    Trouble is, I cannot get the DBLauncher jar to run well in my Dockerfile. 

    FROM ubuntu:18.04
    #installing jdk and xvfb
    RUN apt-get update -y && apt-get upgrade -y && apt-get install -y openjdk-8-jdk xvfb
    #copying DBLauncher jar to image
    COPY /lib/DBLauncher.jar /usr/src/bot/DBLauncher.jar
    #copying script jars for client jar to reference
    COPY /lib/chickenkiller.jar /usr/src/bot/scripts/chickenkiller.jar
    COPY /lib/mining-skiller.jar /usr/src/bot/scripts/mining-skiller.jar
    #Running using xvfb so that X11 forwarding exceptions don't occur
    #Following same method as Windows tutorial, let launcher do its thing, terminate
    RUN xvfb-run java -jar /usr/src/bot/DBLauncher.jar &
    RUN sleep 5 && pkill -f "xvfb-run"
    #At this point I would like the java process to call the CLI commands to start the scripts
    #using quickstart ...
    CMD ["java", "-jar", "/usr/src/bot/app.jar"]

     

    This Dockerfile hangs in the image build stage because the launcher never progresses past "Downloaded latest client version! Checking integrity."

    I realize using xvfb-run is somewhat of a pain but otherwise running the launcher results in X11 forwarding exceptions since the Docker container doesn't have GUI capability. 

    image.thumb.png.a0849d98c3dee3e96c97a22c463a08f7.png

    I have tried forgetting about the DBLauncher setup and instead copying the /DreamBot installation directory onto my container. After that I start my script by calling the client jar and passing my credentials in via command line. The problem here is that the client doesn't recognize my local scripts even if they are in the /DreamBot/Scripts/ directory. The script manifests are correct because my script jars get picked up on my local machine, but in the container only the scripts I have downloaded on the Dreambot site show. 

    image.png.f163d86376a325499ada86108ab1fde6.png

     

    I have been stuck on this for a bit and would love if someone could chime in on the below questions. 

    I promise to make a tutorial on Docker containers if I get this working!

    Questions:

    -Does anybody have experience running the DBLauncher jar in a headless environment (ie without GUI access)? Did you have to mess around with X11 forwarding to get it to work?

    -Are there environment variables that I can set to point the client jar to my script directory containing the script jars? 

     

    Link to comment
    Share on other sites

    @yeeter01 awesome tutorial on automating the install/setup! I used that as a base for the above. 

     

    You mentioned you're using docker - can you share which base image you use for your containers? 

    Link to comment
    Share on other sites

    If anyone is curious I actually got this working. 

    Instead of trying to run the launcher in the Dockerfile I moved that part of the environment setup to runtime. 

     

    Dockerfile:

     

    FROM ubuntu:18.04
    
    #installing jdk, xvfb, and curl
    RUN apt-get update -y && apt-get upgrade -y && apt-get install -y openjdk-8-jdk xvfb curl
    
    #Pulling down DBLauncher jar
    RUN mkdir /usr/src/bot/
    RUN curl -L https://dreambot.org/DBLauncher.jar --output /usr/src/bot/launcher.jar
    
    #Copying necessary jars
    COPY /target/botnet-1.0-SNAPSHOT.jar /usr/src/bot/app.jar
    COPY /lib/chicken-killer.jar /root/DreamBot/Scripts/chickenkiller.jar
    
    CMD ["java", "-jar", "/usr/src/bot/app.jar"]

     

    Main Class:

     

    import java.io.IOException;
    import java.util.concurrent.TimeUnit;
    
    public class Main {
        public static void main(String[] args) throws IOException, InterruptedException {
            // First, run the launcher jar to pull down the client jar into $home/DreamBot/BotData
            Runtime rt = Runtime.getRuntime();
            Process firstInstall = rt.exec("xvfb-run java -jar /usr/src/bot/launcher.jar");
    
            //Kill after 15 seconds
            TimeUnit.SECONDS.sleep(15);
            firstInstall.destroy();
            firstInstall.waitFor();
    
            //Run your script using quickstart
            //Can pipe logs into a file, etc...
            //We are using xvfb-run as it handles X11 forwarding and we want to run the client headless
            execCmd("xvfb-run -a java -jar /root/DreamBot/BotData/client.jar -username yourUsername -password yourPassword " +
                    "-covert -accountUsername yourAccountUsername -accountPassword yourAccountPassword -render none -script ChickenKiller -world f2p");
        }
    
        public static void execCmd(String cmd) throws java.io.IOException {
            java.util.Scanner s = new java.util.Scanner(Runtime.getRuntime().exec(cmd).getInputStream()).useDelimiter("\\A");
            System.out.println(s.hasNext() ? s.next() : "");
        }
    }

     

    This achieves the basic functionality of running the dreambot client in a linux container. Once I have a multi container cluster configured with bots doing different tasks I will make a tutorial :). 

     

     

    Link to comment
    Share on other sites

    • 1 year later...
    On 7/30/2022 at 12:25 PM, send_splits said:

    If anyone is curious I actually got this working. 

    Instead of trying to run the launcher in the Dockerfile I moved that part of the environment setup to runtime. 

     

    Dockerfile:

     

    FROM ubuntu:18.04
    
    #installing jdk, xvfb, and curl
    RUN apt-get update -y && apt-get upgrade -y && apt-get install -y openjdk-8-jdk xvfb curl
    
    #Pulling down DBLauncher jar
    RUN mkdir /usr/src/bot/
    RUN curl -L https://dreambot.org/DBLauncher.jar --output /usr/src/bot/launcher.jar
    
    #Copying necessary jars
    COPY /target/botnet-1.0-SNAPSHOT.jar /usr/src/bot/app.jar
    COPY /lib/chicken-killer.jar /root/DreamBot/Scripts/chickenkiller.jar
    
    CMD ["java", "-jar", "/usr/src/bot/app.jar"]

     

    Main Class:

     

    import java.io.IOException;
    import java.util.concurrent.TimeUnit;
    
    public class Main {
        public static void main(String[] args) throws IOException, InterruptedException {
            // First, run the launcher jar to pull down the client jar into $home/DreamBot/BotData
            Runtime rt = Runtime.getRuntime();
            Process firstInstall = rt.exec("xvfb-run java -jar /usr/src/bot/launcher.jar");
    
            //Kill after 15 seconds
            TimeUnit.SECONDS.sleep(15);
            firstInstall.destroy();
            firstInstall.waitFor();
    
            //Run your script using quickstart
            //Can pipe logs into a file, etc...
            //We are using xvfb-run as it handles X11 forwarding and we want to run the client headless
            execCmd("xvfb-run -a java -jar /root/DreamBot/BotData/client.jar -username yourUsername -password yourPassword " +
                    "-covert -accountUsername yourAccountUsername -accountPassword yourAccountPassword -render none -script ChickenKiller -world f2p");
        }
    
        public static void execCmd(String cmd) throws java.io.IOException {
            java.util.Scanner s = new java.util.Scanner(Runtime.getRuntime().exec(cmd).getInputStream()).useDelimiter("\\A");
            System.out.println(s.hasNext() ? s.next() : "");
        }
    }

     

    This achieves the basic functionality of running the dreambot client in a linux container. Once I have a multi container cluster configured with bots doing different tasks I will make a tutorial :). 

     

     

    Did you ever get this going by chance? 

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.