File size: 1,009 Bytes
2069803
 
a34fd92
127b7c6
2069803
3d67717
127b7c6
 
2069803
127b7c6
 
 
 
2069803
 
127b7c6
 
 
 
09f048b
 
127b7c6
2069803
127b7c6
2069803
127b7c6
 
 
 
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
# Step 1: Start from a clean Java 21 environment
FROM eclipse-temurin:21-jre-jammy

# Step 2: Set the working directory
WORKDIR /server

# Step 3: Install dependencies (wget for server, flask for web app) and clean up
RUN apt-get update && apt-get install -y wget python3-flask && rm -rf /var/lib/apt/lists/*

# Step 4: Download the Minecraft server
RUN wget https://piston-data.mojang.com/v1/objects/450698d1863ab5180c25d7c804ef0fe6369dd1ba/server.jar

# Step 5: Accept the Minecraft EULA
RUN echo "eula=true" > eula.txt

# Step 6: Copy the Flask app code into the container
COPY app.py .

# Step 7: Change ownership of the directory to the correct user
RUN chown -R 1000:1000 /server

# Step 8: Expose ports for Minecraft (25565) and the Flask web app (7860)
EXPOSE 25565
EXPOSE 7860

# Step 9: Start both servers.
# The Minecraft server runs in the background (&)
# The Flask app runs in the foreground, keeping the container alive.
CMD bash -c "java -Xms512M -Xmx1G -jar server.jar nogui & python3 app.py"