riddhiman commited on
Commit
745e985
·
verified ·
1 Parent(s): 9a69f0c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +9 -11
Dockerfile CHANGED
@@ -1,22 +1,20 @@
1
- # Use an official OpenJDK image for Java 21 as a parent image
2
  FROM openjdk:21
3
 
4
- # Optional: Set the environment variable for Java's memory usage
5
- # Adjust Xmx and Xms values according to your server's specifications
6
- ENV JAVA_OPTS="-Xmx1024M -Xms1024M"
7
-
8
- # Create a directory for the Minecraft server
9
  WORKDIR /minecraft
10
 
11
- # Copy the Minecraft server's JAR file into the container's working directory
12
  COPY server.jar /minecraft
13
 
14
- # Expose the Minecraft server port
15
  EXPOSE 7860
16
 
17
- # Agree to Minecraft's EULA. Change this only if you have.
18
- # It is important to understand and agree to EULA before changing it to TRUE.
19
  ENV EULA=true
20
 
21
- # Run the Minecraft server command. Replace 'server.jar' with the name of your server jar file, if different.
 
 
 
 
 
 
 
22
  CMD if [ "${EULA}" != "true" ]; then echo "You must accept the Minecraft EULA by setting the EULA env variable to TRUE."; exit 1; fi && java ${JAVA_OPTS} -jar server.jar --nogui --port 7860
 
 
1
  FROM openjdk:21
2
 
 
 
 
 
 
3
  WORKDIR /minecraft
4
 
 
5
  COPY server.jar /minecraft
6
 
 
7
  EXPOSE 7860
8
 
9
+ ENV JAVA_OPTS="-Xmx1024M -Xms1024M"
 
10
  ENV EULA=true
11
 
12
+ # Create a cache directory and adjust permissions
13
+ RUN mkdir -p /minecraft/cache && chown -R 1000:1000 /minecraft
14
+
15
+ # Add a non-root user and switch to it
16
+ RUN adduser --disabled-password --home /minecraft --gecos "" minecraft
17
+ RUN chown -R minecraft:minecraft /minecraft
18
+ USER minecraft
19
+
20
  CMD if [ "${EULA}" != "true" ]; then echo "You must accept the Minecraft EULA by setting the EULA env variable to TRUE."; exit 1; fi && java ${JAVA_OPTS} -jar server.jar --nogui --port 7860