From fcd99dcc09542ca1a96c1d1c8362ac2c6777b58e Mon Sep 17 00:00:00 2001 From: Lukrecja Date: Mon, 2 Feb 2026 17:35:01 +0100 Subject: [PATCH] add docker and docker compose files --- .dockerignore | 7 +++++++ .env.example | 8 ++++++++ .gitignore | 2 ++ Dockerfile | 31 +++++++++++++++++++++++++++++++ docker-compose-example.yml | 37 +++++++++++++++++++++++++++++++++++++ entrypoint.sh | 20 ++++++++++++++++++++ 6 files changed, 105 insertions(+) create mode 100644 .dockerignore create mode 100644 .env.example create mode 100644 Dockerfile create mode 100644 docker-compose-example.yml create mode 100644 entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..467dd31 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.git/ +.gitignore +target/ +config.toml +Dockerfile +docker-compose.yml +.dockerignore diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..687723f --- /dev/null +++ b/.env.example @@ -0,0 +1,8 @@ +LISTEN_ADDR=0.0.0.0:25565 +SERVER_ADDR=mc-container:25565 +MOTD_SERVER_ADDR=0.0.0.0:8081 +RCON_ADDR=mc-container:25575 +RCON_PASSWORD=password +IDLE_TIMEOUT_SECS=600 +POLLING_INTERVAL_MILLIS=10000 +CONTAINER_NAME=mc-container diff --git a/.gitignore b/.gitignore index 4a3b37d..dcecf30 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /target config.toml +.env +docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6285dfa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM rust:1.90-slim-bookworm AS builder + +WORKDIR /app + +RUN apt-get update && apt-get install -y \ + pkg-config \ + libssl-dev \ + && rm -rf /var/lib/apt/lists/* + +COPY Cargo.toml Cargo.lock ./ + +COPY src ./src +COPY assets ./assets + +RUN cargo build --release + +FROM debian:bookworm-slim + +WORKDIR /app + +RUN apt-get update && apt-get install -y \ + ca-certificates \ + libssl3 \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=builder /app/target/release/mc-proxy-controller /app/mc-proxy-controller + +COPY entrypoint.sh /app/entrypoint.sh +RUN chmod +x /app/entrypoint.sh + +ENTRYPOINT ["/app/entrypoint.sh"] diff --git a/docker-compose-example.yml b/docker-compose-example.yml new file mode 100644 index 0000000..b9fb456 --- /dev/null +++ b/docker-compose-example.yml @@ -0,0 +1,37 @@ +services: + mc-proxy-controller: + build: + context: . + dockerfile: Dockerfile + container_name: mc-proxy-controller + restart: unless-stopped + + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + + ports: + - "25565:25565" + - "8081:8081" + + environment: + LISTEN_ADDR: "0.0.0.0:25565" + + SERVER_ADDR: "mc-container:25565" + + MOTD_SERVER_ADDR: "0.0.0.0:8081" + + RCON_ADDR: "mc-container:25575" + RCON_PASSWORD: "${RCON_PASSWORD:-minecraft}" + + IDLE_TIMEOUT_SECS: "${IDLE_TIMEOUT_SECS:-900}" + POLLING_INTERVAL_MILLIS: "${POLLING_INTERVAL_MILLIS:-10000}" + + CONTAINER_NAME: "mc-container" + + networks: + - mc-container-network + +networks: + mc-container-network: + external: true + name: mc-container_default diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..ded234e --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -e + +cat > /app/config.toml <