Hi all, I wanted to share a docker image that can be used to easily build mods, without worrying about environment setup.
This is useful if you want to have a pre-configured environment with all the build tools and SDK configured. Where you can just drop in some Java source files and point it at your Starsector directory, then build jars against your current game version. Supports any Java/Gradle version by just updating the numbers.
This is especially great if you don't want to configure IntelliJ manually on every machine, and you want to be able to simply drop in the files and run a build without manually installing dependencies.
I recommend some familiarity with Docker.
This sets up a JDK 8 Debian container with Gradle 7.2, which support outputting Java 7 bytecode to create mod jars that are fully compatible with current Starsector.
FROM debian:bookworm-slim
# install dependencies
RUN apt update \
# core
&& apt -y install bash curl wget unzip git apt-transport-https gnupg \
# jdk 8
&& wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | apt-key add - \
&& echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list \
&& apt update && apt -y install temurin-8-jdk \
# cleanup
&& rm -rf /var/lib/apt/lists/* && apt -y autoremove && apt -y clean
# install gradle 7.2
RUN wget -O /tmp/gradle-7.2-all.zip https://services.gradle.org/distributions/gradle-7.2-all.zip \
&& mkdir -p /opt/gradle \
&& unzip -q -d /opt/gradle /tmp/gradle-7.2-all.zip \
&& rm /tmp/gradle-7.2-all.zip
# run shell
CMD ["/bin/bash", "-l"]
This is meant to be used for a mod that can be built with Gradle. I was using this gradle build script:
https://github.com/wispborne/starsector-mod-template/blob/master/build.gradle.kts.
I modified it slightly to allow specifying the starsector dir as a Gradle property:
/**
* Where your Starsector game is installed to. Can be set using the `starsector.dir` Gradle property.
*/
val starsectorDirectory =
if (providers.gradleProperty("starsector.dir").isPresent) providers.gradleProperty("starsector.dir").get()
else "C:/Program Files (x86)/Fractal Softworks/Starsector"
println("Starsector directory: $starsectorDirectory")
If you use this image and any gradle project, you can build and run the container like this:
docker build -f ./starsector_mod_builder.docker -t localhost/starsector_mod_builder
docker run --rm -it -v $(pwd):/prj -v /path/to/your/starsector/dir:/starsector localhost/starsector_mod_builder /prj/your_build_script.sh
The above will mount your starsector gamedir into the container, and then run the build script inside the container
For a build script, use something as simple as:
cd /prj
/opt/gradle/gradle-7.2/bin/gradle -Pstarsector.dir="/starsector" build
This will then build jars for you!
I hope this is helpful.