2021-01-24 12:47:19 +00:00
|
|
|
#!/usr/bin/docker
|
|
|
|
# ____ __ ____ ______ __
|
|
|
|
# / __ \____ _____/ /_____ _____/ __ \/ ___/ |/ /
|
|
|
|
# / / / / __ \/ ___/ //_/ _ \/ ___/ / / /\__ \| /
|
|
|
|
# / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / |
|
2021-03-04 13:22:13 +00:00
|
|
|
# /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| :NAKED
|
2021-01-24 12:47:19 +00:00
|
|
|
#
|
2021-03-04 13:27:12 +00:00
|
|
|
# Title: Docker-OSX (Mac on Docker)
|
2021-03-04 13:22:13 +00:00
|
|
|
# Author: Sick.Codes https://twitter.com/sickcodes
|
2021-05-06 05:29:26 +00:00
|
|
|
# Version: 4.4
|
2021-01-24 12:47:19 +00:00
|
|
|
# License: GPLv3+
|
|
|
|
# Repository: https://github.com/sickcodes/Docker-OSX
|
2021-03-04 13:22:13 +00:00
|
|
|
# Website: https://sick.codes
|
2021-01-24 12:47:19 +00:00
|
|
|
#
|
|
|
|
# This image won't run unless you supply a disk image using:
|
|
|
|
# -v ${PWD}/mac_hdd_ng.img:/image
|
|
|
|
#
|
|
|
|
# Take screenshots in the Arch container and display in terminal: scrotcat
|
|
|
|
#
|
|
|
|
# Build:
|
|
|
|
#
|
|
|
|
# docker build -t docker-osx:naked -f Dockerfile.naked .
|
|
|
|
#
|
|
|
|
# Run headless:
|
|
|
|
#
|
|
|
|
# docker run -it --device /dev/kvm -p 50922:10022 -v ${PWD}/mac_hdd_ng.img:/image docker-osx:naked
|
|
|
|
#
|
|
|
|
# Run with display:
|
|
|
|
#
|
|
|
|
# docker run -it --device /dev/kvm -p 50922:10022 -v ${PWD}/mac_hdd_ng.img:/image -e "DISPLAY=${DISPLAY:-:0.0}" -v /tmp/.X11-unix:/tmp/.X11-unix docker-osx:naked
|
|
|
|
#
|
|
|
|
|
2021-02-26 04:22:56 +00:00
|
|
|
FROM sickcodes/docker-osx:latest
|
2021-01-24 12:47:19 +00:00
|
|
|
|
|
|
|
MAINTAINER 'https://twitter.com/sickcodes' <https://sick.codes>
|
|
|
|
|
|
|
|
USER root
|
|
|
|
|
|
|
|
WORKDIR /root
|
|
|
|
|
|
|
|
RUN rm -f /home/arch/OSX-KVM/mac_hdd_ng.img
|
|
|
|
|
|
|
|
# OPTIONAL: Arch Linux server mirrors for super fast builds
|
|
|
|
# set RANKMIRRORS to any value other that nothing, e.g. -e RANKMIRRORS=true
|
|
|
|
ARG RANKMIRRORS
|
|
|
|
ARG MIRROR_COUNTRY=US
|
|
|
|
ARG MIRROR_COUNT=10
|
|
|
|
RUN if [[ "${RANKMIRRORS}" ]]; then { pacman -Sy wget --noconfirm || pacman -Syu wget --noconfirm ; } \
|
|
|
|
; wget -O ./rankmirrors "https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/rankmirrors" \
|
|
|
|
; 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 \
|
|
|
|
&& tee -a /etc/pacman.d/mirrorlist <<< 'Server = http://mirrors.evowise.com/archlinux/$repo/os/$arch' \
|
|
|
|
&& tee -a /etc/pacman.d/mirrorlist <<< 'Server = http://mirror.rackspace.com/archlinux/$repo/os/$arch' \
|
|
|
|
&& tee -a /etc/pacman.d/mirrorlist <<< 'Server = https://mirror.rackspace.com/archlinux/$repo/os/$arch' \
|
|
|
|
&& cat /etc/pacman.d/mirrorlist ; fi
|
|
|
|
|
2021-02-07 19:25:59 +00:00
|
|
|
# For taking screenshots of the Xfvb screen, useful during development.
|
|
|
|
ARG SCROT
|
|
|
|
|
|
|
|
RUN pacman -Syu xorg-server-xvfb wget xterm xorg-xhost xorg-xrandr sshpass --noconfirm \
|
|
|
|
&& if [[ "${SCROT}" ]]; then \
|
|
|
|
pacman -Syu scrot base-devel --noconfirm \
|
2021-03-09 16:55:18 +00:00
|
|
|
&& git clone --recurse-submodules --depth 1 https://github.com/stolk/imcat.git \
|
2021-02-07 19:25:59 +00:00
|
|
|
&& cd imcat \
|
|
|
|
&& make \
|
|
|
|
&& sudo cp imcat /usr/bin/imcat \
|
|
|
|
&& touch /usr/bin/scrotcat \
|
|
|
|
&& tee -a /usr/bin/scrotcat <<< '/usr/bin/imcat <(scrot -o /dev/stdout)' \
|
|
|
|
&& chmod +x /usr/bin/scrotcat \
|
|
|
|
; else \
|
|
|
|
touch /usr/bin/scrotcat \
|
|
|
|
&& echo echo >> /usr/bin/scrotcat \
|
|
|
|
&& chmod +x /usr/bin/scrotcat \
|
|
|
|
; fi \
|
|
|
|
; yes | pacman -Scc
|
2021-01-24 12:47:19 +00:00
|
|
|
|
|
|
|
USER arch
|
|
|
|
|
2021-02-08 00:58:07 +00:00
|
|
|
WORKDIR /home/arch/OSX-KVM
|
|
|
|
|
2021-01-24 12:47:19 +00:00
|
|
|
RUN mkdir -p ~/.ssh \
|
|
|
|
&& touch ~/.ssh/authorized_keys \
|
|
|
|
&& touch ~/.ssh/config \
|
|
|
|
&& chmod 700 ~/.ssh \
|
|
|
|
&& chmod 600 ~/.ssh/config \
|
|
|
|
&& chmod 600 ~/.ssh/authorized_keys \
|
|
|
|
&& tee -a ~/.ssh/config <<< 'Host *' \
|
|
|
|
&& tee -a ~/.ssh/config <<< ' StrictHostKeyChecking no' \
|
|
|
|
&& tee -a ~/.ssh/config <<< ' UserKnownHostsFile=/dev/null'
|
|
|
|
|
2021-03-24 13:40:16 +00:00
|
|
|
#### SPECIAL RUNTIME ARGUMENTS BELOW
|
|
|
|
|
|
|
|
ENV ADDITIONAL_PORTS=
|
|
|
|
|
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-01-24 12:47:19 +00:00
|
|
|
|
2021-05-06 05:29:26 +00:00
|
|
|
# edit the CPU that is beign emulated
|
|
|
|
ENV CPU=Penryn
|
|
|
|
|
2021-01-24 12:47:19 +00:00
|
|
|
ENV DISPLAY=:99
|
|
|
|
|
2021-03-06 17:59:03 +00:00
|
|
|
ENV HEADLESS=false
|
|
|
|
|
2021-02-25 18:16:24 +00:00
|
|
|
ENV ENV=/env
|
|
|
|
|
2021-03-24 13:40:16 +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-01-24 12:47:19 +00:00
|
|
|
ENV IMAGE_PATH=/image
|
2021-03-24 13:40:16 +00:00
|
|
|
ENV IMAGE_FORMAT=qcow2
|
|
|
|
|
|
|
|
ENV KVM='accel=kvm:tcg'
|
|
|
|
|
|
|
|
# ENV MASTER_PLIST_URL="https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist"
|
|
|
|
|
|
|
|
# ENV NETWORKING=e1000-82545em
|
|
|
|
ENV NETWORKING=vmxnet3
|
2021-01-24 12:47:19 +00:00
|
|
|
|
2021-02-25 18:16:24 +00:00
|
|
|
ENV NOPICKER=true
|
|
|
|
|
2021-03-24 13:40:16 +00:00
|
|
|
# dynamic RAM options for runtime
|
|
|
|
ENV RAM=3
|
|
|
|
# ENV RAM=max
|
|
|
|
# ENV RAM=half
|
|
|
|
|
|
|
|
# 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-04-18 10:54:43 +00:00
|
|
|
# libguestfs verbose
|
|
|
|
ENV LIBGUESTFS_DEBUG=1
|
|
|
|
ENV LIBGUESTFS_TRACE=1
|
|
|
|
|
|
|
|
CMD 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-03-06 17:59:03 +00:00
|
|
|
; { [[ "${DISPLAY}" = ':99' ]] || [[ "${HEADLESS}" == true ]] ; } && { \
|
2021-02-07 19:25:59 +00:00
|
|
|
nohup Xvfb :99 -screen 0 1920x1080x16 \
|
|
|
|
& until [[ "$(xrandr --query 2>/dev/null)" ]]; do sleep 1 ; done \
|
|
|
|
; } \
|
2021-02-26 05:49:40 +00:00
|
|
|
; [[ "${NOPICKER}" == true ]] && { \
|
|
|
|
sed -i '/^.*InstallMedia.*/d' Launch.sh \
|
2021-03-06 19:18:23 +00:00
|
|
|
&& export BOOTDISK="${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2}" \
|
2021-02-26 05:49:40 +00:00
|
|
|
; } \
|
2021-03-06 19:18:23 +00:00
|
|
|
|| export BOOTDISK="${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/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-04 09:12:50 +00:00
|
|
|
--count 1 \
|
|
|
|
--tsv ./serial.tsv \
|
|
|
|
--bootdisks \
|
|
|
|
--width "${WIDTH:-1920}" \
|
|
|
|
--height "${HEIGHT:-1080}" \
|
2021-03-06 19:18:23 +00:00
|
|
|
--output-bootdisk "${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/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-04 09:12:50 +00:00
|
|
|
--width "${WIDTH:-1920}" \
|
|
|
|
--height "${HEIGHT:-1080}" \
|
2021-03-06 19:18:23 +00:00
|
|
|
--output-bootdisk "${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \
|
2021-04-18 10:54:43 +00:00
|
|
|
|| exit 1 ; } \
|
2021-03-28 10:17:47 +00:00
|
|
|
; ./enable-ssh.sh && /bin/bash -c ./Launch.sh
|