From 910060cb6efb9a2fdc6ff18f86eaf04dfb77e788 Mon Sep 17 00:00:00 2001 From: Luke Cottage Date: Sun, 28 Feb 2021 13:29:51 +0100 Subject: [PATCH 1/3] [no refs]: containerized mcrcon --- Dockerfile | 17 +++++++++++++++++ README.md | 21 +++++++++++++++++++++ docker.env | 4 ++++ docker.sh | 4 ++++ 4 files changed, 46 insertions(+) create mode 100644 Dockerfile create mode 100644 docker.env create mode 100755 docker.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7ef2914 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM gcc:10 + +# Default variables (see docker.env and README.md) - get latest mcrcon version +ENV MCRCON_BIN_URL=https://github.com/Tiiffi/mcrcon/releases/download/v0.7.1/mcrcon-0.7.1-linux-x86-64.tar.gz +ARG MCRCON_HOST=localhost +ARG MCRCON_PORT=25575 +ARG MCRCON_PASS + +RUN apt-get update && apt-get -y install wget tar make musl-dev && rm -rf /var/lib/apt/lists/* + +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..7e53081 --- /dev/null +++ b/docker.env @@ -0,0 +1,4 @@ +MCRCON_BIN_URL=https://github.com/Tiiffi/mcrcon/releases/download/v0.7.1/mcrcon-0.7.1-linux-x86-64.tar.gz +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 From b747e9d57ba3f3f92becb2520ce500163e22d69a Mon Sep 17 00:00:00 2001 From: Luke Cottage Date: Sun, 28 Feb 2021 13:35:13 +0100 Subject: [PATCH 2/3] [no refs]: containerized mcrcon - removing unused envs --- Dockerfile | 1 - docker.env | 1 - 2 files changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7ef2914..a04524f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,6 @@ FROM gcc:10 # Default variables (see docker.env and README.md) - get latest mcrcon version -ENV MCRCON_BIN_URL=https://github.com/Tiiffi/mcrcon/releases/download/v0.7.1/mcrcon-0.7.1-linux-x86-64.tar.gz ARG MCRCON_HOST=localhost ARG MCRCON_PORT=25575 ARG MCRCON_PASS diff --git a/docker.env b/docker.env index 7e53081..42a1b8c 100644 --- a/docker.env +++ b/docker.env @@ -1,4 +1,3 @@ -MCRCON_BIN_URL=https://github.com/Tiiffi/mcrcon/releases/download/v0.7.1/mcrcon-0.7.1-linux-x86-64.tar.gz MCRCON_HOST=localhost MCRCON_PORT=25575 MCRCON_PASS=CHANGE_ME From c64ee2923ed8c49ebb41ffe5e4dce316565ab3c2 Mon Sep 17 00:00:00 2001 From: Luke Cottage Date: Mon, 1 Mar 2021 12:18:39 +0100 Subject: [PATCH 3/3] [no refs]: containerized mcrcon - optmized docker images size with alpine (from 1.2GB to 200MB) --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index a04524f..864d8b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM gcc:10 +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 apt-get update && apt-get -y install wget tar make musl-dev && rm -rf /var/lib/apt/lists/* +RUN apk --update-cache --no-cache add build-base musl-dev ADD ./* /tmp/