Skip to content

Commit e718aec

Browse files
committed
Rollback naked
1 parent 0202359 commit e718aec

File tree

1 file changed

+26
-223
lines changed

1 file changed

+26
-223
lines changed

Dockerfile.naked

Lines changed: 26 additions & 223 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,22 @@
3030
# 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
3131
#
3232

33-
FROM archlinux:base-devel
34-
LABEL maintainer='https://twitter.com/sickcodes <https://sick.codes>'
33+
FROM sickcodes/docker-osx:latest
3534

36-
SHELL ["/bin/bash", "-c"]
35+
MAINTAINER 'https://twitter.com/sickcodes' <https://sick.codes>
3736

38-
# change disk size here or add during build, e.g. --build-arg VERSION=10.14.5 --build-arg SIZE=50G
39-
ARG SIZE=200G
37+
USER root
38+
39+
WORKDIR /root
40+
41+
RUN rm -f /home/arch/OSX-KVM/mac_hdd_ng.img
4042

4143
# OPTIONAL: Arch Linux server mirrors for super fast builds
4244
# set RANKMIRRORS to any value other that nothing, e.g. -e RANKMIRRORS=true
43-
RUN perl -i -p -e s/^\#Color/Color$'\n'ParallelDownloads\ =\ 30/g /etc/pacman.conf
4445
ARG RANKMIRRORS
4546
ARG MIRROR_COUNTRY=US
4647
ARG MIRROR_COUNT=10
47-
48-
RUN if [[ "${RANKMIRRORS}" ]]; then \
49-
{ pacman -Sy wget --noconfirm || pacman -Syu wget --noconfirm ; } \
48+
RUN if [[ "${RANKMIRRORS}" ]]; then { pacman -Sy wget --noconfirm || pacman -Syu wget --noconfirm ; } \
5049
; wget -O ./rankmirrors "https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/rankmirrors" \
5150
; wget -O- "https://www.archlinux.org/mirrorlist/?country=${MIRROR_COUNTRY:-US}&protocol=https&use_mirror_status=on" \
5251
| sed -e 's/^#Server/Server/' -e '/^#/d' \
@@ -58,40 +57,11 @@ RUN if [[ "${RANKMIRRORS}" ]]; then \
5857
&& cat /etc/pacman.d/mirrorlist \
5958
; fi
6059

61-
# This fails on hub.docker.com, useful for debugging in cloud
62-
# RUN [[ $(egrep -c '(svm|vmx)' /proc/cpuinfo) -gt 0 ]] || { echo KVM not possible on this host && exit 1; }
63-
64-
# RUN tee -a /etc/pacman.conf <<< '[community-testing]' \
65-
# && tee -a /etc/pacman.conf <<< 'Include = /etc/pacman.d/mirrorlist'
66-
67-
RUN pacman -Syu git zip vim nano alsa-utils openssh --noconfirm \
68-
&& ln -s /bin/vim /bin/vi \
69-
&& useradd arch -p arch \
70-
&& tee -a /etc/sudoers <<< 'arch ALL=(ALL) NOPASSWD: ALL' \
71-
&& mkdir /home/arch \
72-
&& chown arch:arch /home/arch \
73-
&& yes | sudo pacman -Scc
74-
75-
# allow ssh to container
76-
RUN mkdir -m 700 /root/.ssh \
77-
&& touch /root/.ssh/authorized_keys \
78-
&& chmod 644 /root/.ssh/authorized_keys \
79-
&& tee -a /etc/ssh/sshd_config <<< 'AllowTcpForwarding yes' \
80-
&& tee -a /etc/ssh/sshd_config <<< 'PermitTunnel yes' \
81-
&& tee -a /etc/ssh/sshd_config <<< 'X11Forwarding yes' \
82-
&& tee -a /etc/ssh/sshd_config <<< 'PasswordAuthentication yes' \
83-
&& tee -a /etc/ssh/sshd_config <<< 'PermitRootLogin yes' \
84-
&& tee -a /etc/ssh/sshd_config <<< 'PubkeyAuthentication yes' \
85-
&& tee -a /etc/ssh/sshd_config <<< 'HostKey /etc/ssh/ssh_host_rsa_key' \
86-
&& tee -a /etc/ssh/sshd_config <<< 'HostKey /etc/ssh/ssh_host_ecdsa_key' \
87-
&& tee -a /etc/ssh/sshd_config <<< 'HostKey /etc/ssh/ssh_host_ed25519_key'
88-
8960
# For taking screenshots of the Xfvb screen, useful during development.
9061
ARG SCROT
9162

92-
# the following code only runs if --build-arg SCROT=true is used
9363
RUN pacman -Syu xorg-server-xvfb wget xterm xorg-xhost xorg-xrandr sshpass --noconfirm \
94-
&& if [[ "${SCROT}" == true ]]; then \
64+
&& if [[ "${SCROT}" ]]; then \
9565
pacman -Syu scrot base-devel --noconfirm \
9666
&& git clone --recurse-submodules --depth 1 https://github.com/stolk/imcat.git \
9767
&& cd imcat \
@@ -111,102 +81,6 @@ USER arch
11181

11282
ENV USER arch
11383

114-
# download OSX-KVM
115-
# RUN git clone --recurse-submodules --depth 1 https://github.com/kholia/OSX-KVM.git /home/arch/OSX-KVM
116-
RUN git clone --recurse-submodules --depth 1 https://github.com/kholia/OSX-KVM.git /home/arch/OSX-KVM
117-
118-
WORKDIR /home/arch/OSX-KVM
119-
120-
RUN touch enable-ssh.sh \
121-
&& chmod +x ./enable-ssh.sh \
122-
&& tee -a enable-ssh.sh <<< '[[ -f /etc/ssh/ssh_host_rsa_key ]] || \' \
123-
&& tee -a enable-ssh.sh <<< '[[ -f /etc/ssh/ssh_host_ed25519_key ]] || \' \
124-
&& tee -a enable-ssh.sh <<< '[[ -f /etc/ssh/ssh_host_ed25519_key ]] || \' \
125-
&& tee -a enable-ssh.sh <<< 'sudo /usr/bin/ssh-keygen -A' \
126-
&& tee -a enable-ssh.sh <<< 'nohup sudo /usr/bin/sshd -D &'
127-
128-
# QEMU CONFIGURATOR
129-
# set optional ram at runtime -e RAM=16
130-
# set optional cores at runtime -e SMP=4 -e CORES=2
131-
# add any additional commands in QEMU cli format -e EXTRA="-usb -device usb-host,hostbus=1,hostaddr=8"
132-
133-
# default env vars, RUNTIME ONLY, not for editing in build time.
134-
135-
# RUN yes | sudo pacman -Syu qemu libvirt dnsmasq virt-manager bridge-utils edk2-ovmf netctl libvirt-dbus --overwrite --noconfirm
136-
137-
RUN yes | sudo pacman -Syu bc qemu libvirt dnsmasq virt-manager bridge-utils openresolv jack ebtables edk2-ovmf netctl libvirt-dbus wget --overwrite --noconfirm \
138-
&& yes | sudo pacman -Scc
139-
140-
WORKDIR /home/arch/OSX-KVM
141-
142-
# we still want a recovery disk, monterey is backwards compatible (APFS), however, the Catalina and below are not (HFS+).
143-
ARG SHORTNAME=monterey
144-
145-
RUN make \
146-
&& qemu-img convert BaseSystem.dmg -O qcow2 -p -c BaseSystem.img \
147-
&& rm ./BaseSystem.dmg
148-
149-
ARG LINUX=true
150-
151-
# required to use libguestfs inside a docker container, to create bootdisks for docker-osx on-the-fly
152-
RUN if [[ "${LINUX}" == true ]]; then \
153-
sudo pacman -Syu linux libguestfs --noconfirm \
154-
&& yes | sudo pacman -Scc \
155-
; fi
156-
157-
# optional --build-arg to change branches for testing
158-
ARG BRANCH=master
159-
ARG REPO='https://github.com/sickcodes/Docker-OSX.git'
160-
# RUN git clone --recurse-submodules --depth 1 --branch "${BRANCH}" "${REPO}"
161-
RUN git clone --recurse-submodules --depth 1 --branch "${BRANCH}" "${REPO}"
162-
163-
RUN touch Launch.sh \
164-
&& chmod +x ./Launch.sh \
165-
&& tee -a Launch.sh <<< '#!/bin/bash' \
166-
&& tee -a Launch.sh <<< 'set -eux' \
167-
&& tee -a Launch.sh <<< 'sudo chown $(id -u):$(id -g) /dev/kvm 2>/dev/null || true' \
168-
&& tee -a Launch.sh <<< 'sudo chown -R $(id -u):$(id -g) /dev/snd 2>/dev/null || true' \
169-
&& tee -a Launch.sh <<< '[[ "${RAM}" = max ]] && export RAM="$(("$(head -n1 /proc/meminfo | tr -dc "[:digit:]") / 1000000"))"' \
170-
&& tee -a Launch.sh <<< '[[ "${RAM}" = half ]] && export RAM="$(("$(head -n1 /proc/meminfo | tr -dc "[:digit:]") / 2000000"))"' \
171-
&& tee -a Launch.sh <<< 'sudo chown -R $(id -u):$(id -g) /dev/snd 2>/dev/null || true' \
172-
&& tee -a Launch.sh <<< 'exec qemu-system-x86_64 -m ${RAM:-2}000 \' \
173-
&& 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} \' \
174-
&& tee -a Launch.sh <<< '-machine q35,${KVM-"accel=kvm:tcg"} \' \
175-
&& tee -a Launch.sh <<< '-smp ${CPU_STRING:-${SMP:-4},cores=${CORES:-4}} \' \
176-
&& tee -a Launch.sh <<< '-usb -device usb-kbd -device usb-tablet \' \
177-
&& tee -a Launch.sh <<< '-device isa-applesmc,osk=ourhardworkbythesewordsguardedpleasedontsteal\(c\)AppleComputerInc \' \
178-
&& tee -a Launch.sh <<< '-drive if=pflash,format=raw,readonly=on,file=/home/arch/OSX-KVM/OVMF_CODE.fd \' \
179-
&& tee -a Launch.sh <<< '-drive if=pflash,format=raw,file=/home/arch/OSX-KVM/OVMF_VARS-1024x768.fd \' \
180-
&& tee -a Launch.sh <<< '-smbios type=2 \' \
181-
&& tee -a Launch.sh <<< '-audiodev ${AUDIO_DRIVER:-alsa},id=hda -device ich9-intel-hda -device hda-duplex,audiodev=hda \' \
182-
&& tee -a Launch.sh <<< '-device ich9-ahci,id=sata \' \
183-
&& tee -a Launch.sh <<< '-drive id=OpenCoreBoot,if=none,snapshot=on,format=qcow2,file=${BOOTDISK:-/home/arch/OSX-KVM/OpenCore/OpenCore.qcow2} \' \
184-
&& tee -a Launch.sh <<< '-device ide-hd,bus=sata.2,drive=OpenCoreBoot \' \
185-
&& tee -a Launch.sh <<< '-device ide-hd,bus=sata.3,drive=InstallMedia \' \
186-
&& tee -a Launch.sh <<< '-drive id=InstallMedia,if=none,file=/home/arch/OSX-KVM/BaseSystem.img,format=${BASESYSTEM_FORMAT:-qcow2} \' \
187-
&& tee -a Launch.sh <<< '-drive id=MacHDD,if=none,file=${IMAGE_PATH:-/home/arch/OSX-KVM/mac_hdd_ng.img},format=${IMAGE_FORMAT:-qcow2} \' \
188-
&& tee -a Launch.sh <<< '-device ide-hd,bus=sata.4,drive=MacHDD \' \
189-
&& tee -a Launch.sh <<< '-netdev user,id=net0,hostfwd=tcp::${INTERNAL_SSH_PORT:-10022}-:22,hostfwd=tcp::${SCREEN_SHARE_PORT:-5900}-:5900,${ADDITIONAL_PORTS} \' \
190-
&& tee -a Launch.sh <<< '-device ${NETWORKING:-vmxnet3},netdev=net0,id=net0,mac=${MAC_ADDRESS:-52:54:00:09:49:17} \' \
191-
&& tee -a Launch.sh <<< '-monitor stdio \' \
192-
&& tee -a Launch.sh <<< '-boot menu=on \' \
193-
&& tee -a Launch.sh <<< '-vga vmware \' \
194-
&& tee -a Launch.sh <<< '${EXTRA:-}'
195-
196-
# docker exec containerid mv ./Launch-nopicker.sh ./Launch.sh
197-
# This is now a legacy command.
198-
# You can use -e BOOTDISK=/bootdisk with -v ./bootdisk.img:/bootdisk
199-
200-
### LEGACY CODE
201-
RUN grep -v InstallMedia ./Launch.sh > ./Launch-nopicker.sh \
202-
&& chmod +x ./Launch-nopicker.sh \
203-
&& sed -i -e s/OpenCore\.qcow2/OpenCore\-nopicker\.qcow2/ ./Launch-nopicker.sh
204-
###
205-
206-
USER arch
207-
208-
ENV USER arch
209-
21084
#### libguestfs versioning
21185

21286
# 5.13+ problem resolved by building the qcow2 against 5.12 using libguestfs-1.44.1-6
@@ -218,66 +92,16 @@ ENV KERNEL_PACKAGE_URL=https://archive.archlinux.org/packages/l/linux/linux-5.12
21892
ENV KERNEL_HEADERS_PACKAGE_URL=https://archive.archlinux.org/packages/l/linux/linux-headers-5.12.14.arch1-1-x86_64.pkg.tar.zst
21993
ENV LIBGUESTFS_PACKAGE_URL=https://archive.archlinux.org/packages/l/libguestfs/libguestfs-1.44.1-6-x86_64.pkg.tar.zst
22094

221-
# fix ad hoc errors from using the arch museum to get libguestfs
222-
RUN sudo sed -i -e 's/^\#RemoteFileSigLevel/RemoteFileSigLevel/g' /etc/pacman.conf
223-
22495
RUN sudo pacman -Syy \
22596
&& sudo pacman -Rns linux --noconfirm \
22697
; sudo pacman -S mkinitcpio --noconfirm \
227-
&& sudo pacman -U "${KERNEL_PACKAGE_URL}" --noconfirm || exit 1 \
228-
&& sudo pacman -U "${LIBGUESTFS_PACKAGE_URL}" --noconfirm || exit 1 \
98+
&& sudo pacman -U "${KERNEL_PACKAGE_URL}" --noconfirm \
99+
&& sudo pacman -U "${LIBGUESTFS_PACKAGE_URL}" --noconfirm \
229100
&& rm -rf /var/tmp/.guestfs-* \
230-
&& yes | sudo pacman -Scc \
231-
&& libguestfs-test-tool || exit 1 \
232-
&& rm -rf /var/tmp/.guestfs-*
101+
; libguestfs-test-tool || exit 1
233102

234103
####
235104

236-
# These are hardcoded serials for non-iMessage related research
237-
# Overwritten by using GENERATE_UNIQUE=true
238-
# Upstream removed nopicker, so we are adding it back in, at build time
239-
# Once again, this is just for the Docker build so there is a default nopicker image there
240-
241-
# libguestfs verbose
242-
ENV LIBGUESTFS_DEBUG=1
243-
ENV LIBGUESTFS_TRACE=1
244-
245-
ARG STOCK_DEVICE_MODEL=iMacPro1,1
246-
ARG STOCK_SERIAL=C02TM2ZBHX87
247-
ARG STOCK_BOARD_SERIAL=C02717306J9JG361M
248-
ARG STOCK_UUID=007076A6-F2A2-4461-BBE5-BAD019F8025A
249-
ARG STOCK_MAC_ADDRESS=00:0A:27:00:00:00
250-
ARG STOCK_WIDTH=1920
251-
ARG STOCK_HEIGHT=1080
252-
ARG STOCK_MASTER_PLIST_URL=https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist
253-
ARG STOCK_MASTER_PLIST_URL_NOPICKER=https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-nopicker-custom.plist
254-
ARG STOCK_BOOTDISK=/home/arch/OSX-KVM/OpenCore/OpenCore.qcow2
255-
ARG STOCK_BOOTDISK_NOPICKER=/home/arch/OSX-KVM/OpenCore/OpenCore-nopicker.qcow2
256-
257-
RUN ./Docker-OSX/osx-serial-generator/generate-specific-bootdisk.sh \
258-
--master-plist-url="${STOCK_MASTER_PLIST_URL}" \
259-
--model "${STOCK_DEVICE_MODEL}" \
260-
--serial "${STOCK_SERIAL}" \
261-
--board-serial "${STOCK_BOARD_SERIAL}" \
262-
--uuid "${STOCK_UUID}" \
263-
--mac-address "${STOCK_MAC_ADDRESS}" \
264-
--width "${STOCK_WIDTH}" \
265-
--height "${STOCK_HEIGHT}" \
266-
--output-bootdisk "${STOCK_BOOTDISK}" || exit 1 \
267-
; rm -rf /var/tmp/.guestfs-*
268-
269-
RUN ./Docker-OSX/osx-serial-generator/generate-specific-bootdisk.sh \
270-
--master-plist-url="${STOCK_MASTER_PLIST_URL_NOPICKER}" \
271-
--model "${STOCK_DEVICE_MODEL}" \
272-
--serial "${STOCK_SERIAL}" \
273-
--board-serial "${STOCK_BOARD_SERIAL}" \
274-
--uuid "${STOCK_UUID}" \
275-
--mac-address "${STOCK_MAC_ADDRESS}" \
276-
--width "${STOCK_WIDTH}" \
277-
--height "${STOCK_HEIGHT}" \
278-
--output-bootdisk "${STOCK_BOOTDISK_NOPICKER}" || exit 1 \
279-
; rm -rf /var/tmp/.guestfs-*
280-
281105

282106
WORKDIR /home/arch/OSX-KVM
283107

@@ -291,32 +115,29 @@ RUN mkdir -p ~/.ssh \
291115
&& tee -a ~/.ssh/config <<< ' StrictHostKeyChecking no' \
292116
&& tee -a ~/.ssh/config <<< ' UserKnownHostsFile=/dev/null'
293117

294-
### symlink the old directory as upstream has renamed a directory. Symlinking purely for backwards compatability!
118+
####
119+
120+
# symlink the old directory, for redundancy
295121
RUN ln -s /home/arch/OSX-KVM/OpenCore /home/arch/OSX-KVM/OpenCore-Catalina || true
122+
296123
####
297124

298125
#### SPECIAL RUNTIME ARGUMENTS BELOW
299-
# env -e ADDITIONAL_PORTS with a comma
300-
# for example, -e ADDITIONAL_PORTS=hostfwd=tcp::23-:23,
301-
ENV ADDITIONAL_PORTS=
302126

303-
# since the Makefile uses raw, and raw uses the full disk amount
304-
# we want to use a compressed qcow2
305-
# ENV BASESYSTEM_FORMAT=raw
306-
ENV BASESYSTEM_FORMAT=qcow2
127+
ENV ADDITIONAL_PORTS=
307128

308129
# add additional QEMU boot arguments
309130
ENV BOOT_ARGS=
310131

311132
ENV BOOTDISK=
312133

313-
# edit the CPU that is being emulated
134+
# edit the CPU that is beign emulated
314135
ENV CPU=Penryn
315-
ENV CPUID_FLAGS='vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check,'
316136

317-
ENV DISPLAY=:0.0
137+
ENV DISPLAY=:99
138+
139+
ENV HEADLESS=false
318140

319-
# Deprecated
320141
ENV ENV=/env
321142

322143
# Boolean for generating a bootdisk with new random serials.
@@ -335,11 +156,10 @@ ENV KVM='accel=kvm:tcg'
335156
# ENV NETWORKING=e1000-82545em
336157
ENV NETWORKING=vmxnet3
337158

338-
# boolean for skipping the disk selection menu at in the boot process
339-
ENV NOPICKER=false
159+
ENV NOPICKER=true
340160

341161
# dynamic RAM options for runtime
342-
ENV RAM=4
162+
ENV RAM=3
343163
# ENV RAM=max
344164
# ENV RAM=half
345165

@@ -348,26 +168,9 @@ ENV RAM=4
348168
ENV WIDTH=1920
349169
ENV HEIGHT=1080
350170

351-
VOLUME ["/tmp/.X11-unix"]
352-
353-
# check if /image is a disk image or a directory. This allows you to optionally use -v disk.img:/image
354-
# NOPICKER is used to skip the disk selection screen
355-
# GENERATE_UNIQUE is used to generate serial numbers on boot.
356-
# /env is a file that you can generate and save using -v source.sh:/env
357-
# the env file is a file that you can carry to the next container which will supply the serials numbers.
358-
# GENERATE_SPECIFIC is used to either accept the env serial numbers OR you can supply using:
359-
# -e DEVICE_MODEL="iMacPro1,1" \
360-
# -e SERIAL="C02TW0WAHX87" \
361-
# -e BOARD_SERIAL="C027251024NJG36UE" \
362-
# -e UUID="5CCB366D-9118-4C61-A00A-E5BAF3BED451" \
363-
# -e MAC_ADDRESS="A8:5C:2C:9A:46:2F" \
364-
365-
# the output will be /bootdisk.
366-
# /bootdisk is a useful persistent place to store the 15Mb serial number bootdisk.
367-
368-
# if you don't set any of the above:
369-
# the default serial numbers are already contained in ./OpenCore/OpenCore.qcow2
370-
# And the default serial numbers
171+
# libguestfs verbose
172+
ENV LIBGUESTFS_DEBUG=1
173+
ENV LIBGUESTFS_TRACE=1
371174

372175
CMD sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" 2>/dev/null || true \
373176
; sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" 2>/dev/null || true \

0 commit comments

Comments
 (0)