diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..864d8b2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM alpine:3 + +# Default variables (see docker.env and README.md) - get latest mcrcon version +ARG MCRCON_HOST=localhost +ARG MCRCON_PORT=25575 +ARG MCRCON_PASS + +RUN apk --update-cache --no-cache add build-base musl-dev + +ADD ./* /tmp/ + +WORKDIR /tmp +RUN make && make install && rm -rf /tmp/* + +WORKDIR / +ENTRYPOINT ["mcrcon"] diff --git a/README.md b/README.md index 300695a..d2ee0b3 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,27 @@ MCRCON_HOST MCRCON_PORT MCRCON_PASS ``` + +#### Docker usage + +_See "Usage" for commands._ + +If you want use rcon with docker, you can do it via script [docker.sh](./docker.sh): it will start an interactive rcon terminal. +Before starting the script, make you sure to edit properly the [env file](./docker.env) with your arguments. + +``` +./docker.sh +``` + +Instead, if you want use it as oneshot command, after build you can launch it like below reported: + +``` +docker run -it --rm --env-file docker.env tiiffi/mcrcon:latest "say Hello Minecraft World" +``` + +Note: `--rm` arguments helps you to clean docker workspace + + ###### Notes: - mcrcon will start in terminal mode if no commands are given - Command-line options will override environment variables diff --git a/docker.env b/docker.env new file mode 100644 index 0000000..42a1b8c --- /dev/null +++ b/docker.env @@ -0,0 +1,3 @@ +MCRCON_HOST=localhost +MCRCON_PORT=25575 +MCRCON_PASS=CHANGE_ME diff --git a/docker.sh b/docker.sh new file mode 100755 index 0000000..93b0cfd --- /dev/null +++ b/docker.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +docker build -t tiiffi/mcrcon:latest . +docker run -it --rm --env-file docker.env tiiffi/mcrcon:latest