mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-05-13 23:45:25 +00:00
feat: load env vars from file or archive at startup (#4053)
This commit is contained in:
@@ -156,6 +156,54 @@ Disabling mods within docker compose files:
|
||||
mod2.jar
|
||||
```
|
||||
|
||||
### Loading container configuration from a pack
|
||||
|
||||
A pack can ship its own container configuration so that the server type, version,
|
||||
and other variables travel with the pack rather than being declared by the user.
|
||||
At startup, before `TYPE` is dispatched, the container can load environment
|
||||
variables from a file on disk, a URL, an entry inside an archive, or from the
|
||||
`.env` of each `GENERIC_PACK(S)` entry.
|
||||
|
||||
- `LOAD_ENV_FROM_GENERIC_PACK`: when `true`, each entry in `GENERIC_PACKS` (after
|
||||
`GENERIC_PACKS_PREFIX`/`SUFFIX` expansion) is probed for a top-level `.env`
|
||||
and each one found is sourced in the same order the packs are applied (later
|
||||
packs override earlier ones, matching the layering of the unpack itself). Packs
|
||||
without a `.env` are skipped without error. URLs are downloaded into
|
||||
`/data/packs/` and reused by the regular generic-pack unpack step, so they are
|
||||
not fetched twice.
|
||||
- `LOAD_ENV_FROM_FILE`: container path or URL of a shell-style env file (one
|
||||
`KEY=VALUE` per line). Comments and blank lines are allowed.
|
||||
- `LOAD_ENV_FROM_ARCHIVE`: container path or URL of a zip/tar archive containing
|
||||
an env file. The entry is sourced into the environment.
|
||||
- `LOAD_ENV_FROM_ARCHIVE_ENTRY`: relative path of the env file inside the archive.
|
||||
Defaults to `.env`.
|
||||
|
||||
These can be combined. Load order is: generic packs first, then
|
||||
`LOAD_ENV_FROM_FILE`, then `LOAD_ENV_FROM_ARCHIVE` — later loads override
|
||||
earlier ones, and all of them **override** values passed via `docker run -e` (or
|
||||
compose `environment:`), so the pack's declared values win.
|
||||
|
||||
```shell
|
||||
docker run -d \
|
||||
-e EULA=TRUE \
|
||||
-e GENERIC_PACK=https://cdn.example.org/my-pack.zip \
|
||||
-e LOAD_ENV_FROM_GENERIC_PACK=true \
|
||||
itzg/minecraft-server
|
||||
```
|
||||
|
||||
Where `my-pack.zip` contains a `.env` at its root such as:
|
||||
|
||||
```env
|
||||
TYPE=FABRIC
|
||||
VERSION=1.21.1
|
||||
FABRIC_LOADER_VERSION=0.16.0
|
||||
```
|
||||
|
||||
!!! warning
|
||||
The env file is sourced by `bash`, so any shell syntax it contains will be
|
||||
evaluated. Only point these variables at sources you trust. `EULA` cannot be
|
||||
set this way — it is checked before the env file is loaded.
|
||||
|
||||
## Mods/plugins list
|
||||
|
||||
You may also download or copy over individual mods/plugins using the `MODS` or `PLUGINS` environment variables. Both are a comma or newline delimited list of
|
||||
|
||||
Reference in New Issue
Block a user