add docker and docker compose files

This commit is contained in:
2026-02-02 17:35:01 +01:00
parent 753d9e1e64
commit fcd99dcc09
6 changed files with 105 additions and 0 deletions

7
.dockerignore Normal file
View File

@@ -0,0 +1,7 @@
.git/
.gitignore
target/
config.toml
Dockerfile
docker-compose.yml
.dockerignore

8
.env.example Normal file
View File

@@ -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

2
.gitignore vendored
View File

@@ -1,2 +1,4 @@
/target
config.toml
.env
docker-compose.yml

31
Dockerfile Normal file
View File

@@ -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"]

View File

@@ -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

20
entrypoint.sh Normal file
View File

@@ -0,0 +1,20 @@
#!/bin/bash
set -e
cat > /app/config.toml <<EOF
listen_addr = "${LISTEN_ADDR:-0.0.0.0:25565}"
server_addr = "${SERVER_ADDR:-mc-server:25565}"
motd_server_addr = "${MOTD_SERVER_ADDR:-127.0.0.1:8081}"
rcon_addr = "${RCON_ADDR:-mc-server:25575}"
rcon_password = "${RCON_PASSWORD:-minecraft}"
idle_timeout_secs = ${IDLE_TIMEOUT_SECS:-300}
polling_interval_millis = ${POLLING_INTERVAL_MILLIS:-250}
container_name = "${CONTAINER_NAME:-mc-server}"
EOF
echo "Generated config.toml:"
cat /app/config.toml
echo ""
echo "Starting mc-proxy-controller..."
exec /app/mc-proxy-controller