-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
79 lines (69 loc) · 2.56 KB
/
Dockerfile
File metadata and controls
79 lines (69 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
ARG VERSION=1.21.11
FROM docker.io/openjdk:21-bullseye AS builder
RUN apt-get update && apt-get -y install git maven gradle jq && rm -rf /var/lib/apt/lists/*
# Build source plugins
WORKDIR /build
COPY source-plugins.json .
COPY build-scripts .
RUN jq -c '.[]' source-plugins.json | while read json ; do \
./build-plugin.sh "$json" ; \
done ; \
rm *.sh
# Set up run-time image
FROM docker.io/openjdk:21-slim-bullseye
RUN apt-get update && apt-get -y install curl jq unzip gettext-base && rm -rf /var/lib/apt/lists/*
ARG VERSION
# Runtime config
ENV HEAP=2G
ENV OPS=
ENV ALLOW=
EXPOSE 25565 8123
VOLUME [ "/data" ]
# Copy build scripts
WORKDIR /build
COPY build-scripts .
# Download latest Paper release
WORKDIR /minecraft
RUN PAPER_API=https://api.papermc.io/v2/projects/paper && \
BUILD=$(curl -s ${PAPER_API}/versions/${VERSION}/builds | jq -r '.builds | map(select(.channel == "default") | .build) | .[-1]') && \
JAR_NAME=paper-${VERSION}-${BUILD}.jar && \
PAPERMC_URL="${PAPER_API}/versions/${VERSION}/builds/${BUILD}/downloads/${JAR_NAME}" && \
curl -o paper.jar "${PAPERMC_URL}"
# Install plugins
WORKDIR /plugins
COPY --from=builder /build .
COPY plugins.json .
COPY source-plugins.json .
COPY plugin-jars .
RUN jq -c '.[]' plugins.json | while read json ; do \
export name="$(echo $json | jq -j '.name')" ; \
export url="$(echo $json | jq -j '.url')" ; \
export jar="$(echo $json | jq -j '.jar')" ; \
[ -f "$name.jar" ] || mv "$jar" "$name.jar" || true ; \
[ -f "$name.jar" ] || curl -fLo "$name.jar" "$url" || exit 1 ; \
export realname=$(/build/plugin-name.sh "${name}.jar") ; \
mv "$name.jar" "$realname.jar" || true ; \
done && \
# Disable automatic updates for plugins that support it
mkdir Updater && \
echo "disable: true" > Updater/config.yml
# Install datapacks, scripts and plugin configs
WORKDIR /
COPY datapacks datapacks
COPY plugin-conf plugin-conf
COPY scripts scripts
# Set up Minecraft working directory
WORKDIR /minecraft
COPY conf .
RUN export PERMISSION_FILES="permissions.yml ops.json whitelist.json banned-ips.json banned-players.json" && \
useradd -rd `realpath .` minecraft && \
chown -R minecraft:minecraft . && \
chown minecraft:minecraft /datapacks && \
chown minecraft:minecraft /plugins && \
echo "eula=true" > eula.txt && \
ln -s /data/logs && \
for f in ${PERMISSION_FILES} ; do ln -s /data/permissions/${f} ; done ; \
rm -rf /build
RUN bash -c '/scripts/startup.sh & sleep 30 ; kill %1' && \
rm -rf /data/*
CMD /scripts/startup.sh