Dockerfile.appimage 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Builds the Sculpt Engine / Project Cold Water native Linux client as an AppImage.
  2. # Ubuntu 22.04 (glibc 2.35) keeps the resulting AppImage runnable on most modern distros.
  3. FROM ubuntu:22.04 AS builder
  4. ENV DEBIAN_FRONTEND=noninteractive
  5. RUN apt-get update && apt-get install -y --no-install-recommends \
  6. build-essential curl ca-certificates pkg-config file patchelf python3 wget \
  7. libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev \
  8. libx11-dev libxcursor-dev libxi-dev libxrandr-dev libxkbcommon-x11-dev \
  9. libvulkan-dev libgl1-mesa-dev \
  10. && rm -rf /var/lib/apt/lists/*
  11. RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable
  12. ENV PATH="/root/.cargo/bin:${PATH}"
  13. WORKDIR /app
  14. COPY Cargo.toml Cargo.lock ./
  15. COPY src ./src
  16. COPY tests ./tests
  17. COPY shaders ./shaders
  18. COPY mods ./mods
  19. COPY scripts/appimage ./scripts/appimage
  20. RUN cargo build --release --bin project_cold_water
  21. # Assemble AppDir
  22. RUN set -eux; \
  23. APPDIR=/app/AppDir; \
  24. mkdir -p $APPDIR/usr/bin $APPDIR/usr/lib $APPDIR/usr/share/sculpt-engine; \
  25. cp target/release/project_cold_water $APPDIR/usr/bin/project_cold_water; \
  26. cp -r mods $APPDIR/usr/share/sculpt-engine/mods; \
  27. cp scripts/appimage/AppRun $APPDIR/AppRun; chmod +x $APPDIR/AppRun; \
  28. cp scripts/appimage/sculpt-engine.desktop $APPDIR/sculpt-engine.desktop; \
  29. python3 scripts/appimage/make_icon.py $APPDIR/sculpt-engine.png; \
  30. ln -s sculpt-engine.png $APPDIR/.DirIcon; \
  31. # Bundle libasound (cpal links it at build time); GPU/Wayland/X11 libs are dlopen'd from the host.
  32. cp -L "$(ldconfig -p | awk '/libasound\.so\.2 /{print $NF; exit}')" $APPDIR/usr/lib/; \
  33. patchelf --set-rpath '$ORIGIN/../lib' $APPDIR/usr/bin/project_cold_water; \
  34. ldd $APPDIR/usr/bin/project_cold_water
  35. # Package with appimagetool (extract-and-run: no FUSE inside containers)
  36. RUN set -eux; \
  37. wget -q https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage -O /tmp/appimagetool; \
  38. chmod +x /tmp/appimagetool; \
  39. mkdir -p /out; \
  40. ARCH=x86_64 /tmp/appimagetool --appimage-extract-and-run /app/AppDir /out/SculptEngine-x86_64.AppImage; \
  41. ls -la /out
  42. FROM scratch AS export
  43. COPY --from=builder /out/SculptEngine-x86_64.AppImage /SculptEngine-x86_64.AppImage