-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
45 lines (33 loc) · 1.19 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
FROM alpine:3.21.2
LABEL maintainer='Chris Kankiewicz <Chris@ChrisKankiewicz.com>'
# Minecraft version
ARG MC_VERSION=1.21.4
ARG MC_JAR_SHA1=4707d00eb834b446575d89a61a11b5d548d8c001
# Set default JVM options
ENV _JAVA_OPTIONS '-Xms256M -Xmx1024M'
# Create Minecraft directories
RUN mkdir -pv /opt/minecraft /etc/minecraft
# Create non-root user
RUN adduser -DHs /sbin/nologin minecraft
# Add the EULA file
COPY files/eula.txt /etc/minecraft/eula.txt
# Add the ops script
COPY files/ops /usr/local/bin/ops
RUN chmod +x /usr/local/bin/ops
# Install dependencies, fetch Minecraft server jar file and chown files
ARG JAR_URL=https://launcher.mojang.com/v1/objects/${MC_JAR_SHA1}/server.jar
RUN apk add --update ca-certificates nss tzdata wget \
&& apk add openjdk21-jre-headless \
&& wget -O /opt/minecraft/minecraft_server.jar ${JAR_URL} \
&& apk del --purge wget && rm -rf /var/cache/apk/* \
&& chown -R minecraft:minecraft /etc/minecraft /opt/minecraft
# Define volumes
VOLUME /etc/minecraft
# Expose port
EXPOSE 25565
# Set running user
USER minecraft
# Set the working dir
WORKDIR /etc/minecraft
# Default run command
CMD ["java", "-jar", "/opt/minecraft/minecraft_server.jar", "nogui"]