Giter Club home page Giter Club logo

mrpack-container's Introduction

mrpack-container

Turn Modrinth modpack (.mrpack) files directly into ready-to-use container images.

mrpack-container is:

  • Fast
  • Does not require a JVM
  • Does not require a container runtime
  • Pure Rust

The resulting containers are:

  • Small, usually a few hundred MB depending on mods installed
  • Fast to start up, with no downloads on bootup required
  • Security focused, running as non-root with the majority of the filesystem immutable

Warnings

You are responsible for adhering to the licensing requirements of the mod files involved. This project is not affiliated with Modrinth. NOT AN OFFICIAL MINECRAFT PRODUCT. NOT APPROVED BY OR ASSOCIATED WITH MOJANG OR MICROSOFT.

This is pre-Alpha and is under construction. In particular, the code quality is awful because this is thrown together. Many things are not yet supported.

Installing

Right now you will need to clone this repository with git, and then build the mrpack-container binary with Rust. You will need to have a Rust toolchain installed for your platform.

For example:

git clone https://github.com/JamesLaverack/mrpack-container.git
cd mrpack-container
cargo build --release

Or, from inside the mrpack-container directory, you can directly build and execute using cargo run.

Building Images

You need a Modrinth format modpack file (i.e., a .mrpack file). You can find these on Modrinth, or use packwiz to convert other formats of modpack to the Modrinth format.

mrpack-container --output ./output my-modpack.mrpack

The output is in OCI format in the given directory, but not compressed. You can use tar to compress it into a single file: tar cf - -C ./output ..

You can load and execute the produced image directly with a container runtime.

tar cf - -C ./output/ . | podman load

or use Skopeo to upload it directly to a container runtime:

skopeo copy --format=oci oci:./output docker://registry.example.com/my-modpack:latest

Using Images

You will need to mount:

  • A Minecraft server var, usually at /usr/lib/minecraft/sever.jar
  • A file to accept the Minecraft EULA, usually a text file containing eula=true at /var/minecraft/eula.txt.

And you will probably want to mount:

  • A settings file, usually at /var/minecraft/server.properties
  • A directory to store the world saves, usually at /var/minecraft/world

For example:

# Minecraft 1.20.1
wget https://piston-data.mojang.com/v1/objects/84194a2f286ef7c14ed7ce0090dba59902951553/server.jar
# Doing this means you are accepting the Minecraft EULA
echo "eula=true" > eula.txt
mkdir world
podman run \
  -p 25565:25565 \
  -v "$(pwd)"/world:/var/minecraft/world \
  -v "$(pwd)"/server.jar:/usr/lib/minecraft/server.jar:ro \
  -v "$(pwd)"/eula.txt:/var/minecraft/eula.txt:ro \
  <container_id>

Will run the server and make it available on localhost:25565.

Container Structure

In general:

  • /bin, /lib, /usr/local/java, and /usr/share/doc are used for system-level dependencies, i.e., Java.
  • /usr/local/minecraft is used for immutable files to do with the Minecraft install.
  • /var/minecraft is used for things that are mostly expected to be mutable at runtime.

In detail:

  • /bin with a simlink for /bin/java (to /usr/local/java/bin/java)
  • /lib with the musl libc library
  • /usr/local/java with the JVM
  • /usr/local/minecraft/lib with modloader libraries
  • /usr/share/doc/musl with copyright information for musl

The files and overrides in the Modrinth file are unpacked into /var/minecraft. Permissions are set as 0755 or 0644, and most files are owned by root. Some files, depending on their name, are set as 0777 or 0666 instead, allowing the Minecraft process to write to them.

The container is intended to be run with the main process running as uid 1000 and gid 1000, therefore a number of directories are owned by that user instead:

  • /var/minecraft
  • /var/minecraft/config
  • /var/miencraft/libraries

Layers

The container makes extensive use of layering:

  • A base layer, of musl from Debian. Including only the shared library and copyright information.
  • a JRE
  • Your mod loader of choice
  • Each download from the mrpack file, one layer per download
  • Overrides from the mrpack file
  • Server overrides from the mrpack file
  • Permissions changes

mrpack-container's People

Contributors

dependabot[bot] avatar jameslaverack avatar

Stargazers

 avatar  avatar

Watchers

 avatar

mrpack-container's Issues

Build layers in parallel

It's possible to write the layers in parallel, as they don't depend on each other in our application. This would greatly reduce execution time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.