Skip to content

Docker

You can build Docker images with Mineflake.

With Nix

First, you need to add mineflake to your flake.nix. You can read more here.

You can simply use buildMineflakeContainer function:

docker.nix
1
2
3
4
5
6
7
{ mineflake, ... }:

mineflake.buildMineflakeContainer {
    type = "spigot";
    command = "${jre_headless}/bin/java -Xms1G -Xmx1G -jar {} nogui";
    package = mineflake.paper;
}

Or if you want better layer caching, you can use buildMineflakeLayeredContainer function:

docker.nix
1
2
3
4
5
6
7
{ mineflake, ... }:

mineflake.buildMineflakeLayeredContainer {
    type = "spigot";
    command = "${jre_headless}/bin/java -Xms1G -Xmx1G -jar {} nogui";
    package = mineflake.paper;
}

Build derivation, then import it to Docker:

nix build .#docker
docker load < result

Then you can run it:

docker run -it --rm -p 25565:25565 -v $(pwd)/server:/data mineflake

With Dockerfile

You can also use Dockerfile to build Mineflake images:

Dockerfile
FROM rust:slim-buster as builder

RUN cargo install mineflake


FROM debian:buster-slim as final

ENV MINEFLAKE_CACHE=/cache
RUN mkdir -p $MINEFLAKE_CACHE

COPY --from=builder /usr/local/cargo/bin/mineflake /usr/local/bin/mineflake
COPY mineflake.yml /mineflake.yml

WORKDIR /data

# This will download all dependencies and cache them in Docker layer.
# So image can be run offline.
RUN mineflake vendor

CMD mineflake apply -r -c /mineflake.yml
Local packages in Dockerfile

Local packages are supported only if you COPY them to image at same path as in mineflake.yml.

Java is not included

If you need Java to run your server, you need to install it yourself. You can use openjdk:slim-buster image as base instead of debian:buster-slim.

This Dockerfile will build Mineflake image with mineflake.yml configuration and it dependencies.

Build it:

docker build -t mineflake .

Then you can run it:

docker run -it --rm -p 25565:25565 -v $(pwd)/server:/data mineflake