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

feat: Add arm64 container support #6

Merged
merged 7 commits into from
Jan 27, 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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rootfs/Ubuntu_22_04.tar.gz filter=lfs diff=lfs merge=lfs -text
38 changes: 38 additions & 0 deletions .github/workflows/docker-hub-publish-arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release
on:
release:
types: [published]

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
# list of Docker images to use as base name for tags
images: |
${{ github.repository }}
# generate Docker tags based on the following events/attributes
tags: |
type=semver,pattern={{version}}
# always generate latest tag on push
flavor: |
latest=true
- name: Build and push to DockerHub & GitHub Packages
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
file: ./Dockerfile_arm64
platforms: linux/arm64
104 changes: 104 additions & 0 deletions Dockerfile_arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# linux/arm64

FROM ubuntu:22.04 as fex_build


RUN dpkg --add-architecture arm64 && \
apt-get update && \
apt-get install -y \
cmake \
ninja-build \
clang \
libglfw3-dev:arm64 \
libsdl2-dev:arm64 \
libepoxy-dev:arm64 \
g++-x86-64-linux-gnu \
nasm \
git && \
apt-get clean && rm -rf /var/lib/apt/lists/*


WORKDIR /tmp

RUN git clone https://github.com/FEX-Emu/FEX.git && \
cd FEX && \
git submodule update --init && \
mkdir Build && \
cd Build && \
CC=clang CXX=clang++ cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DENABLE_LTO=True -DBUILD_TESTS=False -G Ninja .. && \
ninja

RUN cd FEX/Build && \
ninja install && \
ninja binfmt_misc_32 && \
ninja binfmt_misc_64

RUN rm -rf FEX


############################################################

FROM ubuntu:22.04 as steam_build

COPY --from=fex_build /usr/ /usr/


RUN apt-get update -y && \
apt-get install -y sudo curl && \
apt-get clean && rm -rf /var/lib/apt/lists/*

RUN useradd -m -s /bin/bash steam


USER steam

WORKDIR /home/steam/.fex-emu/RootFS

# This rootfs is based on https://github.com/TeriyakiGod/steamcmd-docker-arm64

# COPY Ubuntu_22_04.tar.gz .
RUN curl -sqL "https://github.com/hmes98318/palworld-docker/raw/055f6759d6ced37ee23d4bdffdc30583d8eae751/RootFS/Ubuntu_22_04.tar.gz" | tar zxvf - && \
echo '{"Config":{"RootFS":"Ubuntu_22_04"}}' > ../Config.js


WORKDIR /home/steam/steamcmd

RUN curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf - && \
echo './steamcmd.sh +quit' > init_steam.sh && \
chmod +x init_steam.sh && \
FEXBash ./init_steam.sh && \
mkdir -p ~/.steam/sdk64/ && \
ln -s ~/steamcmd/linux64/steamclient.so ~/.steam/sdk64/steamclient.so && \
rm init_steam.sh


############################################################

FROM steam_build


USER steam

WORKDIR /home/steam/steamcmd

RUN echo "$(uname -m)" > platform
RUN mkdir -p /home/steam/palworld/Pal/Saved

COPY DefaultPalWorldSettings.ini /home/steam/palworld/DefaultPalWorldSettings.ini
COPY entrypoint.sh /home/steam/palworld/entrypoint.sh


USER root

RUN chown steam:steam /home/steam/palworld/DefaultPalWorldSettings.ini && \
chown steam:steam /home/steam/palworld/entrypoint.sh && \
chmod +x /home/steam/palworld/entrypoint.sh


USER steam

EXPOSE 8211/udp

VOLUME ["/home/steam/palworld/Pal/Saved"]

ENTRYPOINT ["FEXBash", "/home/steam/palworld/entrypoint.sh"]
6 changes: 4 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

VERSION="v0.2.0"
STEAMCMD="/home/steam/steamcmd/steamcmd.sh"
PLATFORM="$(cat /home/steam/steamcmd/platform)"
PALWORLD_DIR="/home/steam/palworld"
PALWORLD_SETTINGS="$PALWORLD_DIR/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini"

Expand Down Expand Up @@ -34,6 +35,7 @@ print_system_info() {
echo "Author: hmes98318"
echo "GitHub: https://github.com/hmes98318/palworld-docker"
echo "----------------------------------------"
echo "Platform: $PLATFORM"
echo "OS: $(cat /etc/os-release | grep "^PRETTY_NAME" | cut -d'=' -f2)"
echo "CPU: $(grep 'model name' /proc/cpuinfo | uniq | cut -d':' -f2)"
echo "RAM: $(awk '/MemTotal/ {total=$2} /MemFree/ {free=$2} END {printf("%.2fGB/%.2fGB", (total-free)/1024000, total/1024000)}' /proc/meminfo)"
Expand Down Expand Up @@ -149,12 +151,12 @@ main(){

if [ ! -f "$PALWORLD_SETTINGS" ]; then
echo "-> Initializing PalServer to generate settings file..."
timeout -s SIGTERM 20s "$PALWORLD_DIR/PalServer.sh"
timeout -s SIGTERM 30s "$PALWORLD_DIR/PalServer.sh"
cp "$PALWORLD_DIR/DefaultPalWorldSettings.ini" "$PALWORLD_SETTINGS"

# Check if initialization is successful
if [ ! -f "$PALWORLD_SETTINGS" ]; then
echo "Initialization failed: Unable to generate settings file." >&2
echo "Initialization failed: Unable to generate settings file. Please make sure the mounted archive directory has proper read and write permissions." >&2
exit 1
fi

Expand Down