Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add windows container suport. #6

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.3.1] - 2024-01-24

### changed
- Add windows container suport.

## [0.3.0] - 2024-01-12

### Changed
Expand Down
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@ A docker image that provides a LeviLamina server that will automatically downloa

The following starts a LeviLamina server running a default version and exposing the default UDP port:

Linux Container:
```sh
docker run -d -it -e EULA=TRUE -p 19132:19132/udp -v levilamina-server-data:/data ghcr.io/liteldev/levilamina-server
docker run -d -it -e EULA=TRUE -p 19132:19132/udp -v levilamina-server-data:/data ghcr.io/liteldev/levilamina-server-wine
```

Windows Container:
```sh
docker run -d -it -e EULA=TRUE -p 19132:19132/udp -v C:/levilamina-server-data:C:/data ghcr.io/liteldev/levilamina-server-windows
```

If you plan to use the server in production, it is recommended to use Docker Compose to manage the container. You can use the following `compose.yaml` file as a template:

Linux Container:
```yml
services:
mc-server:
image: ghcr.io/liteldev/levilamina-server
image: ghcr.io/liteldev/levilamina-server-wine
environment:
EULA: TRUE
VERSION: 0.4.2
Expand All @@ -32,6 +39,27 @@ volumes:
levilamina-server-data:
```

Linux Container:
```yml
services:
mc-server:
image: ghcr.io/liteldev/levilamina-server-wine
environment:
EULA: TRUE
VERSION: 0.4.2
PACKAGES: |
github.com/LiteLDev/[email protected]
ports:
- 19132:19132/udp
volumes:
- C:levilamina-server-data:C:/data
stdin_open: true
tty: true

volumes:
levilamina-server-data:
```

### Environment variables

- `EULA`(`FALSE`): must be set to `TRUE` to accept the [Minecraft End User License Agreement](https://minecraft.net/terms).
Expand Down
16 changes: 16 additions & 0 deletions windows/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM mcr.microsoft.com/windows/servercore:ltsc2022

USER ContainerAdministrator

RUN md "C:\scripts"
COPY ["scripts/*", "C:/scripts/"]

ENV Path="%Path%;C:/Program Files (x86)/Busybox;C:\Program Files (x86)\Lip"

RUN md "C:\Program Files (x86)\Busybox"
RUN C:\Windows\System32\curl.exe -o "C:\Program Files (x86)\Busybox\busybox.exe" -L "https://frippery.org/files/busybox/busybox.exe"

RUN ["busybox", "bash", "-c", "C:/scripts/build.sh"]

ENTRYPOINT ["busybox", "bash", "-c", "C:/scripts/entrypoint.sh"]
WORKDIR C:/data
34 changes: 34 additions & 0 deletions windows/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Set default values for environment variables
VERSION="${VERSION:-LATEST}"
PACKAGES="${PACKAGES:-}"
EULA="${EULA:-FALSE}"

# Enforce EULA
if [ $(echo "$EULA" | tr '[:lower:]' '[:upper:]') != "TRUE" ]
then
echo "You must accept the Minecraft EULA to run the server."
echo "Set the environment variable EULA to true to accept it."
exit 1
fi

# Install dependencies on first run
# Test if bedrock_server_mod.exe exists
if [ ! -f "bedrock_server_mod.exe" ]; then
# Install LeveLamina
if [ "$VERSION" = "LATEST" ]
then
lip install -y github.com/LiteLDev/LeviLamina
else
lip install -y github.com/LiteLDev/LeviLamina@$VERSION
fi

# Install packages, line by line
for package in $PACKAGES
do
lip install -y $package
done

./PeEditor.exe --pause=false --mod=true
fi

./bedrock_server_mod.exe
12 changes: 12 additions & 0 deletions windows/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cd C:/Users/ContainerAdministrator/Downloads

# Dowload and install vcruntime2022
wget -O "vc_redist.x64.exe" "https://aka.ms/vs/17/release/vc_redist.x64.exe"
./vc_redist.x64.exe /install /quiet /norestart
rm vc_redist.x64.exe

# Download lip
mkdir -p 'C:/Program Files/Lip'
wget "https://github.com/lippkg/lip/releases/latest/download/lip-windows-amd64.zip"
unzip lip-windows-amd64.zip -d "C:/Program Files/Lip/"
rm lip-windows-amd64.zip