├── .gitignore ├── .dockerignore ├── runtime-assets └── usr │ └── local │ └── bin │ ├── lite-entrypoint.sh │ ├── darling-setup.sh │ └── entrypoint.sh ├── LICENSE ├── .circleci └── config.yml ├── README.md ├── Makefile └── Dockerfile /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | out 3 | temp 4 | apps 5 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .gitignore 3 | .travis.yml 4 | README.md 5 | LICENSE 6 | hooks 7 | Dockerfile 8 | Makefile 9 | -------------------------------------------------------------------------------- /runtime-assets/usr/local/bin/lite-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Prepare for OverlayFS 4 | echo "Preparing OverlayFS" 5 | sudo mount -t tmpfs tmpfs /home/darling 6 | echo "Executing $@" 7 | exec sudo "$@" 8 | -------------------------------------------------------------------------------- /runtime-assets/usr/local/bin/darling-setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copy in osxcross macports 3 | 4 | # cp -rv /Volumes/SystemRoot/osxcross/target/macports/pkgs/opt/local/lib /usr/local/lib 5 | # cp -rv /Volumes/SystemRoot/osxcross/target/macports/pkgs/opt/local/libexec /usr/local/libexec 6 | -------------------------------------------------------------------------------- /runtime-assets/usr/local/bin/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # setuid root on darling binary 4 | sudo chmod 4755 /usr/local/bin/darling 5 | 6 | # Setup kernel module paths 7 | sudo mkdir -p /lib/modules/"$(uname -r)" 8 | sudo ln -s /usr/src/linux-headers-"$(uname -r)" /lib/modules/"$(uname -r)"/build 9 | 10 | # Build kernel module 11 | cd /usr/local/src/darling/build || exit 1 12 | sudo make lkm -j"$(nproc)" 13 | sudo make lkm_install 14 | sudo xz -d /lib/modules/"$(uname -r)"/extra/darling-mach.ko.xz 15 | 16 | # Try to unload any existing darling modules 17 | sudo rmmod darling-mach.ko 18 | 19 | # Load new module 20 | sudo insmod /lib/modules/"$(uname -r)"/extra/darling-mach.ko 21 | 22 | # Work around existing overlayfs 23 | sudo mount -t tmpfs tmpfs /home/darling 24 | 25 | # Setup darling env 26 | darling shell < /usr/local/bin/darling-setup.sh 27 | 28 | if [ $# -eq 0 ]; then 29 | echo "No command was given to run, exiting." 30 | exit 1 31 | else 32 | # Ensure we don't get left in wrong directory after module build 33 | cd /home/darling || exit 1 34 | exec "$@" 35 | fi 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Utensils Union 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | docker: 5 | - image: docker:stable-git 6 | steps: 7 | - checkout 8 | - setup_remote_docker 9 | - run: 10 | name: Install build dependencies 11 | command: | 12 | apk add --no-cache \ 13 | bash \ 14 | curl \ 15 | git \ 16 | jq \ 17 | make 18 | - run: 19 | name: Pull cache images 20 | command: | 21 | docker pull utensils/darling:builder || exit 0 22 | docker pull utensils/darling:latest || exit 0 23 | - run: 24 | name: Make And Push Build image for cache re-use 25 | command: | 26 | make builder 27 | make push-builder 28 | - run: 29 | name: Make Runtime Image 30 | command: | 31 | make 32 | - run: 33 | name: List Docker Images 34 | command: | 35 | make list 36 | - run: 37 | name: Push Docker Runtime Image 38 | command: | 39 | make push 40 | make push-readme 41 | - run: 42 | name: Update MicroBadger 43 | command: | 44 | make update-micro-badge -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker darling 2 | 3 | [![CircleCI](https://circleci.com/gh/utensils/docker-darling.svg?style=svg)](https://circleci.com/gh/utensils/docker-darling) [![Docker Pulls](https://img.shields.io/docker/pulls/utensils/darling.svg)](https://hub.docker.com/r/utensils/darling/) [![Docker Stars](https://img.shields.io/docker/stars/utensils/darling.svg)](https://hub.docker.com/r/utensils/darling/) [![](https://images.microbadger.com/badges/image/utensils/darling.svg)](https://microbadger.com/images/utensils/darling "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/version/utensils/darling.svg)](https://microbadger.com/images/utensils/darling "Get your own version badge on microbadger.com") 4 | 5 | ## About 6 | 7 | This is a containerized version of Darling (macOS translation layer). This is an experimental project with the goal to eventually cross compile both iOS and macOS projects in a docker container. I have had some limited success with macOS application builds. 8 | 9 | Darling actually uses it's own container system, so running with Docker is a bit redundant, but I would be interested to see it work more gracefully with docker in the future. 10 | 11 | **Pull Requests are always welcome!** 12 | 13 | ## Building 14 | 15 | This image is fairly heavy to build and can take a few hours depending on your system. The resulting image is about **1.5GB** uncompressed. 16 | The build is driven by a `Makefile` so simply run the following: 17 | 18 | ```shell 19 | make 20 | ``` 21 | 22 | If you look at the Makefile you will see a variable for `DARLING_GIT_REF` which is used to build the image against a known working git ref since there seems to be no versioning or tagging going on with Darling. This variable is nothing more than a build arg passed to docker so you can build the most recent commit: 23 | 24 | ```shell 25 | DARLING_GIT_REF=master make 26 | ``` 27 | or you can build from a specific commit: 28 | ```shell 29 | DARLING_GIT_REF=a00051b580c45b002690422819e9e2ce486f257e make 30 | ``` 31 | 32 | ## Usage 33 | 34 | Ensure you have kernel sources installed on your host, this is needed to build the darling 35 | kernel module against the running system on container startup. We run the container in **privileged** mode and inject the module into the host`s kernel. 36 | 37 | We use a volume mount of your host systems kernel sources (read only) so the kernel module can be built on container startup, this is just an attempt to keep the image somewhat portable. 38 | 39 | For Manjaro/Arch Linux Hosts run: 40 | 41 | ```shell 42 | docker run -i -t \ 43 | -v /lib/modules/"$(uname -r)"/build:/lib/modules/"$(uname -r)"/build:ro \ 44 | --privileged utensils/darling darling shell 45 | ``` 46 | 47 | For Ubuntu/Debian Hosts run: 48 | 49 | ```shell 50 | docker run -i -t \ 51 | -v /usr/src:/usr/src:ro \ 52 | --privileged utensils/darling darling shell 53 | ``` 54 | 55 | ## License 56 | 57 | This docker build project is licensed [MIT](LICENSE). 58 | Darling is GNU v3, other included assets all have their own licensing. 59 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | SHELL := /usr/bin/env bash 4 | REPO_NAMESPACE ?= utensils 5 | REPO_USERNAME ?= jamesbrink 6 | REPO_API_URL ?= https://hub.docker.com/v2 7 | IMAGE_NAME ?= darling 8 | BASE_IMAGE ?= ubuntu:18.04 9 | DARLING_GIT_REF ?= a00051b580c45b002690422819e9e2ce486f257e 10 | VERSION := $(shell git describe --tags --abbrev=0 2>/dev/null || git rev-parse --abbrev-ref HEAD 2>/dev/null) 11 | VCS_REF := $(shell git rev-parse --short HEAD 2>/dev/null || echo "0000000") 12 | BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") 13 | 14 | # Default target is to build container 15 | .PHONY: default 16 | default: build 17 | 18 | # Build the builder image for cache purposes 19 | .PHONY: builder 20 | builder: 21 | docker build \ 22 | --build-arg BASE_IMAGE=$(BASE_IMAGE) \ 23 | --build-arg BUILD_DATE=$(BUILD_DATE) \ 24 | --build-arg DARLING_GIT_REF=$(DARLING_GIT_REF) \ 25 | --build-arg VCS_REF=$(VCS_REF) \ 26 | --build-arg VERSION=$(VERSION) \ 27 | --tag $(REPO_NAMESPACE)/$(IMAGE_NAME):builder \ 28 | --target builder \ 29 | --cache-from $(REPO_NAMESPACE)/$(IMAGE_NAME):builder \ 30 | --file Dockerfile . 31 | 32 | # Build the runtime docker image 33 | .PHONY: build 34 | build: 35 | docker build \ 36 | --build-arg BASE_IMAGE=$(BASE_IMAGE) \ 37 | --build-arg BUILD_DATE=$(BUILD_DATE) \ 38 | --build-arg DARLING_GIT_REF=$(DARLING_GIT_REF) \ 39 | --build-arg VCS_REF=$(VCS_REF) \ 40 | --build-arg VERSION=$(VERSION) \ 41 | --tag $(REPO_NAMESPACE)/$(IMAGE_NAME):latest \ 42 | --tag $(REPO_NAMESPACE)/$(IMAGE_NAME):$(VCS_REF) \ 43 | --tag $(REPO_NAMESPACE)/$(IMAGE_NAME):$(VERSION) \ 44 | --cache-from $(REPO_NAMESPACE)/$(IMAGE_NAME):builder \ 45 | --cache-from $(REPO_NAMESPACE)/$(IMAGE_NAME):latest \ 46 | --file Dockerfile . 47 | 48 | # List built images 49 | .PHONY: list 50 | list: 51 | docker images $(REPO_NAMESPACE)/$(IMAGE_NAME) --filter "dangling=false" 52 | 53 | # Run any tests 54 | .PHONY: test 55 | test: 56 | docker run -t $(REPO_NAMESPACE)/$(IMAGE_NAME) env | grep VERSION | grep $(VERSION) 57 | 58 | # Push images to repo 59 | .PHONY: push 60 | push: 61 | echo "$$REPO_PASSWORD" | docker login -u "$(REPO_USERNAME)" --password-stdin; \ 62 | docker push $(REPO_NAMESPACE)/$(IMAGE_NAME):latest; \ 63 | docker push $(REPO_NAMESPACE)/$(IMAGE_NAME):$(VCS_REF); \ 64 | docker push $(REPO_NAMESPACE)/$(IMAGE_NAME):$(VERSION); 65 | 66 | # Push builder image for cache purposes 67 | .PHONY: push-builder 68 | push-builder: 69 | echo "$$REPO_PASSWORD" | docker login -u "$(REPO_USERNAME)" --password-stdin; \ 70 | docker push $(REPO_NAMESPACE)/$(IMAGE_NAME):builder; 71 | 72 | # Update README on registry 73 | .PHONY: push-readme 74 | push-readme: 75 | echo "Authenticating to $(REPO_API_URL)"; \ 76 | token=$$(curl -s -X POST -H "Content-Type: application/json" -d '{"username": "$(REPO_USERNAME)", "password": "'"$$REPO_PASSWORD"'"}' $(REPO_API_URL)/users/login/ | jq -r .token); \ 77 | code=$$(jq -n --arg description "$$(> /etc/sudoers; 116 | 117 | # Copy our Darling build from previous stage 118 | COPY --from=builder /usr/local /usr/local 119 | 120 | # Labels / Metadata. 121 | ARG BUILD_DATE 122 | ARG DARLING_GIT_REF 123 | ARG VCS_REF 124 | ARG VERSION 125 | LABEL \ 126 | org.opencontainers.image.authors="James Brink " \ 127 | org.opencontainers.image.created="${BUILD_DATE}" \ 128 | org.opencontainers.image.description="Darling ($VERSION)" \ 129 | org.opencontainers.image.revision="${VCS_REF}" \ 130 | org.opencontainers.image.source="https://github.com/utensils/docker-darling.git" \ 131 | org.opencontainers.image.title="darling (lite)" \ 132 | org.opencontainers.image.vendor="Utensils" \ 133 | org.opencontainers.image.version="git - ${DARLING_GIT_REF}" 134 | 135 | # Setup our environment variables. 136 | ENV PATH="/usr/local/bin:$PATH" 137 | 138 | # Drop down to our unprivileged user. 139 | USER darling 140 | 141 | # Set our working directory. 142 | WORKDIR /home/darling 143 | 144 | # Set the entrypoint. 145 | ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] 146 | 147 | # Set the default command 148 | CMD ["/usr/local/bin/darling", "shell"] 149 | --------------------------------------------------------------------------------