| # 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" |