2020-06-05 18:41:37 +00:00
#!/usr/bin/docker
2020-06-04 18:31:47 +00:00
# ____ __ ____ ______ __
# / __ \____ _____/ /_____ _____/ __ \/ ___/ |/ /
2021-01-02 11:55:00 +00:00
# / / / / __ \/ ___/ //_/ _ \/ ___/ / / /\__ \| /
# / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / |
# /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_|
#
2021-03-04 13:22:13 +00:00
# Title: Docker-OSX (Mac on Docker)
# Author: Sick.Codes https://twitter.com/sickcodes
2021-08-25 23:05:17 +00:00
# Version: 6.0
2020-06-15 04:33:29 +00:00
# License: GPLv3+
2021-03-04 13:22:13 +00:00
# Repository: https://github.com/sickcodes/Docker-OSX
# Website: https://sick.codes
2021-01-02 11:55:00 +00:00
#
2020-06-15 04:33:29 +00:00
# All credits for OSX-KVM and the rest at @Kholia's repo: https://github.com/kholia/osx-kvm
2021-01-02 11:55:00 +00:00
# OpenCore support go to https://github.com/Leoyzen/KVM-Opencore
2020-06-04 20:25:29 +00:00
# and https://github.com/thenickdude/KVM-Opencore/
2021-01-02 11:55:00 +00:00
#
2020-06-04 18:31:47 +00:00
# This Dockerfile automates the installation of Docker-OSX
2020-06-15 04:33:29 +00:00
# It will build a 200GB container. You can change the size using build arguments.
# This Dockerfile builds on top of the work done by Dhiru Kholia, and many others.
2021-01-02 11:55:00 +00:00
#
2020-06-04 18:31:47 +00:00
# Build:
#
# docker build -t docker-osx .
2020-06-15 04:33:29 +00:00
# docker build -t docker-osx --build-arg VERSION=10.15.5 --build-arg SIZE=200G .
2024-04-08 10:37:47 +00:00
# docker build -t docker-osx-sonoma --build-arg BRANCH=sonoma --build-arg SHORTNAME=sonoma .
2021-01-02 11:55:00 +00:00
#
2020-06-15 04:33:29 +00:00
# Basic Run:
#
2021-01-02 11:55:00 +00:00
# docker run --device /dev/kvm --device /dev/snd -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" sickcodes/docker-osx:latest
2020-06-15 04:33:29 +00:00
#
# Run with SSH:
2021-01-02 11:55:00 +00:00
#
2020-11-13 08:34:40 +00:00
# docker run --device /dev/kvm --device /dev/snd -e RAM=6 -p 50922:10022 -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" sickcodes/docker-osx:latest
2020-06-15 04:33:29 +00:00
# # ssh fullname@localhost -p 50922
2021-01-02 11:55:00 +00:00
#
2020-06-15 04:33:29 +00:00
# Optargs:
2021-01-02 11:55:00 +00:00
#
2021-01-24 12:47:19 +00:00
# -v $PWD/disk.img:/image
# -e SIZE=200G
# -e VERSION=10.15.6
# -e RAM=5
# -e SMP=4
# -e CORES=4
# -e EXTRA=
# -e INTERNAL_SSH_PORT=10022
2021-02-07 17:27:02 +00:00
# -e MAC_ADDRESS=
2020-06-15 04:33:29 +00:00
#
# Extra QEMU args:
#
# docker run ... -e EXTRA="-usb -device usb-host,hostbus=1,hostaddr=8" ...
# # you will also need to pass the device to the container
2020-06-04 18:31:47 +00:00
2021-02-21 06:38:27 +00:00
FROM archlinux:base-devel
2021-10-02 16:12:41 +00:00
LABEL maintainer = 'https://twitter.com/sickcodes <https://sick.codes>'
2020-06-04 18:31:47 +00:00
2020-12-31 10:30:53 +00:00
SHELL [ "/bin/bash" , "-c" ]
2020-06-15 04:33:29 +00:00
# change disk size here or add during build, e.g. --build-arg VERSION=10.14.5 --build-arg SIZE=50G
2021-01-24 13:06:37 +00:00
ARG SIZE = 200G
2024-04-08 10:37:47 +00:00
ARG PARALLEL_DOWNLOADS = 30
2020-06-04 18:31:47 +00:00
2021-01-24 12:47:19 +00:00
# OPTIONAL: Arch Linux server mirrors for super fast builds
# set RANKMIRRORS to any value other that nothing, e.g. -e RANKMIRRORS=true
2024-04-08 10:37:47 +00:00
RUN perl -i -p -e s/^\# Color/Color$'\n' ParallelDownloads\ = \ ${ PARALLEL_DOWNLOADS : =30 } /g /etc/pacman.conf
2021-01-24 12:47:19 +00:00
ARG RANKMIRRORS
2021-01-05 10:03:25 +00:00
ARG MIRROR_COUNTRY = US
ARG MIRROR_COUNT = 10
2021-02-12 18:11:48 +00:00
2022-11-16 14:44:37 +00:00
RUN tee /etc/pacman.d/mirrorlist <<< 'Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch' \
&& tee -a /etc/pacman.d/mirrorlist <<< 'Server = http://mirror.rackspace.com/archlinux/$repo/os/$arch' \
2022-11-16 14:46:51 +00:00
&& tee -a /etc/pacman.d/mirrorlist <<< 'Server = https://mirror.rackspace.com/archlinux/$repo/os/$arch'
2022-11-16 14:44:37 +00:00
2022-11-16 14:25:24 +00:00
# Fixes issue with invalid GPG keys: update the archlinux-keyring package to get the latest keys, then remove and regenerate gnupg keys
2022-11-16 14:41:37 +00:00
RUN pacman -Sy archlinux-keyring --noconfirm \
&& rm -rf /etc/pacman.d/gnupg \
2022-11-16 14:25:24 +00:00
&& pacman-key --init \
&& pacman-key --populate archlinux
2021-02-07 17:59:24 +00:00
RUN if [ [ " ${ RANKMIRRORS } " ] ] ; then \
{ pacman -Sy wget --noconfirm || pacman -Syu wget --noconfirm ; } \
2022-11-16 14:25:24 +00:00
; wget -O ./rankmirrors " https://raw.githubusercontent.com/sickcodes/Docker-OSX/ ${ BRANCH : =master } /rankmirrors " \
2021-02-07 17:59:24 +00:00
; wget -O- " https://www.archlinux.org/mirrorlist/?country= ${ MIRROR_COUNTRY :- US } &protocol=https&use_mirror_status=on " \
| sed -e 's/^#Server/Server/' -e '/^#/d' \
| head -n " $(( ${ MIRROR_COUNT :- 10 } + 1 )) " \
| bash ./rankmirrors --verbose --max-time 5 - > /etc/pacman.d/mirrorlist \
&& cat /etc/pacman.d/mirrorlist \
; fi
2021-01-05 10:03:25 +00:00
2022-07-04 12:53:22 +00:00
RUN tee -a /etc/pacman.d/gnupg/gpg.conf <<< 'keyserver hkp://keyserver.ubuntu.com' \
&& tee -a /etc/pacman.d/gnupg/gpg.conf <<< 'keyserver hkps://hkps.pool.sks-keyservers.net:443' \
2022-11-10 00:11:18 +00:00
&& tee -a /etc/pacman.d/gnupg/gpg.conf <<< 'keyserver hkp://pgp.mit.edu:11371' \
&& tee -a /etc/pacman.d/gnupg/gpg.conf <<< 'keyserver hkps://keys.openpgp.org' \
&& tee -a /etc/pacman.d/gnupg/gpg.conf <<< 'keyserver hkps://keys.mailvelope.com'
2022-07-04 12:53:22 +00:00
2020-06-15 04:33:29 +00:00
# This fails on hub.docker.com, useful for debugging in cloud
2020-06-04 22:17:01 +00:00
# RUN [[ $(egrep -c '(svm|vmx)' /proc/cpuinfo) -gt 0 ]] || { echo KVM not possible on this host && exit 1; }
2020-06-04 18:31:47 +00:00
2021-02-21 06:38:27 +00:00
# RUN tee -a /etc/pacman.conf <<< '[community-testing]' \
# && tee -a /etc/pacman.conf <<< 'Include = /etc/pacman.d/mirrorlist'
2020-06-04 18:31:47 +00:00
2021-02-24 05:29:17 +00:00
RUN pacman -Syu git zip vim nano alsa-utils openssh --noconfirm \
2020-10-05 08:01:45 +00:00
&& ln -s /bin/vim /bin/vi \
2020-06-18 13:30:02 +00:00
&& useradd arch -p arch \
&& tee -a /etc/sudoers <<< 'arch ALL=(ALL) NOPASSWD: ALL' \
2022-11-15 19:17:58 +00:00
&& mkdir -p /home/arch \
2020-06-18 13:30:02 +00:00
&& chown arch:arch /home/arch
2020-06-04 18:31:47 +00:00
2020-06-15 04:33:29 +00:00
# allow ssh to container
2022-11-15 19:17:58 +00:00
RUN mkdir -p -m 700 /root/.ssh
2020-06-15 04:33:29 +00:00
WORKDIR /root/.ssh
2020-06-18 13:30:02 +00:00
RUN touch authorized_keys \
&& chmod 644 authorized_keys
2020-06-15 04:33:29 +00:00
WORKDIR /etc/ssh
2020-06-18 13:30:02 +00:00
RUN tee -a sshd_config <<< 'AllowTcpForwarding yes' \
&& tee -a sshd_config <<< 'PermitTunnel yes' \
&& tee -a sshd_config <<< 'X11Forwarding yes' \
&& tee -a sshd_config <<< 'PasswordAuthentication yes' \
&& tee -a sshd_config <<< 'PermitRootLogin yes' \
&& tee -a sshd_config <<< 'PubkeyAuthentication yes' \
&& tee -a sshd_config <<< 'HostKey /etc/ssh/ssh_host_rsa_key' \
&& tee -a sshd_config <<< 'HostKey /etc/ssh/ssh_host_ecdsa_key' \
&& tee -a sshd_config <<< 'HostKey /etc/ssh/ssh_host_ed25519_key'
2020-06-15 04:33:29 +00:00
2020-06-04 18:31:47 +00:00
USER arch
2024-04-08 10:37:47 +00:00
# download OSX-KVM for the submodules
2021-03-09 16:55:18 +00:00
RUN git clone --recurse-submodules --depth 1 https://github.com/kholia/OSX-KVM.git /home/arch/OSX-KVM
2020-06-04 18:31:47 +00:00
2020-06-15 04:33:29 +00:00
# enable ssh
# docker exec .... ./enable-ssh.sh
USER arch
2020-09-25 19:08:18 +00:00
WORKDIR /home/arch/OSX-KVM
2020-06-18 13:30:02 +00:00
RUN touch enable-ssh.sh \
&& chmod +x ./enable-ssh.sh \
&& tee -a enable-ssh.sh <<< '[[ -f /etc/ssh/ssh_host_rsa_key ]] || \' \
&& tee -a enable-ssh.sh <<< '[[ -f /etc/ssh/ssh_host_ed25519_key ]] || \' \
&& tee -a enable-ssh.sh <<< '[[ -f /etc/ssh/ssh_host_ed25519_key ]] || \' \
&& tee -a enable-ssh.sh <<< 'sudo /usr/bin/ssh-keygen -A' \
2020-06-18 13:42:16 +00:00
&& tee -a enable-ssh.sh <<< 'nohup sudo /usr/bin/sshd -D &'
2020-06-15 04:33:29 +00:00
# QEMU CONFIGURATOR
# set optional ram at runtime -e RAM=16
# set optional cores at runtime -e SMP=4 -e CORES=2
# add any additional commands in QEMU cli format -e EXTRA="-usb -device usb-host,hostbus=1,hostaddr=8"
# default env vars, RUNTIME ONLY, not for editing in build time.
2021-01-05 13:15:44 +00:00
# RUN yes | sudo pacman -Syu qemu libvirt dnsmasq virt-manager bridge-utils edk2-ovmf netctl libvirt-dbus --overwrite --noconfirm
2024-04-08 10:37:47 +00:00
RUN yes | sudo pacman -Syu bc qemu-desktop libvirt dnsmasq virt-manager bridge-utils openresolv jack2 ebtables edk2-ovmf netctl libvirt-dbus wget scrot --overwrite --noconfirm \
2021-02-07 17:59:24 +00:00
&& yes | sudo pacman -Scc
2021-01-05 13:15:44 +00:00
WORKDIR /home/arch/OSX-KVM
2020-09-20 10:36:45 +00:00
2022-11-14 19:00:37 +00:00
# fix invalid signature on old libguestfs
ARG SIGLEVEL = Never
2022-11-18 15:58:05 +00:00
RUN sudo tee -a /etc/pacman.conf <<< " SigLevel = ${ SIGLEVEL } " \
&& sudo tee -a /etc/pacman.conf <<< 'RemoteFileSigLevel = Optional' \
&& sudo sed -i -e 's/^\#RemoteFileSigLevel/RemoteFileSigLevel/g' /etc/pacman.conf
2022-11-14 19:00:37 +00:00
2021-10-31 00:09:09 +00:00
ARG LINUX = true
# required to use libguestfs inside a docker container, to create bootdisks for docker-osx on-the-fly
2024-04-08 10:37:47 +00:00
# reminder this is what makes :naked image larger than expected
2021-10-31 00:09:09 +00:00
RUN if [ [ " ${ LINUX } " = = true ] ] ; then \
2022-11-18 04:35:02 +00:00
sudo pacman -Syu linux linux-headers archlinux-keyring guestfs-tools mkinitcpio pcre pcre2 --noconfirm \
2022-11-14 19:00:37 +00:00
&& libguestfs-test-tool \
2022-11-18 04:35:02 +00:00
&& rm -rf /var/tmp/.guestfs-* \
&& yes | sudo pacman -Scc \
2021-10-31 00:09:09 +00:00
; fi
2021-02-27 07:05:22 +00:00
# optional --build-arg to change branches for testing
ARG BRANCH = master
ARG REPO = 'https://github.com/sickcodes/Docker-OSX.git'
2024-04-08 10:37:47 +00:00
RUN git clone --recurse-submodules --depth 1 --branch " ${ BRANCH : =master } " " ${ REPO : =https : //github.com/sickcodes/Docker-OSX.git } "
2021-02-25 08:52:56 +00:00
2024-09-26 07:47:40 +00:00
RUN touch Launch.sh \
2020-06-18 13:30:02 +00:00
&& chmod +x ./Launch.sh \
2021-03-24 21:16:03 +00:00
&& tee -a Launch.sh <<< '#!/bin/bash' \
&& tee -a Launch.sh <<< 'set -eux' \
2020-09-20 09:31:44 +00:00
&& tee -a Launch.sh <<< 'sudo chown $(id -u):$(id -g) /dev/kvm 2>/dev/null || true' \
&& tee -a Launch.sh <<< 'sudo chown -R $(id -u):$(id -g) /dev/snd 2>/dev/null || true' \
2021-03-17 21:20:31 +00:00
&& tee -a Launch.sh <<< '[[ "${RAM}" = max ]] && export RAM="$(("$(head -n1 /proc/meminfo | tr -dc "[:digit:]") / 1000000"))"' \
2021-03-17 20:27:39 +00:00
&& tee -a Launch.sh <<< '[[ "${RAM}" = half ]] && export RAM="$(("$(head -n1 /proc/meminfo | tr -dc "[:digit:]") / 2000000"))"' \
&& tee -a Launch.sh <<< 'sudo chown -R $(id -u):$(id -g) /dev/snd 2>/dev/null || true' \
2021-11-30 17:39:30 +00:00
&& tee -a Launch.sh <<< 'exec qemu-system-x86_64 -m ${RAM:-4}000 \' \
2021-07-25 20:35:54 +00:00
&& tee -a Launch.sh <<< '-cpu ${CPU:-Penryn},${CPUID_FLAGS:-vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check,}${BOOT_ARGS} \' \
2021-03-24 18:14:05 +00:00
&& tee -a Launch.sh <<< '-machine q35,${KVM-"accel=kvm:tcg"} \' \
2021-02-25 08:52:56 +00:00
&& tee -a Launch.sh <<< '-smp ${CPU_STRING:-${SMP:-4},cores=${CORES:-4}} \' \
2024-03-27 13:07:30 +00:00
&& tee -a Launch.sh <<< '-device qemu-xhci,id=xhci \' \
&& tee -a Launch.sh <<< '-device usb-kbd,bus=xhci.0 -device usb-tablet,bus=xhci.0 \' \
2020-06-18 13:30:02 +00:00
&& tee -a Launch.sh <<< '-device isa-applesmc,osk=ourhardworkbythesewordsguardedpleasedontsteal\(c\)AppleComputerInc \' \
2021-07-25 19:25:39 +00:00
&& tee -a Launch.sh <<< '-drive if=pflash,format=raw,readonly=on,file=/home/arch/OSX-KVM/OVMF_CODE.fd \' \
2020-09-20 10:36:45 +00:00
&& tee -a Launch.sh <<< '-drive if=pflash,format=raw,file=/home/arch/OSX-KVM/OVMF_VARS-1024x768.fd \' \
2020-06-18 13:30:02 +00:00
&& tee -a Launch.sh <<< '-smbios type=2 \' \
2020-09-20 09:14:24 +00:00
&& tee -a Launch.sh <<< '-audiodev ${AUDIO_DRIVER:-alsa},id=hda -device ich9-intel-hda -device hda-duplex,audiodev=hda \' \
2020-06-18 13:30:02 +00:00
&& tee -a Launch.sh <<< '-device ich9-ahci,id=sata \' \
2021-11-29 04:41:24 +00:00
&& tee -a Launch.sh <<< '-drive id=OpenCoreBoot,if=none,snapshot=on,format=qcow2,file=${BOOTDISK:-/home/arch/OSX-KVM/OpenCore/OpenCore.qcow2} \' \
2020-06-18 13:30:02 +00:00
&& tee -a Launch.sh <<< '-device ide-hd,bus=sata.2,drive=OpenCoreBoot \' \
&& tee -a Launch.sh <<< '-device ide-hd,bus=sata.3,drive=InstallMedia \' \
2021-11-30 17:39:30 +00:00
&& tee -a Launch.sh <<< '-drive id=InstallMedia,if=none,file=/home/arch/OSX-KVM/BaseSystem.img,format=${BASESYSTEM_FORMAT:-qcow2} \' \
2021-03-24 13:40:16 +00:00
&& tee -a Launch.sh <<< '-drive id=MacHDD,if=none,file=${IMAGE_PATH:-/home/arch/OSX-KVM/mac_hdd_ng.img},format=${IMAGE_FORMAT:-qcow2} \' \
2020-06-18 13:30:02 +00:00
&& tee -a Launch.sh <<< '-device ide-hd,bus=sata.4,drive=MacHDD \' \
2021-03-02 21:24:28 +00:00
&& tee -a Launch.sh <<< '-netdev user,id=net0,hostfwd=tcp::${INTERNAL_SSH_PORT:-10022}-:22,hostfwd=tcp::${SCREEN_SHARE_PORT:-5900}-:5900,${ADDITIONAL_PORTS} \' \
2021-03-01 11:23:12 +00:00
&& tee -a Launch.sh <<< '-device ${NETWORKING:-vmxnet3},netdev=net0,id=net0,mac=${MAC_ADDRESS:-52:54:00:09:49:17} \' \
2020-06-18 13:30:02 +00:00
&& tee -a Launch.sh <<< '-monitor stdio \' \
2021-07-25 19:25:39 +00:00
&& tee -a Launch.sh <<< '-boot menu=on \' \
2020-06-18 13:30:02 +00:00
&& tee -a Launch.sh <<< '-vga vmware \' \
2020-09-20 09:04:19 +00:00
&& tee -a Launch.sh <<< '${EXTRA:-}'
2020-06-04 18:31:47 +00:00
2020-10-06 17:12:45 +00:00
# docker exec containerid mv ./Launch-nopicker.sh ./Launch.sh
2021-02-25 14:03:06 +00:00
# This is now a legacy command.
# You can use -e BOOTDISK=/bootdisk with -v ./bootdisk.img:/bootdisk
2021-10-29 17:25:51 +00:00
### LEGACY CODE
2020-10-06 17:12:45 +00:00
RUN grep -v InstallMedia ./Launch.sh > ./Launch-nopicker.sh \
&& chmod +x ./Launch-nopicker.sh \
&& sed -i -e s/OpenCore\. qcow2/OpenCore\- nopicker\. qcow2/ ./Launch-nopicker.sh
2021-10-29 17:25:51 +00:00
###
2020-10-06 17:12:45 +00:00
2021-07-28 18:32:48 +00:00
USER arch
2024-08-28 15:37:42 +00:00
ENV USER = arch
2021-07-28 17:25:52 +00:00
2021-09-16 18:47:52 +00:00
# These are hardcoded serials for non-iMessage related research
# Overwritten by using GENERATE_UNIQUE=true
# Upstream removed nopicker, so we are adding it back in, at build time
# Once again, this is just for the Docker build so there is a default nopicker image there
2021-10-31 00:09:09 +00:00
# libguestfs verbose
ENV LIBGUESTFS_DEBUG = 1
ENV LIBGUESTFS_TRACE = 1
2021-09-16 18:47:52 +00:00
ARG STOCK_DEVICE_MODEL = iMacPro1,1
ARG STOCK_SERIAL = C02TM2ZBHX87
ARG STOCK_BOARD_SERIAL = C02717306J9JG361M
ARG STOCK_UUID = 007076A6-F2A2-4461-BBE5-BAD019F8025A
ARG STOCK_MAC_ADDRESS = 00 :0A:27:00:00:00
ARG STOCK_WIDTH = 1920
ARG STOCK_HEIGHT = 1080
ARG STOCK_MASTER_PLIST_URL = https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist
ARG STOCK_MASTER_PLIST_URL_NOPICKER = https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-nopicker-custom.plist
2021-10-28 23:17:44 +00:00
ARG STOCK_BOOTDISK = /home/arch/OSX-KVM/OpenCore/OpenCore.qcow2
ARG STOCK_BOOTDISK_NOPICKER = /home/arch/OSX-KVM/OpenCore/OpenCore-nopicker.qcow2
2021-09-16 18:47:52 +00:00
RUN ./Docker-OSX/osx-serial-generator/generate-specific-bootdisk.sh \
--master-plist-url= " ${ STOCK_MASTER_PLIST_URL } " \
--model " ${ STOCK_DEVICE_MODEL } " \
--serial " ${ STOCK_SERIAL } " \
--board-serial " ${ STOCK_BOARD_SERIAL } " \
--uuid " ${ STOCK_UUID } " \
--mac-address " ${ STOCK_MAC_ADDRESS } " \
--width " ${ STOCK_WIDTH } " \
--height " ${ STOCK_HEIGHT } " \
2021-11-29 04:15:44 +00:00
--output-bootdisk " ${ STOCK_BOOTDISK } " || exit 1 \
; rm -rf /var/tmp/.guestfs-*
2021-09-16 18:47:52 +00:00
RUN ./Docker-OSX/osx-serial-generator/generate-specific-bootdisk.sh \
--master-plist-url= " ${ STOCK_MASTER_PLIST_URL_NOPICKER } " \
--model " ${ STOCK_DEVICE_MODEL } " \
--serial " ${ STOCK_SERIAL } " \
--board-serial " ${ STOCK_BOARD_SERIAL } " \
--uuid " ${ STOCK_UUID } " \
--mac-address " ${ STOCK_MAC_ADDRESS } " \
--width " ${ STOCK_WIDTH } " \
--height " ${ STOCK_HEIGHT } " \
2021-11-29 04:15:44 +00:00
--output-bootdisk " ${ STOCK_BOOTDISK_NOPICKER } " || exit 1 \
; rm -rf /var/tmp/.guestfs-*
2021-09-16 18:47:52 +00:00
2021-10-29 17:25:51 +00:00
### symlink the old directory as upstream has renamed a directory. Symlinking purely for backwards compatability!
2021-10-30 21:55:07 +00:00
RUN ln -s /home/arch/OSX-KVM/OpenCore /home/arch/OSX-KVM/OpenCore-Catalina || true
2021-10-28 23:17:44 +00:00
####
2021-03-24 13:40:16 +00:00
#### SPECIAL RUNTIME ARGUMENTS BELOW
# env -e ADDITIONAL_PORTS with a comma
# for example, -e ADDITIONAL_PORTS=hostfwd=tcp::23-:23,
ENV ADDITIONAL_PORTS =
2021-11-29 04:34:20 +00:00
# since the Makefile uses raw, and raw uses the full disk amount
# we want to use a compressed qcow2
# ENV BASESYSTEM_FORMAT=raw
ENV BASESYSTEM_FORMAT = qcow2
2021-05-06 05:29:26 +00:00
# add additional QEMU boot arguments
ENV BOOT_ARGS =
2021-03-06 19:25:26 +00:00
ENV BOOTDISK =
2021-02-25 18:16:24 +00:00
2021-07-08 23:32:26 +00:00
# edit the CPU that is being emulated
2021-05-06 05:29:26 +00:00
ENV CPU = Penryn
2021-07-25 20:35:54 +00:00
ENV CPUID_FLAGS = 'vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check,'
2021-05-06 05:29:26 +00:00
2021-01-24 13:06:37 +00:00
ENV DISPLAY = :0.0
2020-09-20 09:18:40 +00:00
2021-07-08 23:32:26 +00:00
# Deprecated
2021-02-25 18:16:24 +00:00
ENV ENV = /env
2021-03-03 16:54:45 +00:00
# Boolean for generating a bootdisk with new random serials.
ENV GENERATE_UNIQUE = false
# Boolean for generating a bootdisk with specific serials.
ENV GENERATE_SPECIFIC = false
2021-03-24 13:40:16 +00:00
ENV IMAGE_PATH = /home/arch/OSX-KVM/mac_hdd_ng.img
ENV IMAGE_FORMAT = qcow2
ENV KVM = 'accel=kvm:tcg'
2021-11-30 20:32:09 +00:00
ENV MASTER_PLIST_URL = "https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist"
2021-03-24 13:40:16 +00:00
# ENV NETWORKING=e1000-82545em
ENV NETWORKING = vmxnet3
2021-03-03 16:54:45 +00:00
# boolean for skipping the disk selection menu at in the boot process
ENV NOPICKER = false
2021-03-24 13:40:16 +00:00
# dynamic RAM options for runtime
2021-11-30 17:39:30 +00:00
ENV RAM = 4
2021-03-24 13:40:16 +00:00
# ENV RAM=max
# ENV RAM=half
2021-03-03 16:54:45 +00:00
# The x and y coordinates for resolution.
# Must be used with either -e GENERATE_UNIQUE=true or -e GENERATE_SPECIFIC=true.
ENV WIDTH = 1920
ENV HEIGHT = 1080
2021-02-25 14:03:06 +00:00
2021-01-26 21:25:45 +00:00
VOLUME [ "/tmp/.X11-unix" ]
2021-02-25 14:03:06 +00:00
# check if /image is a disk image or a directory. This allows you to optionally use -v disk.img:/image
# NOPICKER is used to skip the disk selection screen
# GENERATE_UNIQUE is used to generate serial numbers on boot.
# /env is a file that you can generate and save using -v source.sh:/env
# the env file is a file that you can carry to the next container which will supply the serials numbers.
# GENERATE_SPECIFIC is used to either accept the env serial numbers OR you can supply using:
# -e DEVICE_MODEL="iMacPro1,1" \
# -e SERIAL="C02TW0WAHX87" \
# -e BOARD_SERIAL="C027251024NJG36UE" \
# -e UUID="5CCB366D-9118-4C61-A00A-E5BAF3BED451" \
# -e MAC_ADDRESS="A8:5C:2C:9A:46:2F" \
# the output will be /bootdisk.
# /bootdisk is a useful persistent place to store the 15Mb serial number bootdisk.
# if you don't set any of the above:
2021-10-28 23:17:44 +00:00
# the default serial numbers are already contained in ./OpenCore/OpenCore.qcow2
2021-02-25 14:03:06 +00:00
# And the default serial numbers
2024-09-26 07:47:40 +00:00
# DMCA compliant download process
2024-09-26 16:17:43 +00:00
# If BaseSystem.img does not exist, download ${SHORTNAME}
# shortname default is catalina, which means :latest is catalina
ENV SHORTNAME = sonoma
2024-09-26 07:47:40 +00:00
2024-09-26 16:17:43 +00:00
ENV BASESYSTEM_IMAGE = BaseSystem.img
2024-09-26 07:47:40 +00:00
CMD ! [ [ -e " ${ BASESYSTEM_IMAGE :- BaseSystem .img } " ] ] \
&& printf '%s\n' " No BaseSystem.img available, downloading ${ SHORTNAME } " \
&& make \
&& qemu-img convert BaseSystem.dmg -O qcow2 -p -c ${ BASESYSTEM_IMAGE :- BaseSystem .img } \
&& rm ./BaseSystem.dmg \
; sudo touch /dev/kvm /dev/snd " ${ IMAGE_PATH } " " ${ BOOTDISK } " " ${ ENV } " 2>/dev/null || true \
2021-05-04 07:54:27 +00:00
; sudo chown -R $( id -u) :$( id -g) /dev/kvm /dev/snd " ${ IMAGE_PATH } " " ${ BOOTDISK } " " ${ ENV } " 2>/dev/null || true \
2021-02-26 05:49:40 +00:00
; [ [ " ${ NOPICKER } " = = true ] ] && { \
sed -i '/^.*InstallMedia.*/d' Launch.sh \
2021-10-28 23:17:44 +00:00
&& export BOOTDISK = " ${ BOOTDISK : =/home/arch/OSX-KVM/OpenCore/OpenCore-nopicker.qcow2 } " \
2021-02-26 05:49:40 +00:00
; } \
2021-10-28 23:17:44 +00:00
|| export BOOTDISK = " ${ BOOTDISK : =/home/arch/OSX-KVM/OpenCore/OpenCore.qcow2 } " \
2021-02-26 05:26:35 +00:00
; [ [ " ${ GENERATE_UNIQUE } " = = true ] ] && { \
2021-03-09 16:55:18 +00:00
./Docker-OSX/osx-serial-generator/generate-unique-machine-values.sh \
2021-03-04 09:52:45 +00:00
--master-plist-url= " ${ MASTER_PLIST_URL } " \
2021-03-03 16:54:45 +00:00
--count 1 \
--tsv ./serial.tsv \
--bootdisks \
--width " ${ WIDTH :- 1920 } " \
--height " ${ HEIGHT :- 1080 } " \
2021-10-28 23:17:44 +00:00
--output-bootdisk " ${ BOOTDISK : =/home/arch/OSX-KVM/OpenCore/OpenCore.qcow2 } " \
2021-03-04 12:05:41 +00:00
--output-env " ${ ENV : =/env } " \
2021-04-18 10:54:43 +00:00
|| exit 1 ; } \
2021-02-26 05:26:35 +00:00
; [ [ " ${ GENERATE_SPECIFIC } " = = true ] ] && { \
2021-03-04 11:57:52 +00:00
source " ${ ENV : =/env } " 2>/dev/null \
2021-03-09 16:55:18 +00:00
; ./Docker-OSX/osx-serial-generator/generate-specific-bootdisk.sh \
2021-03-04 09:52:45 +00:00
--master-plist-url= " ${ MASTER_PLIST_URL } " \
2021-02-25 14:03:06 +00:00
--model " ${ DEVICE_MODEL } " \
--serial " ${ SERIAL } " \
--board-serial " ${ BOARD_SERIAL } " \
--uuid " ${ UUID } " \
--mac-address " ${ MAC_ADDRESS } " \
2021-03-03 16:54:45 +00:00
--width " ${ WIDTH :- 1920 } " \
--height " ${ HEIGHT :- 1080 } " \
2021-10-28 23:17:44 +00:00
--output-bootdisk " ${ BOOTDISK : =/home/arch/OSX-KVM/OpenCore/OpenCore.qcow2 } " \
2021-04-18 10:54:43 +00:00
|| exit 1 ; } \
2021-03-25 13:59:59 +00:00
; ./enable-ssh.sh && /bin/bash -c ./Launch.sh
2020-06-04 18:31:47 +00:00
2020-06-15 04:33:29 +00:00
# virt-manager mode: eta son
# CMD virsh define <(envsubst < Docker-OSX.xml) && virt-manager || virt-manager
# CMD virsh define <(envsubst < macOS-libvirt-Catalina.xml) && virt-manager || virt-manager