This repository has been archived by the owner on Feb 15, 2024. It is now read-only.
forked from felixklauke/paper-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
113 lines (95 loc) · 3.35 KB
/
Dockerfile
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Java Version
ARG JAVA_VERSION=17
###########################
### Running environment ###
###########################
FROM openjdk:${JAVA_VERSION}-alpine AS runtime
#####################################
### Maintained by Felix Klauke ###
### Contact: [email protected] ###
#####################################
LABEL maintainer="Felix Klauke <[email protected]>"
#################
### Arguments ###
#################
ARG PAPER_VERSION=1.18.2
ARG PAPER_BUILD=268
ARG PAPER_DOWNLOAD_URL=https://papermc.io/api/v2/projects/paper/versions/${PAPER_VERSION}/builds/${PAPER_BUILD}/downloads/paper-${PAPER_VERSION}-${PAPER_BUILD}.jar
##########################
### Environment & ARGS ###
##########################
ENV MINECRAFT_PATH=/opt/minecraft
ENV SERVER_PATH=${MINECRAFT_PATH}/server
ENV DATA_PATH=${MINECRAFT_PATH}/data
ENV LOGS_PATH=${MINECRAFT_PATH}/logs
ENV CONFIG_PATH=${MINECRAFT_PATH}/config
ENV WORLDS_PATH=${MINECRAFT_PATH}/worlds
ENV PLUGINS_PATH=${MINECRAFT_PATH}/plugins
ENV PROPERTIES_LOCATION=${CONFIG_PATH}/server.properties
ENV JAVA_HEAP_SIZE=4G
ENV JAVA_ARGS="-server -Dcom.mojang.eula.agree=true"
ENV SPIGOT_ARGS="--nojline"
ENV PAPER_ARGS=""
#################
### Libraries ###
#################
RUN apk add py3-pip
RUN pip3 install --ignore-installed six mcstatus
###################
### Healthcheck ###
###################
HEALTHCHECK --interval=10s --timeout=5s --start-period=120s \
CMD mcstatus localhost:$( cat $PROPERTIES_LOCATION | grep "server-port" | cut -d'=' -f2 ) ping
######################
### Obtain scripts ###
######################
ADD scripts/docker-entrypoint.sh docker-entrypoint.sh
RUN chmod +x docker-entrypoint.sh
############
### User ###
############
RUN addgroup minecraft && \
adduser -s /bin/bash minecraft -G minecraft -h ${MINECRAFT_PATH} -D && \
mkdir ${SERVER_PATH} ${LOGS_PATH} ${DATA_PATH} ${WORLDS_PATH} ${PLUGINS_PATH} ${CONFIG_PATH} && \
chown -R minecraft:minecraft ${MINECRAFT_PATH}
USER minecraft
#########################
### Working directory ###
#########################
WORKDIR ${SERVER_PATH}
################################
### Download jar from paper. ###
################################
ADD ${PAPER_DOWNLOAD_URL} paper.jar
#########################
### Setup environment ###
#########################
# Create symlink for plugin volume as hotfix for some plugins who hard code their directories
RUN ln -s $PLUGINS_PATH $SERVER_PATH/plugins && \
# Create symlink for persistent data
ln -s $DATA_PATH/banned-ips.json $SERVER_PATH/banned-ips.json && \
ln -s $DATA_PATH/banned-players.json $SERVER_PATH/banned-players.json && \
ln -s $DATA_PATH/help.yml $SERVER_PATH/help.yml && \
ln -s $DATA_PATH/ops.json $SERVER_PATH/ops.json && \
ln -s $DATA_PATH/permissions.yml $SERVER_PATH/permissions.yml && \
ln -s $DATA_PATH/whitelist.json $SERVER_PATH/whitelist.json && \
# Create symlink for logs
ln -s $LOGS_PATH $SERVER_PATH/logs
###############
### Volumes ###
###############
VOLUME "${CONFIG_PATH}"
VOLUME "${WORLDS_PATH}"
VOLUME "${PLUGINS_PATH}"
VOLUME "${DATA_PATH}"
VOLUME "${LOGS_PATH}"
#############################
### Expose minecraft port ###
#############################
EXPOSE 25565
######################################
### Entrypoint is the start script ###
######################################
ENTRYPOINT [ "./docker-entrypoint.sh" ]
# Run Command
CMD [ "serve" ]