feat: entrypoint

This commit is contained in:
CyberL1 2024-07-07 12:59:32 +02:00
parent 1a3804e865
commit cbecb21ea3
4 changed files with 18 additions and 15 deletions

View File

@ -10,6 +10,7 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Resources\files\template\Dockerfile" /> <EmbeddedResource Include="Resources\files\template\Dockerfile" />
<EmbeddedResource Include="Resources\files\template\entrypoint" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -661,7 +661,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
var world = _context.Worlds.Find(wId); var world = _context.Worlds.Find(wId);
var server = new DockerHelper(world); var server = new DockerHelper(world);
server.RunCommand("rm -rf world"); server.RunCommand($"rm -rf slot-{world.ActiveSlot}");
server.RebootServer(); server.RebootServer();
return Ok(true); return Ok(true);

View File

@ -3,7 +3,7 @@ FROM eclipse-temurin:21-jre-alpine
COPY . . COPY . .
RUN apk upgrade RUN apk upgrade
RUN apk add openssl at RUN apk add openssl
RUN wget -O rcon-cli.tar.gz https://github.com/itzg/rcon-cli/releases/download/1.6.7/rcon-cli_1.6.7_linux_amd64.tar.gz RUN wget -O rcon-cli.tar.gz https://github.com/itzg/rcon-cli/releases/download/1.6.7/rcon-cli_1.6.7_linux_amd64.tar.gz
RUN tar xzf rcon-cli.tar.gz RUN tar xzf rcon-cli.tar.gz
@ -15,16 +15,4 @@ WORKDIR mc
RUN wget -O server.jar https://piston-data.mojang.com/v1/objects/450698d1863ab5180c25d7c804ef0fe6369dd1ba/server.jar RUN wget -O server.jar https://piston-data.mojang.com/v1/objects/450698d1863ab5180c25d7c804ef0fe6369dd1ba/server.jar
EXPOSE 25565 EXPOSE 25565
ENTRYPOINT ["/entrypoint"]
RUN java -jar server.jar
RUN echo "$(openssl rand -hex 20)" > .rcon-pwd
RUN echo eula=true > eula.txt
RUN echo "enable-rcon=true" >> server.properties
RUN echo "rcon.password=$(cat .rcon-pwd)" >> server.properties
RUN echo "password: $(cat .rcon-pwd)" >> /root/.rcon-cli.yaml
RUN rm .rcon-pwd
CMD ["java", "-jar", "server.jar"]

View File

@ -0,0 +1,14 @@
#!/bin/sh
RCON_PASSWORD="$(openssl rand -hex 20)"
echo "password: $RCON_PASSWORD" >> /root/.rcon-cli.yaml
[ ! -f eula.txt ] && echo "eula=true" > eula.txt
if [ ! -f server.properties ]; then
echo "enable-rcon=true" >> server.properties
echo "rcon.password=$RCON_PASSWORD" >> server.properties
echo "level-name=slot-1" >> server.properties
fi
java -jar server.jar