primary / Dockerfile
Nodiw52992's picture
Update Dockerfile
efd0b6d verified
# Use the latest Python image as the base
FROM python:latest
# Install required system packages and Oracle JDK 21
USER root
RUN apt-get update && apt-get install -y \
curl \
jq \
wget \
bash \
nano \
git \
imagemagick \
zip \
unzip \
git-lfs \
&& git lfs install \
&& wget https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.deb \
&& dpkg -i jdk-21_linux-x64_bin.deb \
&& rm jdk-21_linux-x64_bin.deb \
&& rm -rf /var/lib/apt/lists/*
# Upgrade pip to the latest version
RUN pip install --no-cache-dir --upgrade pip
# Create a non-root user and switch to it
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# Set working directory for Minecraft
WORKDIR /minecraft
# Copy required files into the container (ensure these exist in your build context)
RUN wget https://raw.githubusercontent.com/KnoxTheDev/main-server/refs/heads/main/eula.txt
RUN wget https://raw.githubusercontent.com/KnoxTheDev/main-server/refs/heads/main/server.py
RUN wget https://raw.githubusercontent.com/KnoxTheDev/main-server/refs/heads/main/server.properties
RUN wget https://raw.githubusercontent.com/KnoxTheDev/main-server/refs/heads/main/start.sh
RUN wget https://raw.githubusercontent.com/KnoxTheDev/main-server/refs/heads/main/plugins.sh
RUN wget https://raw.githubusercontent.com/KnoxTheDev/main-server/refs/heads/main/server-icon.png
RUN wget https://raw.githubusercontent.com/KnoxTheDev/main-server/refs/heads/main/playit.sh
RUN wget https://raw.githubusercontent.com/KnoxTheDev/main-server/refs/heads/main/sshx
RUN wget https://raw.githubusercontent.com/KnoxTheDev/main-server/refs/heads/main/configs.zip
RUN wget https://raw.githubusercontent.com/KnoxTheDev/main-server/refs/heads/main/backup.sh
# Check if worlds.zip exists before downloading
RUN wget --spider https://huggingface.co/datasets/knoxius/primary/resolve/main/worlds.zip && \
wget https://huggingface.co/datasets/knoxius/primary/resolve/main/worlds.zip && unzip worlds.zip && rm worlds.zip || \
echo "worlds.zip not found, skipping download."
RUN convert server-icon.png -resize 64x64 server-icon.png
RUN sed -i 's/\r$//' playit.sh
RUN chmod +x plugins.sh start.sh playit.sh backup.sh sshx
# Install Python dependencies (for your downloader scripts)
RUN pip install --no-cache-dir requests
# Expose the necessary ports: 7860 for the dummy HTTP server
EXPOSE 7860
# Setup plugins' configs
RUN unzip configs.zip && rm configs.zip
# Entrypoint Commands
CMD python -m http.server 7860 > /dev/null 2>&1 & ./sshx