mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-02-18 07:26:24 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
998a5b4180 | ||
|
|
c45d3e2fdd | ||
|
|
308a7766fa | ||
|
|
53591311ac | ||
|
|
377cd569bc | ||
|
|
cf6761156c | ||
|
|
5cbf1e0785 | ||
|
|
f1cacb7c36 | ||
|
|
ca67f24298 | ||
|
|
5698e784a1 | ||
|
|
a357c8a793 | ||
|
|
0843d19722 |
@@ -92,19 +92,19 @@ jobs:
|
||||
platforms: linux/amd64,linux/arm/v7,linux/arm64
|
||||
mcVersion: 1.12.2
|
||||
# Pin version for Java 8
|
||||
# mcHelperVersion: 1.46.0
|
||||
mcHelperVersion: 1.51.1
|
||||
- variant: java8-graalvm-ce
|
||||
baseImage: ghcr.io/graalvm/graalvm-ce:java8
|
||||
platforms: linux/amd64
|
||||
mcVersion: 1.12.2
|
||||
# Pin version for Java 8
|
||||
# mcHelperVersion: 1.46.0
|
||||
mcHelperVersion: 1.51.1
|
||||
- variant: java8-jdk
|
||||
baseImage: eclipse-temurin:8u312-b07-jdk-focal
|
||||
platforms: linux/amd64,linux/arm64
|
||||
mcVersion: 1.12.2
|
||||
# Pin version for Java 8
|
||||
# mcHelperVersion: 1.46.0
|
||||
mcHelperVersion: 1.51.1
|
||||
env:
|
||||
IMAGE_TO_TEST: "${{ github.repository_owner }}/minecraft-server:test-${{ matrix.variant }}-${{ github.run_id }}"
|
||||
HAS_IMAGE_REPO_ACCESS: ${{ secrets.DOCKER_USER != '' && secrets.DOCKER_PASSWORD != '' }}
|
||||
@@ -112,7 +112,7 @@ jobs:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6.0.0
|
||||
uses: actions/checkout@v6.0.1
|
||||
with:
|
||||
# for build-files step
|
||||
fetch-depth: 0
|
||||
@@ -149,7 +149,7 @@ jobs:
|
||||
org.opencontainers.image.authors=Geoff Bourne <itzgeoff@gmail.com>
|
||||
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3.11.1
|
||||
uses: docker/setup-buildx-action@v3.12.0
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3.7.0
|
||||
10
.github/workflows/verify-pr.yml
vendored
10
.github/workflows/verify-pr.yml
vendored
@@ -1,8 +1,8 @@
|
||||
name: Verify PR
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
types: [assigned, opened, synchronize, labeled]
|
||||
branches:
|
||||
- master
|
||||
paths-ignore:
|
||||
- "*.md"
|
||||
- "docs/**"
|
||||
@@ -44,19 +44,19 @@ jobs:
|
||||
platforms: linux/amd64
|
||||
mcVersion: 1.12.2
|
||||
# Pin version for Java 8
|
||||
# mcHelperVersion: 1.42.1
|
||||
mcHelperVersion: 1.51.1
|
||||
env:
|
||||
IMAGE_TO_TEST: ${{ github.repository_owner }}/minecraft-server:test-${{ matrix.variant }}-${{ github.run_id }}
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6.0.0
|
||||
uses: actions/checkout@v6.0.1
|
||||
with:
|
||||
# for build-files step
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3.11.1
|
||||
uses: docker/setup-buildx-action@v3.12.0
|
||||
|
||||
- name: Confirm multi-arch build
|
||||
uses: docker/build-push-action@v6.18.0
|
||||
|
||||
@@ -44,12 +44,12 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
|
||||
--var version=${MC_MONITOR_VERSION} --var app=mc-monitor --file {{.app}} \
|
||||
--from ${GITHUB_BASEURL}/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
|
||||
|
||||
ARG MC_SERVER_RUNNER_VERSION=1.14.0
|
||||
ARG MC_SERVER_RUNNER_VERSION=1.14.1
|
||||
RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
|
||||
--var version=${MC_SERVER_RUNNER_VERSION} --var app=mc-server-runner --file {{.app}} \
|
||||
--from ${GITHUB_BASEURL}/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
|
||||
|
||||
ARG MC_HELPER_VERSION=1.51.1
|
||||
ARG MC_HELPER_VERSION=1.52.1
|
||||
ARG MC_HELPER_BASE_URL=${GITHUB_BASEURL}/itzg/mc-image-helper/releases/download/${MC_HELPER_VERSION}
|
||||
# used for cache busting local copy of mc-image-helper
|
||||
ARG MC_HELPER_REV=1
|
||||
|
||||
@@ -77,15 +77,68 @@ The openj9 image tags include specific variables to simplify configuration:
|
||||
- `-e TUNE_NURSERY_SIZES=TRUE` : configures nursery sizes where the initial size is 50%
|
||||
of the `MAX_MEMORY` and the max size is 80%.
|
||||
|
||||
## Enabling rolling logs
|
||||
## Customizing log4j2 configuration
|
||||
|
||||
By default the vanilla log file will grow without limit. The logger can be reconfigured to use a rolling log files strategy by using:
|
||||
The image now uses a templated log4j2 configuration based on PaperMC's logging setup, which is automatically applied for versions that don't require Log4j security patches. This configuration provides rolling logs and advanced logging features by default.
|
||||
|
||||
```
|
||||
-e ENABLE_ROLLING_LOGS=true
|
||||
### Customization via environment variables
|
||||
|
||||
You can customize various aspects of the logging behavior using environment variables:
|
||||
|
||||
- `LOG_LEVEL` : Root logger level (default: `info`)
|
||||
```
|
||||
-e LOG_LEVEL=debug
|
||||
```
|
||||
|
||||
- `ROLLING_LOG_FILE_PATTERN` : Pattern for rolled log file names (default: `logs/%d{yyyy-MM-dd}-%i.log.gz`)
|
||||
```
|
||||
-e ROLLING_LOG_FILE_PATTERN="logs/archive/%d{yyyy-MM-dd}-%i.log.gz"
|
||||
```
|
||||
|
||||
- `ROLLING_LOG_MAX_FILES` : Maximum number of archived log files to keep (default: `1000`)
|
||||
```
|
||||
-e ROLLING_LOG_MAX_FILES=30
|
||||
```
|
||||
|
||||
### Customizing log message formats
|
||||
|
||||
For full control over how log messages are formatted, you can customize the Log4j2 pattern layouts using these variables. These use [Log4j2 Pattern Layout syntax](https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout):
|
||||
|
||||
- `LOG_CONSOLE_FORMAT` : Format for console output (what you see in `docker logs`)
|
||||
Default: `[%d{HH:mm:ss}] [%t/%level]: %msg%n`
|
||||
|
||||
- `LOG_FILE_FORMAT` : Format for file logs (written to `logs/latest.log`)
|
||||
Default: `[%d{HH:mm:ss}] [%t/%level]: %msg%n`
|
||||
|
||||
- `LOG_TERMINAL_FORMAT` : Format for interactive terminal console (used with `docker attach`)
|
||||
Default: `[%d{HH:mm:ss} %level]: %msg%n`
|
||||
|
||||
### Example configurations
|
||||
|
||||
Simple timestamp customization (most common use case):
|
||||
```yaml
|
||||
environment:
|
||||
# What you see in docker logs
|
||||
LOG_CONSOLE_FORMAT: "[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%t/%level]: %msg%n"
|
||||
# What gets written to logs/latest.log
|
||||
LOG_FILE_FORMAT: "[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%t/%level]: %msg%n"
|
||||
```
|
||||
|
||||
> **NOTE** this will interfere with interactive/color consoles [as described in the section above](#interactive-and-color-console)
|
||||
Advanced customization:
|
||||
```yaml
|
||||
environment:
|
||||
LOG_LEVEL: debug
|
||||
# Custom ISO8601 format with logger names
|
||||
LOG_CONSOLE_FORMAT: "%d{ISO8601} %-5level [%t] %logger{36} - %msg%n"
|
||||
LOG_FILE_FORMAT: "%d{ISO8601} %-5level [%t] %logger{36} - %msg%n"
|
||||
ROLLING_LOG_MAX_FILES: 50
|
||||
```
|
||||
|
||||
### Legacy ENABLE_ROLLING_LOGS option
|
||||
|
||||
The `ENABLE_ROLLING_LOGS` environment variable is no longer needed for most use cases, as rolling logs are now enabled by default through the templated configuration. This option is maintained for backward compatibility but is only checked for error reporting when rolling logs cannot be used due to Log4j security patches.
|
||||
|
||||
> **NOTE** The templated log4j2 configuration may interfere with interactive/color consoles [as described in the section above](#interactive-and-color-console)
|
||||
|
||||
## Timezone Configuration
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ where, in this case, the standard server port 25565 will be exposed on your host
|
||||
# ... image and environment section
|
||||
volumes:
|
||||
# attach the relative directory 'data' to the container's /data path
|
||||
./data:data
|
||||
- ./data:data
|
||||
```
|
||||
|
||||
!!! note
|
||||
@@ -84,3 +84,4 @@ Follow the logs of the container using `docker compose logs -f`, check on the st
|
||||
|
||||
!!! note "Deployment Examples"
|
||||
The [deployments page](misc/deployment/index.md) provides more examples of deployment with and beyond Docker Compose.
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@ A `.skip-pause` file can be created in the `/data` directory to make the server
|
||||
|
||||
A starting, example compose file has been provided in [the examples](https://github.com/itzg/docker-minecraft-server/blob/master/examples/autopause/compose.yml).
|
||||
|
||||
Auto-pause is not compatible with `EXEC_DIRECTLY=true` and the two cannot be set together.
|
||||
|
||||
!!! note
|
||||
|
||||
When configuring kubernetes readiness/liveness health checks with auto-pause enabled, be sure to reference the `mc-health` wrapper script rather than `mc-status` directly.
|
||||
|
||||
@@ -25,8 +25,8 @@ If rcon is disabled you can send commands by passing them as arguments to the pa
|
||||
|
||||
```shell
|
||||
docker exec --user 1000 mc mc-send-to-console op player
|
||||
| |
|
||||
+- container name +- Minecraft commands start here
|
||||
| |
|
||||
+- container name +- Minecraft commands start here
|
||||
```
|
||||
|
||||
## Enabling interactive console
|
||||
|
||||
@@ -3,7 +3,7 @@ title: With websocket
|
||||
---
|
||||
|
||||
With `WEBSOCKET_CONSOLE` set to `true`, logs can be streamed, and commands sent, over a websocket connection.
|
||||
The API is available on `/websocket`.
|
||||
The API is available on `/console`.
|
||||
|
||||
## Password
|
||||
A password must be supplied using the `Sec-WebSocket-Protocol` header. This is done by putting `mc-server-runner-ws-v1` in the first slot, and the password in the second. The password can be set with `RCON_PASSWORD` or `WEBSOCKET_PASSWORD`. The latter overwrites the former. Authentication can be disabled with `WEBSOCKET_DISABLE_AUTHENTICATION`.
|
||||
|
||||
@@ -57,9 +57,45 @@ alternatively, you can mount: <code>/etc/localtime:/etc/localtime:ro
|
||||
<td><code>UTC</code></td>
|
||||
<td>⬜️</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>LOG_LEVEL</code></td>
|
||||
<td>Root logger level (trace, debug, info, warn, error)</td>
|
||||
<td><code>info</code></td>
|
||||
<td>⬜️</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>LOG_CONSOLE_FORMAT</code></td>
|
||||
<td>Log4j2 pattern for console output (what you see in <code>docker logs</code>)</td>
|
||||
<td><code>[%d{HH:mm:ss}] [%t/%level]: %msg%n</code></td>
|
||||
<td>⬜️</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>LOG_FILE_FORMAT</code></td>
|
||||
<td>Log4j2 pattern for file logs (written to <code>logs/latest.log</code>)</td>
|
||||
<td><code>[%d{HH:mm:ss}] [%t/%level]: %msg%n</code></td>
|
||||
<td>⬜️</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>LOG_TERMINAL_FORMAT</code></td>
|
||||
<td>Log4j2 pattern for interactive terminal console (used with <code>docker attach</code>)</td>
|
||||
<td><code>[%d{HH:mm:ss} %level]: %msg%n</code></td>
|
||||
<td>⬜️</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>ROLLING_LOG_FILE_PATTERN</code></td>
|
||||
<td>Pattern for rolled/archived log file names</td>
|
||||
<td><code>logs/%d{yyyy-MM-dd}-%i.log.gz</code></td>
|
||||
<td>⬜️</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>ROLLING_LOG_MAX_FILES</code></td>
|
||||
<td>Maximum number of archived log files to keep</td>
|
||||
<td><code>1000</code></td>
|
||||
<td>⬜️</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>ENABLE_ROLLING_LOGS</code></td>
|
||||
<td>By default the vanilla log file will grow without limit. The logger can be reconfigured to use a rolling log files strategy by setting this to <code>true</code></td>
|
||||
<td><strong>Legacy option.</strong> Rolling logs are now enabled by default via templated log4j2 configuration. This option is maintained for backward compatibility but only used for error reporting</td>
|
||||
<td><code>false</code></td>
|
||||
<td>⬜️</td>
|
||||
</tr>
|
||||
@@ -403,12 +439,6 @@ alternatively, you can mount: <code>/etc/localtime:/etc/localtime:ro
|
||||
<td><code></code></td>
|
||||
<td>⬜️</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>EXEC_DIRECTLY</code></td>
|
||||
<td>If you would like to docker attach to the Minecraft server console with color and interactive capabilities, then set to <code>true</code></td>
|
||||
<td><code>false</code></td>
|
||||
<td>⬜️</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>STOP_SERVER_ANNOUNCE_DELAY</code></td>
|
||||
<td>To allow time for players to finish what they're doing during a graceful server shutdown, set <code>STOP_SERVER_ANNOUNCE_DELAY</code> to a number of seconds to delay after an announcement is posted by the server.</td>
|
||||
@@ -609,10 +639,6 @@ alternatively, you can mount: <code>/etc/localtime:/etc/localtime:ro
|
||||
|
||||
### Auto-Pause
|
||||
|
||||
!!! note
|
||||
|
||||
Autopause is not compatible with `EXEC_DIRECTLY=true` and the two cannot be set together.
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
@@ -16,13 +16,13 @@ where `<tag>` refers to the first column of this table:
|
||||
| stable | 21 | Ubuntu | Hotspot | amd64, arm64 | |
|
||||
| java25 | 25 | Ubuntu | Hotspot | amd64, arm64 | |
|
||||
| java25-jdk | 25 | Ubuntu | Hotspot+JDK | amd64, arm64 | |
|
||||
| java25-graalvm | 25 | Oracle | Oracle GraalVM (3) | amd64, arm64 | |
|
||||
| java25-graalvm | 25 | Oracle | Oracle GraalVM (3) | amd64, arm64 | (5) |
|
||||
| java21 | 21 | Ubuntu | Hotspot | amd64, arm64 | |
|
||||
| java21-jdk | 21 | Ubuntu | Hotspot+JDK | amd64, arm64 | |
|
||||
| java21-alpine | 21 | Alpine | Hotspot | amd64, arm64 | |
|
||||
| java21-graalvm | 21 | Oracle | Oracle GraalVM (3) | amd64, arm64 | |
|
||||
| java21-graalvm | 21 | Oracle | Oracle GraalVM (3) | amd64, arm64 | (5) |
|
||||
| java17 | 17 | Ubuntu | Hotspot | amd64, arm64, armv7 | |
|
||||
| java17-graalvm | 17 | Oracle | Oracle GraalVM (3) | amd64, arm64 | |
|
||||
| java17-graalvm | 17 | Oracle | Oracle GraalVM (3) | amd64, arm64 | (5) |
|
||||
| java16 | 16 | Ubuntu | Hotspot | amd64, arm64, armv7 | (4) |
|
||||
| java11 | 11 | Ubuntu | Hotspot | amd64, arm64, armv7 | |
|
||||
| java8 | 8 | Ubuntu | Hotspot | amd64, arm64, armv7 | |
|
||||
@@ -33,6 +33,7 @@ Notes
|
||||
2. Short-term variant, subject to deprecation upon next version introduction
|
||||
3. Based on the [Oracle GraalVM images](https://blogs.oracle.com/java/post/new-oracle-graalvm-container-images), which as of JDK 17, are now under the [GraalVM Free License](https://blogs.oracle.com/java/post/graalvm-free-license) incorporating what used to be known as the GraalVM Enterprise.
|
||||
4. This version of Java is [recommended for PaperMC 1.16.5](https://docs.papermc.io/paper/getting-started/#requirements)
|
||||
5. Due to these images using Oracle Linux, (which is based on Red Hat Enterprise Linux) Forge Installer will not work due to its use of zlib-ng. Use other images for initial installation and Forge version upgrade.
|
||||
|
||||
!!! example "Example using java8"
|
||||
|
||||
@@ -144,4 +145,5 @@ The following image tags have been deprecated and are no longer receiving update
|
||||
|
||||
## JSON Listing
|
||||
|
||||
Information about the image tags is available for programmatic access at <https://raw.githubusercontent.com/itzg/docker-minecraft-server/refs/heads/master/images.json>
|
||||
|
||||
Information about the image tags is available for programmatic access at <https://raw.githubusercontent.com/itzg/docker-minecraft-server/refs/heads/master/images.json>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
To use a different Minecraft version, pass the `VERSION` environment variable (case sensitive), which can have the value
|
||||
|
||||
- LATEST (the default)
|
||||
- SNAPSHOT
|
||||
- a specific version, such as "1.7.9"
|
||||
- `LATEST` for latest release (the default)
|
||||
- `SNAPSHOT` for latest snapshot
|
||||
- a specific version, such as `1.7.9`, `25w35a`, `26.1`, or `26.1-snapshot-1`
|
||||
- or an alpha and beta version, such as "b1.7.3" (server download might not exist)
|
||||
|
||||
For example, to use the latest snapshot:
|
||||
|
||||
@@ -110,9 +110,20 @@ services:
|
||||
####################################################################
|
||||
# Logging Options #
|
||||
# #
|
||||
# Set to "true" to delete old logs #
|
||||
# Rolling logs are now enabled by default with templated #
|
||||
# log4j2 configuration. You can customize: #
|
||||
# #
|
||||
# LOG_LEVEL: Log level (default: info) #
|
||||
# LOG_CONSOLE_FORMAT: Console output format (docker logs) #
|
||||
# LOG_FILE_FORMAT: File log format (logs/latest.log) #
|
||||
# ROLLING_LOG_MAX_FILES: Max archived files (default: 1000) #
|
||||
# #
|
||||
# Example: Add full timestamp to logs #
|
||||
# LOG_CONSOLE_FORMAT: "[%d{yyyy-MM-dd HH:mm:ss}] [%t/%level]: %msg%n"
|
||||
# LOG_FILE_FORMAT: "[%d{yyyy-MM-dd HH:mm:ss}] [%t/%level]: %msg%n"
|
||||
# #
|
||||
# ENABLE_ROLLING_LOGS is now legacy and no longer needed. #
|
||||
####################################################################
|
||||
ENABLE_ROLLING_LOGS: "true"
|
||||
|
||||
####################################################################
|
||||
# Server Timezone #
|
||||
|
||||
@@ -120,9 +120,20 @@ services:
|
||||
####################################################################
|
||||
# Logging Options #
|
||||
# #
|
||||
# Set to "true" to delete old logs #
|
||||
# Rolling logs are now enabled by default with templated #
|
||||
# log4j2 configuration. You can customize: #
|
||||
# #
|
||||
# LOG_LEVEL: Log level (default: info) #
|
||||
# LOG_CONSOLE_FORMAT: Console output format (docker logs) #
|
||||
# LOG_FILE_FORMAT: File log format (logs/latest.log) #
|
||||
# ROLLING_LOG_MAX_FILES: Max archived files (default: 1000) #
|
||||
# #
|
||||
# Example: Add full timestamp to logs #
|
||||
# LOG_CONSOLE_FORMAT: "[%d{yyyy-MM-dd HH:mm:ss}] [%t/%level]: %msg%n"
|
||||
# LOG_FILE_FORMAT: "[%d{yyyy-MM-dd HH:mm:ss}] [%t/%level]: %msg%n"
|
||||
# #
|
||||
# ENABLE_ROLLING_LOGS is now legacy and no longer needed. #
|
||||
####################################################################
|
||||
ENABLE_ROLLING_LOGS: "true"
|
||||
|
||||
####################################################################
|
||||
# Server Timezone #
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="SysOut" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
|
||||
</Console>
|
||||
<Queue name="TerminalConsole">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg%n" />
|
||||
</Queue>
|
||||
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
|
||||
<Policies>
|
||||
<!-- Based on filePattern resolution, so daily -->
|
||||
<TimeBasedTriggeringPolicy />
|
||||
<SizeBasedTriggeringPolicy size="100 MB" />
|
||||
<OnStartupTriggeringPolicy />
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy>
|
||||
<Delete basePath="logs">
|
||||
<IfFileName glob="*.log.gz" />
|
||||
<IfLastModified age="7d" />
|
||||
<IfAccumulatedFileCount exceeds="20"/>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingRandomAccessFile>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="info">
|
||||
<filters>
|
||||
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
|
||||
</filters>
|
||||
<AppenderRef ref="SysOut"/>
|
||||
<AppenderRef ref="File"/>
|
||||
<AppenderRef ref="TerminalConsole"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -28,7 +28,11 @@ shopt -s nullglob
|
||||
|
||||
isDebugging && set -x
|
||||
|
||||
#umask 002
|
||||
if (( $(mc-image-helper java-release) >= 17 )); then
|
||||
MC_IMAGE_HELPER_OPTS+=" --enable-native-access=ALL-UNNAMED"
|
||||
export MC_IMAGE_HELPER_OPTS
|
||||
fi
|
||||
|
||||
export HOME=/data
|
||||
|
||||
log "Running as uid=$(id -u) gid=$(id -g) with /data as '$(ls -lnd /data)'"
|
||||
@@ -91,11 +95,6 @@ fi
|
||||
##########################################
|
||||
# Auto-pause/stop
|
||||
|
||||
if isTrue "${ENABLE_AUTOPAUSE}" && isTrue "${EXEC_DIRECTLY:-false}"; then
|
||||
logError "EXEC_DIRECTLY=true is incompatible with ENABLE_AUTOPAUSE=true"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if isTrue "${ENABLE_AUTOPAUSE}" && isTrue "${ENABLE_AUTOSTOP}"; then
|
||||
logError "ENABLE_AUTOPAUSE=true is incompatible with ENABLE_AUTOSTOP=true"
|
||||
exit 1
|
||||
|
||||
@@ -103,20 +103,76 @@ elif versionLessThan 1.18.1; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if isTrue "${ENABLE_ROLLING_LOGS:-false}"; then
|
||||
if ! ${canUseRollingLogs}; then
|
||||
logError "Using rolling logs is currently not possible in the selected version due to CVE-2021-44228"
|
||||
exit 1
|
||||
# Set up log4j2 configuration with templating support
|
||||
if ${canUseRollingLogs}; then
|
||||
# Set up log configuration defaults
|
||||
: "${LOG_LEVEL:=info}"
|
||||
: "${ROLLING_LOG_MAX_FILES:=1000}"
|
||||
# Note: Can't use ${VAR:=default} syntax for values containing } as it breaks parsing
|
||||
if [ -z "${ROLLING_LOG_FILE_PATTERN}" ]; then
|
||||
ROLLING_LOG_FILE_PATTERN='logs/%d{yyyy-MM-dd}-%i.log.gz'
|
||||
fi
|
||||
# Set up log configuration
|
||||
|
||||
# Pattern format defaults (compatible with vanilla Minecraft)
|
||||
# Note: Can't use ${VAR:=default} syntax because } in the value breaks parsing
|
||||
if [ -z "${LOG_CONSOLE_FORMAT}" ]; then
|
||||
LOG_CONSOLE_FORMAT='[%d{HH:mm:ss}] [%t/%level]: %msg%n'
|
||||
fi
|
||||
if [ -z "${LOG_TERMINAL_FORMAT}" ]; then
|
||||
LOG_TERMINAL_FORMAT='[%d{HH:mm:ss} %level]: %msg%n'
|
||||
fi
|
||||
if [ -z "${LOG_FILE_FORMAT}" ]; then
|
||||
LOG_FILE_FORMAT='[%d{HH:mm:ss}] [%t/%level]: %msg%n'
|
||||
fi
|
||||
|
||||
export LOG_LEVEL ROLLING_LOG_FILE_PATTERN ROLLING_LOG_MAX_FILES
|
||||
export LOG_CONSOLE_FORMAT LOG_TERMINAL_FORMAT LOG_FILE_FORMAT
|
||||
|
||||
LOGFILE="${SERVER_DIR}/log4j2.xml"
|
||||
if [ ! -e "$LOGFILE" ]; then
|
||||
log "Creating log4j2.xml in ${LOGFILE}"
|
||||
cp /image/log4j2.xml "$LOGFILE"
|
||||
|
||||
# Always regenerate if file doesn't exist or REGENERATE_LOG4J2 is set
|
||||
if [ ! -e "$LOGFILE" ] || isTrue "${REGENERATE_LOG4J2:-false}"; then
|
||||
log "Generating log4j2.xml from template in ${LOGFILE}"
|
||||
|
||||
# Generate log4j2.xml using heredoc for reliable variable substitution
|
||||
cat > "$LOGFILE" <<EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="SysOut" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="${LOG_CONSOLE_FORMAT}" />
|
||||
</Console>
|
||||
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="${ROLLING_LOG_FILE_PATTERN}">
|
||||
<PatternLayout pattern="${LOG_FILE_FORMAT}" />
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy />
|
||||
<OnStartupTriggeringPolicy />
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="${ROLLING_LOG_MAX_FILES}"/>
|
||||
</RollingRandomAccessFile>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="${LOG_LEVEL}">
|
||||
<filters>
|
||||
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
|
||||
</filters>
|
||||
<AppenderRef ref="SysOut"/>
|
||||
<AppenderRef ref="File"/>
|
||||
<AppenderRef ref="TerminalConsole"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
EOF
|
||||
else
|
||||
log "log4j2.xml already created, skipping"
|
||||
log "log4j2.xml already exists and is up to date, skipping generation"
|
||||
fi
|
||||
|
||||
# Apply the log4j2 configuration
|
||||
JVM_OPTS="-Dlog4j.configurationFile=log4j2.xml ${JVM_OPTS}"
|
||||
elif isTrue "${ENABLE_ROLLING_LOGS:-false}"; then
|
||||
# Legacy behavior: error if rolling logs explicitly requested but not possible
|
||||
logError "Using rolling logs is currently not possible in the selected version due to CVE-2021-44228"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Optional disable console
|
||||
@@ -485,16 +541,12 @@ fi
|
||||
if isTrue "${DEBUG_EXEC}"; then
|
||||
set -x
|
||||
fi
|
||||
if isTrue "${EXEC_DIRECTLY:-false}"; then
|
||||
"${finalArgs[@]}"
|
||||
else
|
||||
if [ -f "${FTB_DIR}/variables.txt" ]; then
|
||||
JVM_ARGS="${JVM_XX_OPTS} ${JVM_OPTS} $expandedDOpts"
|
||||
JVM_ARGS=${JVM_ARGS//$'\n'/}
|
||||
sed -i "s~JAVA_ARGS=.*~JAVA_ARGS=\"${JVM_ARGS}\"~" "${FTB_DIR}/variables.txt"
|
||||
fi
|
||||
exec mc-server-runner "${mcServerRunnerArgs[@]}" "${finalArgs[@]}"
|
||||
if [ -f "${FTB_DIR}/variables.txt" ]; then
|
||||
JVM_ARGS="${JVM_XX_OPTS} ${JVM_OPTS} $expandedDOpts"
|
||||
JVM_ARGS=${JVM_ARGS//$'\n'/}
|
||||
sed -i "s~JAVA_ARGS=.*~JAVA_ARGS=\"${JVM_ARGS}\"~" "${FTB_DIR}/variables.txt"
|
||||
fi
|
||||
exec mc-server-runner "${mcServerRunnerArgs[@]}" "${finalArgs[@]}"
|
||||
elif [[ $SERVER =~ run.sh ]]; then
|
||||
log "Using Forge supplied run.sh script..."
|
||||
echo $JVM_XX_OPTS $JVM_OPTS $expandedDOpts > user_jvm_args.txt
|
||||
@@ -543,9 +595,5 @@ else
|
||||
set -x
|
||||
fi
|
||||
|
||||
if isTrue "${EXEC_DIRECTLY:-false}"; then
|
||||
exec java "${finalArgs[@]}"
|
||||
else
|
||||
exec mc-server-runner ${bootstrapArgs} "${mcServerRunnerArgs[@]}" java "${finalArgs[@]}"
|
||||
fi
|
||||
exec mc-server-runner ${bootstrapArgs} "${mcServerRunnerArgs[@]}" java "${finalArgs[@]}"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user