Docker image with Heaps, Haxe, Neko and Hashlink.
813
Haxe, Neko, the macOS build of HashLink and the Heaps game engine, for compiling Heaps games into macOS .app bundles and .dmg images.
Docker Hub · Source · All images
| Base image | debian:13.7 |
| Software | Heaps 2.1.0 (installed from haxelib on the first start) |
| Also included | Haxe, Neko, HashLink for macOS (x86_64), bundle and makedmg, xorriso, zip, ShellCheck |
| User | heaps (uid 1000) with passwordless sudo (sudo apt-get install ...) |
| Tags | latest, 2.1.0, 2.1.0-YYYYMMDD |
Run in an empty directory; the commands work on the files of the current directory, mounted as the home directory of the container. CI runs these commands to check that they work.
# the first start installs Heaps and its libraries with haxelib, into ~/haxelib
docker run --rm -v .:/home/heaps -w /home/heaps aljazmc/heaps-buildformac "haxe --version && haxelib list heaps"
# compile the project of the current directory to hello.hl
docker run --rm -v .:/home/heaps -w /home/heaps aljazmc/heaps-buildformac "haxe compile.hxml"
# bundle it into dist/hello.app and make dist/hello.dmg
docker run --rm -v .:/home/heaps -w /home/heaps aljazmc/heaps-buildformac "bundle hello.hl && makedmg dist/hello.app dist/hello.dmg"
## docker-compose.yml example
services:
heaps:
image: aljazmc/heaps-buildformac
working_dir: /home/heaps
user: heaps
volumes:
- .:/home/heaps
## the first start installs Heaps and its libraries with haxelib
docker compose run --rm heaps
## run commands in the container:
docker compose run --rm heaps "haxe compile.hxml"
The commands expect a Heaps project in the current directory with a compile.hxml that compiles it to hello.hl, like this one, and the sources in src:
-cp src
-lib format
-lib heaps
-lib hlsdl
-hl hello.hl
-main Main
The image contains the macOS (x86_64) build of HashLink (hl, libhl.2.dylib, libopenal.1.dylib, *.hdll and headers) in $HASHLINK_MACOS (/usr/local/hashlink-macos). SDL3 is linked into sdl.hdll, so no other libraries are needed. It is the same HashLink version as the Haxe libraries (hlsdl, ...) installed in the container, so a project compiled in the container runs on macOS when all of these files are copied into an .app bundle.
###### the image contains this script as the `bundle` command ([source](https://github.com/aljazmc/dockerfiles/blob/main/heaps/buildformac/bundle)):
#!/bin/bash
set -e
HL_FILE="${1:-hello.hl}"
NAME="$(basename "$HL_FILE" .hl)"
APP="dist/$NAME.app"
HDLLS=(fmt heaps openal sdl ui uv)
DYLIBS=(libhl.2 libopenal.1)
rm -rf "$APP" "dist/$NAME-macos.zip"
mkdir -p "$APP/Contents/MacOS"
cp "$HL_FILE" "$APP/Contents/MacOS/$NAME.hl"
cp "$HASHLINK_MACOS/hl" "$APP/Contents/MacOS"/
for HDLL in "${HDLLS[@]}"; do
cp "$HASHLINK_MACOS/$HDLL.hdll" "$APP/Contents/MacOS"/
done
for DYLIB in "${DYLIBS[@]}"; do
cp -L "$HASHLINK_MACOS/$DYLIB.dylib" "$APP/Contents/MacOS"/
done
if [ -d res ]; then
cp -r res "$APP/Contents/MacOS"/
fi
cat <<EOF > "$APP/Contents/MacOS/launcher"
#!/bin/sh
cd "\$(dirname "\$0")"
exec ./hl $NAME.hl "\$@"
EOF
chmod +x "$APP/Contents/MacOS/launcher" "$APP/Contents/MacOS/hl"
cat <<EOF > "$APP/Contents/Info.plist"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>launcher</string>
<key>CFBundleIdentifier</key>
<string>com.example.$NAME</string>
<key>CFBundleName</key>
<string>$NAME</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
EOF
(cd dist && zip -qry "$NAME-macos.zip" "$NAME.app")
## compile and bundle the project:
docker compose run --rm heaps "haxe compile.hxml && bundle hello.hl"
The result is the dist/hello.app bundle and the dist/hello-macos.zip archive. Extract the archive on a Mac and open hello.app.
HDLLS lists the HashLink libraries that are copied. Add ssl or sqlite if the project uses them. To change the lists, copy the command into the project (cp /usr/local/bin/bundle .), edit it and run ./bundle instead.res directory at runtime (hxd.Res.initLocal()), the directory is copied too. With hxd.Res.initEmbed() the resources are already inside the .hl file.hl reads the .hl file from the current directory, so launcher changes to Contents/MacOS before it starts the game.hello.app and choose "Open", or remove the quarantine flag with xattr -dr com.apple.quarantine hello.app.com.example.$NAME in Info.plist to your own bundle identifier.Applications for macOS are .app bundles and they are usually distributed in a .dmg disk image. Opening the .dmg shows the app next to a link to the Applications folder, and the app is installed by dragging it there. makedmg creates such an image with xorriso (installed in the image).
## the image contains this script as the `makedmg` command ([source](https://github.com/aljazmc/dockerfiles/blob/main/heaps/buildformac/makedmg)):
#!/bin/bash
set -e
APP="${1:?usage: makedmg <app bundle> <output.dmg>}"
OUT="${2:?usage: makedmg <app bundle> <output.dmg>}"
NAME="$(basename "$APP" .app)"
STAGE="$(mktemp -d)"
chmod 755 "$STAGE"
cp -a "$APP" "$STAGE"/
ln -s /Applications "$STAGE/Applications"
rm -f "$OUT"
xorriso -as mkisofs -quiet -V "$NAME" -hfsplus -R -o "$OUT" "$STAGE"
rm -rf "$STAGE"
## create the disk image:
docker compose run --rm heaps "haxe compile.hxml && bundle hello.hl && makedmg dist/hello.app dist/hello.dmg"
The result is dist/hello.dmg. Open it on a Mac and drag hello.app to Applications.
makedmg <app bundle> <output.dmg>..dmg. Compressed .dmg images (UDZO) can only be created with hdiutil on macOS..dmg files with the quarantine flag and macOS passes it on to the app, so the notes about Gatekeeper above apply to the app copied from the .dmg too..dmg runs from a read-only directory, and launcher changes to Contents/MacOS, so write files that should persist, like saved games, to ~/Library/Application Support. hxd.Save writes to the working directory by default.latest: the newest build.2.1.0: the Heaps version in the image, e.g. aljazmc/heaps-buildformac:2.1.0. Use it to stay on a known version.2.1.0-YYYYMMDD: the same version, built on that date (UTC), e.g. 2.1.0-20261122. Every build gets its own tag that never moves, so use it where you need exactly the same image again.~/haxelib), pinned with the HEAPS_VERSION environment variable set in the Dockerfile. An existing ~/haxelib directory is kept as it is.The Dockerfile, the scripts and this README are part of aljazmc/dockerfiles, released under the MIT License.
The software in the image keeps its own license:
| Software | License | In the image |
|---|---|---|
| Heaps | MIT | ~/haxelib/heaps/*/LICENSE after the first start |
Every other package keeps its license too: apk info --license <package> shows it on Alpine, /usr/share/doc/<package>/copyright on Debian.
Content type
Image
Digest
sha256:aaf1b4b2a…
Size
172.7 MB
Last updated
1 day ago
docker pull aljazmc/heaps-buildformac