-
I am writing a Dockerfile for martinohanlon/mcpi: Minecraft: Pi Edition API Python Library to teach children Python through manipulating Minecraft. Here's my custom Dockerfile:
# Dockerfile
FROM busybox:latest AS mods_installer
WORKDIR /mods
ARG MODS_URL=https://github.com/arpruss/raspberryjammod/releases/download/0.94/mods.zip
RUN <<EOF
wget ${MODS_URL} --output-document ./mods.zip
unzip -p ./mods.zip 1.12.2/RaspberryJamMod.jar > ./RaspberryJamMod.jar
rm ./mods.zip
EOF
FROM itzg/minecraft-server:java8-multiarch
WORKDIR /data
COPY --link --from=mods_installer /mods ./mods/
EXPOSE 25565/tcp 4711/tcp compose.yaml:
# compose.yaml
services:
minecraft-server:
build:
context: .
dockerfile: Dockerfile
container_name: "mcpi-server"
ports:
- "${MCPI_PORT:-25565}:25565"
- "${RCON_PORT:-4711}:4711"
volumes:
- type: volume
source: mcpi-world
target: /data
environment:
EULA: "TRUE"
TYPE: "FORGE"
VERSION: "1.12.2"
FORGEVERSION: "14.23.5.2859"
MODE: "creative"
SEED: "${SEED:-}"
RCON_CMDS_STARTUP: |-
time set day
weather clear
gamerule doDaylightCycle false
gamerule doWeatherCycle false
tty: true
stdin_open: true
restart: unless-stopped
volumes:
mcpi-world: When I build the image, Docker caches work well and ends instantly (<2s).
However, after building the image,
Is it possible to cache the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I generally don't recommend building a Dockerfile upon something other than an OS/language base image; however, given how incredibly slow RaspberryPi's are to run, the caching strategy is very useful. Since Let me know if you have any questions about why/what I did in the following example:
|
Beta Was this translation helpful? Give feedback.
I generally don't recommend building a Dockerfile upon something other than an OS/language base image; however, given how incredibly slow RaspberryPi's are to run, the caching strategy is very useful.
Since
/data
is a volume and volumes are not persisted in build images, you have to get creative with preparing, persisting, and using the content. Also, no need to re-invent the wheel -- useMODPACK
to grab the mods zip.Let me know if you have any questions about why/what I did in the following example: