Skip to content

Multi-stage Dockerfile with Gradle cache + local dependency copies #21

@raverydavis

Description

@raverydavis

We should implement a multi-stage Dockerfile that cache gradle dependencies and copies over the local dependencies for a Script - minimally that's just OSRSBot, but we can use DaxWalker as well

Here's an example that isn't quite right

# using multistage docker build
# ref: https://docs.docker.com/develop/develop-images/multistage-build/

# temp container to build using gradle
FROM gradle:7.4.2-jdk17-alpine AS TEMP_BUILD_IMAGE
ENV APP_HOME=/usr/app/
WORKDIR $APP_HOME
COPY build.gradle settings.gradle $APP_HOME

COPY gradle $APP_HOME/gradle
COPY --chown=gradle:gradle . /home/gradle/src
USER root
RUN chown -R gradle /home/gradle/src

RUN gradle build || return 0
COPY . .
RUN gradle clean build

# actual container

# Set base image from Docker image repo
# https://adoptium.net/temurin
FROM eclipse-temurin:17-jre-centos7

# Installs XDisplay packages so we can actually view the container (and run the bot)
RUN yum install libXext.x86_64 libXrender.x86_64 libXtst.x86_64 -y

ENV BOT_JAR_FILE=OSRSBot.jar
ENV APP_HOME=/usr/app/

# Adds the bot jar to the container
COPY --from=TEMP_BUILD_IMAGE $APP_HOME/$BOT_JAR_FILE .
# Adds the scripts to the container
COPY --from=TEMP_BUILD_IMAGE $APP_HOME/build/libs root/.config/OsrsBot/Scripts/Precompiled

# Exposes a port to connect via
EXPOSE 8080

# Runs the bot with the bot flag
ENTRYPOINT exec java -jar ${BOT_JAR_FILE} -bot-runelite -developer-mode

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions