mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-11-26 07:27:37 +00:00
Document extracting archives with APPLY_EXTRA_FILES (#4404)
This commit is contained in:
1 parent
219b721d7a
commit
89c6db53fb
9 files changed
+73
No files matched your search
@@ -124,6 +124,32 @@ A source path can refer to a directory, in which case the files within that dire
|
||||
|
||||
The `APPLY_EXTRA_FILES` feature is processed prior to [patch processing](../configuration/interpolating.md#patching-existing-files), so this can be used as for baseline files to be patched further at runtime.
|
||||
|
||||
### Extracting archives
|
||||
|
||||
A source can also be a ZIP or TAR archive (including `.tar.gz`, `.tar.bz2` and `.tar.zst`) that gets extracted into the destination directory, keeping the paths within the archive. Use a `<<` separator instead of `<` for those entries. Without a destination, such as `<<source_url`, the archive is extracted into `/data`.
|
||||
|
||||
To extract only a directory within the archive, append that path in braces to the source, such as `worlds.zip{world1}`. The prefix is removed, so its contents end up directly in the destination. Several directories are separated by `;`, such as `worlds.zip{world1;world2}`, and are all extracted into the same destination. The paths must be directories within the archive; a single file can't be selected.
|
||||
|
||||
Files extracted from an archive don't replace files that already exist in the destination, since `APPLY_EXTRA_FILES` is processed with `--skip-existing`. That way, changes made by the server, such as to a world, are kept across restarts.
|
||||
|
||||
An archive given by URL is kept in `/data/.tmp/mcopy-archives` and requested with `If-Modified-Since` on later startups, so it is only downloaded again when the server reports it as modified.
|
||||
|
||||
!!! example
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
APPLY_EXTRA_FILES: |
|
||||
world1<</worlds/world1.zip
|
||||
world2<<https://example.com/worlds.zip{world2}
|
||||
config<source_url
|
||||
```
|
||||
|
||||
With that, the contents of `world1.zip` are extracted into `/data/world1` and the `world2` directory within the downloaded `worlds.zip` is extracted into `/data/world2`.
|
||||
|
||||
!!! note
|
||||
|
||||
Extracting archives is not supported by the `java8` image tags and the other pre-Java 17 tags (`java11`, `java16`), since those include an older version of mc-image-helper.
|
||||
|
||||
## Zip file modpack
|
||||
|
||||
Like the `WORLD` option above, you can specify the URL or container path of a "mod pack" to download and install into `mods` for Forge/Fabric or `plugins` for Bukkit/Spigot. To use this option pass the environment variable `MODPACK`, such as
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
plain
|
||||
Binary file not shown.
@@ -0,0 +1,35 @@
|
||||
services:
|
||||
# places an existing world file into /data before mc starts, so the extraction must keep it
|
||||
seed:
|
||||
restart: "no"
|
||||
image: ${IMAGE_TO_TEST:-itzg/minecraft-server}
|
||||
entrypoint: ["bash", "-c", "mkdir -p /data/world1 && cp /seed/world1/level.dat /data/world1/ && chown -R 1000:1000 /data"]
|
||||
volumes:
|
||||
- ./seed:/seed
|
||||
- ./data:/data
|
||||
|
||||
mc:
|
||||
restart: "no"
|
||||
image: ${IMAGE_TO_TEST:-itzg/minecraft-server}
|
||||
depends_on:
|
||||
seed:
|
||||
condition: service_completed_successfully
|
||||
environment:
|
||||
EULA: "true"
|
||||
SETUP_ONLY: "true"
|
||||
APPLY_EXTRA_FILES: |
|
||||
# extracts only the world1 directory of the archive
|
||||
world1<</archives/worlds.zip{world1}
|
||||
# merges the world1 and other directories of the archive
|
||||
merged<</archives/worlds.zip{world1;other}
|
||||
extracted<</archives/configs.tar.gz, plain</archives/plain.txt
|
||||
LOG_TIMESTAMP: "true"
|
||||
# the following are only used to speed up test execution
|
||||
TYPE: CUSTOM
|
||||
CUSTOM_SERVER: /servers/fake.jar
|
||||
VERSION: 1.18.1
|
||||
DEBUG: "true"
|
||||
volumes:
|
||||
- ./data:/data
|
||||
- ./archives:/archives:ro
|
||||
- ./fake.jar:/servers/fake.jar
|
||||
Whitespace-only changes.
@@ -0,0 +1,2 @@
|
||||
# pre-Java 17 variants pin an mc-image-helper that can't extract archives
|
||||
[[ $VARIANT != java8* && $VARIANT != java11* && $VARIANT != java16* ]]
|
||||
@@ -0,0 +1 @@
|
||||
existing
|
||||
@@ -0,0 +1,8 @@
|
||||
# world1 directory of the zip was extracted, without overwriting the existing level.dat
|
||||
mc-image-helper assert fileExists world1/region/r.0.0.mca
|
||||
mc-image-helper assert fileNotExists world1/world1 world1/other world1/readme.txt
|
||||
grep -qx existing world1/level.dat
|
||||
# both selected directories were extracted into the same destination
|
||||
mc-image-helper assert fileExists merged/level.dat merged/region/r.0.0.mca merged/readme.txt
|
||||
# whole tar.gz was extracted and the plain entry was still copied
|
||||
mc-image-helper assert fileExists extracted/config/a.toml plain/plain.txt
|
||||
Reference in new issue
Block a user