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 :).