Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSX Daytona workspace #1338

Open
Tpuljak opened this issue Nov 14, 2024 · 90 comments
Open

OSX Daytona workspace #1338

Tpuljak opened this issue Nov 14, 2024 · 90 comments
Labels
enhancement New feature or request ⚔️ Quest Tracks quest-bot quests

Comments

@Tpuljak
Copy link
Member

Tpuljak commented Nov 14, 2024

Describe the solution you'd like
We should explore the possibility of running OSX images with Daytona to allow users to create workspaces in an OSX environment. This feature might enable additional native development workflows that can not be ran on Linux.
We should look into https://github.com/sickcodes/Docker-OSX as possible images to use.

Additional context
We should first discuss the approach here and outline the necessary changes, if any, needed to make this happen.

@Tpuljak Tpuljak added the enhancement New feature or request label Nov 14, 2024
@quest-bot quest-bot bot added the ⚔️ Quest Tracks quest-bot quests label Nov 14, 2024
Copy link

quest-bot bot commented Nov 14, 2024

New Quest! image New Quest!

A new Quest has been launched in @daytonaio’s repo.
Merge a PR that solves this issue to loot the Quest and earn your reward.


Loot of 500 USD has been stashed in this issue to reward the solver!

🗡 Comment @quest-bot embark to check-in for this Quest and start solving the issue. Other solvers will be notified!

⚔️ When you submit a PR, comment @quest-bot loot #1338 to link your PR to this Quest.

Questions? Check out the docs.


👉 If no one is assigned to the issue, you are welcome to embark on the quest and tackle it without confirmation from us. In the event that multiple PRs are made from different people, we will generally accept those with the cleanest code.

@unsuman
Copy link
Contributor

unsuman commented Nov 15, 2024

I was attempting to pull the sickcodes/docker-osx:latest image to set up a local environment and experiment, but it seems there's an issue related to Apple:
The link is broken.
Screenshot 2024-11-15 at 2 41 28 PM

But there is a backup account on dockerhub. Do you think I should try this or what are your thoughts?

@Tpuljak
Copy link
Member Author

Tpuljak commented Nov 15, 2024

But there is a backup account on dockerhub. Do you think I should try this or what are your thoughts?

Reading through sickcodes/Docker-OSX#799, it seems the DCMA issues should be resolved. From what I can see, you should be able to use the backup.

@unsuman
Copy link
Contributor

unsuman commented Nov 15, 2024

Ok so finally I'm able to run MacOS Ventura on a container(it's just a VM on qemu using KVM launched in a docker container). The GUI is slow because it doesn't support GPU acceleration but I found that we can also run it without a GUI using Telnet or through this

So to build a headless(without GUI) OSX container we need to set things up to use VNC so as to do the disk partitioning and installation but after that we can interact with entirely via SSH. This guide also reflects the above statment.
Let me know what should be the user flow and my next steps?
image

@unsuman
Copy link
Contributor

unsuman commented Nov 18, 2024

Also tried dockur's OSX image, it seems to be fast and consumes less storage. It exposes a web U.I. of the macOS so no need for VNC!

@unsuman
Copy link
Contributor

unsuman commented Nov 18, 2024

The URL is back up now https://hub.docker.com/r/sickcodes/docker-osx/. Now it's DMCA-proof!

@Tpuljak
Copy link
Member Author

Tpuljak commented Nov 19, 2024

@unsuman looks nice. 🚀

For the next step, please create an example public repo (on your github account) where you can add a devcontainer config that will spawn an OSX container. Looking at the instructions, you should be able to achieve this with the runArgs devcontainer property.

Then try to run daytona create REPO_URL. Just make sure to build the daytona binary for OSX beforehand. You can do that by running make build OS=darwin in the root of this repo.

@unsuman
Copy link
Contributor

unsuman commented Nov 19, 2024

Ok! I did what you said. I created this repo and it seems that the dockurr/macos working correctly but got this at the end:
Screenshot from 2024-11-19 15-03-05

I'm unsure about how to do this.

Just make sure to build the daytona binary for OSX beforehand. You can do that by running make build OS=darwin in the root of this repo.

Can you please elaborate? I'm building and using daytona on a devcontainer and in the container I ran make build OS=darwin and then dtn create https://github.com/unsuman/test-osx-dtn:

daytona ➜ /workspaces/daytona (main) $ dtn create https://github.com/unsuman/test-osx-dtn
 WORKSPACE    | ✓ Request submitted
 WORKSPACE    | ✓ Creating workspace test-osx-dtn (328b27dcab34)
 test-osx-dtn | Creating project test-osx-dtn
 test-osx-dtn | Pulling image...
 test-osx-dtn | Pulling from daytonaio/workspace-project
 test-osx-dtn | Digest: sha256:adf39125cf348f8801b8e1d9be37d0693eade0602344b42908433b5c9be1c7ad
 test-osx-dtn | Status: Image is up to date for daytonaio/workspace-project:latest
 test-osx-dtn | Image pulled successfully
 test-osx-dtn | UIDs and GIDs are the same (1000:1000).
 test-osx-dtn | Cloning into '/workdir/328b27dcab34-test-osx-dtn'...
 test-osx-dtn | Pulling image...
 test-osx-dtn | Pulling from alpine/socat
 test-osx-dtn | Already exists 
 test-osx-dtn | Pull complete 
 test-osx-dtn | Digest: sha256:8e99954298d5514fae107ec01f65add1e783c33f56cd468d68b1dc65eb1ab003
 test-osx-dtn | Status: Downloaded newer image for alpine/socat:latest
 test-osx-dtn | Image pulled successfully
 test-osx-dtn | Reading devcontainer configuration...
 test-osx-dtn | [1 ms] @devcontainers/cli 0.71.0. Node.js v20.17.0. linux 6.11.5-200.fc40.x86_64 x64.
 test-osx-dtn | [3524 ms] Start: Run: docker run --sig-proxy=false -a STDOUT -a STDERR --mount source=/home/daytona/.config/daytona-dev/providers/docker-provider/328b27dcab34/328b27dcab34-test-osx-dtn,target=/workspaces/test-osx-dtn,type=bind -l daytona.workspace.id=328b27dcab34 -l daytona.project.name=test-osx-dtn -e DAYTONA_AGENT_LOG_FILE_PATH=(HOME)/.daytona-agent.log -e DAYTONA_CLIENT_ID=d1278b61-7e81-4a6c-94b3-755255da91b2 -e DAYTONA_PROJECT_DIR=/workspaces/test-osx-dtn -e DAYTONA_SERVER_API_KEY=YzRmMTgxN2EtMDI3NS00OGRkLTg3YjMtYjEwMGRjZjM4MTc5 -e DAYTONA_SERVER_API_URL=https://api-de733783-9e9f-4a19-a7d9-bb64161cc8b6.try-eu.daytona.app -e DAYTONA_SERVER_URL=https://de733783-9e9f-4a19-a7d9-bb64161cc8b6.try-eu.daytona.app -e DAYTONA_SERVER_VERSION=v0.0.0-dev -e DAYTONA_TELEMETRY_ENABLED=true -e DAYTONA_WS_ID=328b27dcab34 -e DAYTONA_WS_PROJECT_NAME=test-osx-dtn -e DAYTONA_WS_PROJECT_REPOSITORY_URL=https://github.com/unsuman/test-osx-dtn.git --rm -p 8006:8006 --device=/dev/kvm --cap-add=NET_ADMIN --stop-timeout 120 --entrypoint /bin/sh -l devcontainer.metadata=[{"containerEnv":{"DAYTONA_AGENT_LOG_FILE_PATH":"(HOME)/.daytona-agent.log","DAYTONA_CLIENT_ID":"d1278b61-7e81-4a6c-94b3-755255da91b2","DAYTONA_PROJECT_DIR":"/workspaces/test-osx-dtn","DAYTONA_SERVER_API_KEY":"YzRmMTgxN2EtMDI3NS00OGRkLTg3YjMtYjEwMGRjZjM4MTc5","DAYTONA_SERVER_API_URL":"https://api-de733783-9e9f-4a19-a7d9-bb64161cc8b6.try-eu.daytona.app","DAYTONA_SERVER_URL":"https://de733783-9e9f-4a19-a7d9-bb64161cc8b6.try-eu.daytona.app","DAYTONA_SERVER_VERSION":"v0.0.0-dev","DAYTONA_TELEMETRY_ENABLED":"true","DAYTONA_WS_ID":"328b27dcab34","DAYTONA_WS_PROJECT_NAME":"test-osx-dtn","DAYTONA_WS_PROJECT_REPOSITORY_URL":"https://github.com/unsuman/test-osx-dtn.git"}}] dockurr/macos -c echo Container started
 test-osx-dtn | Unable to find image 'dockurr/macos:latest' locally
 test-osx-dtn | latest: Pulling from dockurr/macos
                0285d69bcdbd: Pull complete 
                af6303568cc9: Pull complete 
                338d409b600b: Pull complete 
                428878222252: Pull complete 
                d5f1e3a79f9a: Pull complete 
                c287bff0861d: Pull complete 
                cc3847659ea6: Pull complete 
 test-osx-dtn | Digest: sha256:d681d6ef09ee49e0caa1a87b59b790a9f24f0fc6521ca6a826064522ed4a768b
 test-osx-dtn | Status: Downloaded newer image for dockurr/macos:latest
 test-osx-dtn | {"outcome":"success","containerId":"b3f39bec79db1e59c437cef0633fc3dd75350cf9d64286fb3e12db0ff719500c","remoteUser":"root","remoteWorkspaceFolder":"/workspaces/test-osx-dtn"}
 test-osx-dtn | Project test-osx-dtn created
 WORKSPACE    | ✓ Workspace creation complete. Pending start...
 WORKSPACE    | ✓ Starting workspace
 test-osx-dtn | Starting project test-osx-dtn
 test-osx-dtn | Reading devcontainer configuration...
 test-osx-dtn | Running devcontainer user commands...
 test-osx-dtn | [30 ms] @devcontainers/cli 0.71.0. Node.js v20.17.0. linux 6.11.5-200.fc40.x86_64 x64.
 test-osx-dtn | {"outcome":"success","result":"done"}
 test-osx-dtn | [1 ms] @devcontainers/cli 0.71.0. Node.js v20.17.0. linux 6.11.5-200.fc40.x86_64 x64.
 test-osx-dtn | {"outcome":"success","containerId":"b3f39bec79db1e59c437cef0633fc3dd75350cf9d64286fb3e12db0ff719500c","remoteUser":"root","remoteWorkspaceFolder":"/workspaces/test-osx-dtn"}
 test-osx-dtn | bash: line 1: curl: command not found
 test-osx-dtn | bash: line 1: sudo: command not found
FATA[0082] failed to create workspace: bash: line 1: curl: command not found
bash: line 1: sudo: command not found 
exit status 1

@Tpuljak
Copy link
Member Author

Tpuljak commented Nov 19, 2024

Can you please elaborate? I'm building and using daytona on a devcontainer and in the container I ran make build OS=darwin and then dtn create https://github.com/unsuman/test-osx-dtn:

That should be okay. First of all, the make command should rather be: make build OS=darwin DAYTONA_CONFIG_DIR=/home/daytona/.config/daytona-dev If you're working in our devcontainer. This command builds the daytona binary for darwin and moves it to the appropriate folder that the server can then serve to the project containers.

test-osx-dtn | bash: line 1: curl: command not found
test-osx-dtn | bash: line 1: sudo: command not found
FATA[0082] failed to create workspace: bash: line 1: curl: command not found

Regarding this. This also happens even if you installed sudo and curl inside the container image?

@Tpuljak
Copy link
Member Author

Tpuljak commented Nov 19, 2024

Please also make sure to include the remoteUser property in the devcontainer definition. I'm not sure which user should be used for that macos image so look that up.

@divanshu-go

This comment was marked as abuse.

@unsuman
Copy link
Contributor

unsuman commented Nov 19, 2024

Can you please elaborate? I'm building and using daytona on a devcontainer and in the container I ran make build OS=darwin and then dtn create https://github.com/unsuman/test-osx-dtn:

That should be okay. First of all, the make command should rather be: make build OS=darwin DAYTONA_CONFIG_DIR=/home/daytona/.config/daytona-dev If you're working in our devcontainer. This command builds the daytona binary for darwin and moves it to the appropriate folder that the server can then serve to the project containers.

test-osx-dtn | bash: line 1: curl: command not found
test-osx-dtn | bash: line 1: sudo: command not found
FATA[0082] failed to create workspace: bash: line 1: curl: command not found

Regarding this. This also happens even if you installed sudo and curl inside the container image?

Yeah figured it out and it worked! Thanks!

➜  daytona git:(main) ./build/daytona create
 WORKSPACE    | ✓ Request submitted
 WORKSPACE    | ✓ Creating workspace test-osx-dtn (27b562677ce0)
 test-osx-dtn | Creating project test-osx-dtn
 test-osx-dtn | Pulling image...
 test-osx-dtn | Pulling from daytonaio/workspace-project
 test-osx-dtn | Already exists 
 test-osx-dtn | Pull complete 
 test-osx-dtn | Pull complete 
 test-osx-dtn | Pull complete 
 test-osx-dtn | Pull complete 
 test-osx-dtn | Pull complete 
 test-osx-dtn | Pull complete 
 test-osx-dtn | Pull complete 
 test-osx-dtn | Pull complete 
 test-osx-dtn | Pull complete 
 test-osx-dtn | Pull complete 
 test-osx-dtn | Pull complete 
 test-osx-dtn | Pull complete 
 test-osx-dtn | Pull complete 
 test-osx-dtn | Pull complete 
 test-osx-dtn | Pull complete 
 test-osx-dtn | Pull complete 
 test-osx-dtn | Pull complete 
 test-osx-dtn | Digest: sha256:adf39125cf348f8801b8e1d9be37d0693eade0602344b42908433b5c9be1c7ad
 test-osx-dtn | Status: Downloaded newer image for daytonaio/workspace-project:latest
 test-osx-dtn | Image pulled successfully
 test-osx-dtn | UIDs and GIDs are the same (1000:1000).
 test-osx-dtn | Cloning into '/workdir/27b562677ce0-test-osx-dtn'...
 test-osx-dtn | Pulling image...
 test-osx-dtn | Pulling from alpine/socat
 test-osx-dtn | Pull complete 
 test-osx-dtn | Pull complete 
 test-osx-dtn | Digest: sha256:8e99954298d5514fae107ec01f65add1e783c33f56cd468d68b1dc65eb1ab003
 test-osx-dtn | Status: Downloaded newer image for alpine/socat:latest
 test-osx-dtn | Image pulled successfully
 test-osx-dtn | Reading devcontainer configuration...
 test-osx-dtn | [1 ms] @devcontainers/cli 0.71.0. Node.js v20.17.0. linux 6.11.5-200.fc40.x86_64 x64.
 test-osx-dtn | [3473 ms] Start: Run: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-daytona/container-features/0.71.0-1732012890759/Dockerfile-with-features -t vsc-27b562677ce0-test-osx-dtn-fc8ef59cf6064231d27ac11240ce2e19c1d17163acc74893f14c958154f33732 --target dev_containers_target_stage --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label /project/27b562677ce0-test-osx-dtn/.devcontainer
 test-osx-dtn | [+] Building 63.7s (6/6) FINISHED                                docker:default
 test-osx-dtn |  => [internal] load build definition from Dockerfile-with-features         1.3s
 test-osx-dtn |  => => transferring dockerfile: 1.11kB                                     0.0s
 test-osx-dtn |  => [internal] load metadata for docker.io/dockurr/macos:latest            3.2s
 test-osx-dtn |  => [internal] load .dockerignore                                          1.3s
 test-osx-dtn |  => => transferring context: 2B                                            0.0s
 test-osx-dtn |  => [dev_container_auto_added_stage_label 1/2] FROM docker.io/dockurr/ma  24.4s
 test-osx-dtn |  => => resolve docker.io/dockurr/macos:latest@sha256:d681d6ef09ee49e0caa1  0.6s
 test-osx-dtn |  => => sha256:d681d6ef09ee49e0caa1a87b59b790a9f24f0fc6521 2.24kB / 2.24kB  0.0s
 test-osx-dtn |  => => sha256:71815c28454c9cbb2bd96fb1b81460fc5e4973a29cc 5.70kB / 5.70kB  0.0s
 test-osx-dtn |  => => sha256:338d409b600be0b06f0159742b6b1240c66ea80fa 10.52kB / 10.52kB  0.6s
 test-osx-dtn |  => => sha256:0285d69bcdbdd9d46a06d454b5050df9a7a6ffcb 80.99MB / 80.99MB  11.8s
 test-osx-dtn |  => => sha256:af6303568cc9ce832333d2b0ce0847c1b80b7f825 14.93MB / 14.93MB  2.8s
 test-osx-dtn |  => => sha256:42887822225253cd6455ddf53681edc6fa560bf566f 5.82kB / 5.82kB  1.5s
 test-osx-dtn |  => => sha256:d5f1e3a79f9a6ba7d41a34cb1feab10bcd61655d8 95.94kB / 95.94kB  2.2s
 test-osx-dtn |  => => sha256:c287bff0861da9200dbf719b512e74baa0a1431e154 1.55MB / 1.55MB  3.2s
 test-osx-dtn |  => => sha256:cc3847659ea68c3505e258450e4e649e6b1e70a49 12.24MB / 12.24MB  5.7s
 test-osx-dtn |  => => extracting sha256:0285d69bcdbdd9d46a06d454b5050df9a7a6ffcb300029cc  0.8s
 test-osx-dtn |  => => extracting sha256:af6303568cc9ce832333d2b0ce0847c1b80b7f8254d002ff  0.3s
 test-osx-dtn |  => => extracting sha256:338d409b600be0b06f0159742b6b1240c66ea80fa35c66c0  0.0s
 test-osx-dtn |  => => extracting sha256:42887822225253cd6455ddf53681edc6fa560bf566f1b28d  0.0s
 test-osx-dtn |  => => extracting sha256:d5f1e3a79f9a6ba7d41a34cb1feab10bcd61655d8dc82ad1  0.0s
 test-osx-dtn |  => => extracting sha256:c287bff0861da9200dbf719b512e74baa0a1431e15433248  0.1s
 test-osx-dtn |  => => extracting sha256:cc3847659ea68c3505e258450e4e649e6b1e70a498bef28a  0.2s
 test-osx-dtn |  => [dev_container_auto_added_stage_label 2/2] RUN apt-get update && apt  28.5s
 test-osx-dtn |  => exporting to image                                                     1.5s
 test-osx-dtn |  => => exporting layers                                                    1.0s
 test-osx-dtn |  => => preparing layers for inline cache                                   0.0s
 test-osx-dtn |  => => writing image sha256:ac6d4ae80f8148b30971da011d4519db62937845704c3  0.0s
 test-osx-dtn |  => => naming to docker.io/library/vsc-27b562677ce0-test-osx-dtn-fc8ef59c  0.1s
 test-osx-dtn | [68467 ms] Start: Run: docker run --sig-proxy=false -a STDOUT -a STDERR --mount source=/home/unsuman/.config/daytona/providers/docker-provider/27b562677ce0/27b562677ce0-test-osx-dtn,target=/workspaces/test-osx-dtn,type=bind -l daytona.workspace.id=27b562677ce0 -l daytona.project.name=test-osx-dtn -e DAYTONA_AGENT_LOG_FILE_PATH=(HOME)/.daytona-agent.log -e DAYTONA_CLIENT_ID=93264e56-774d-4fd6-8079-8f6133f60472 -e DAYTONA_PROJECT_DIR=/workspaces/test-osx-dtn -e DAYTONA_SERVER_API_KEY=MmViODdlN2UtZTI2My00ZTE5LThlNTItYjYzYjQwNjcyNDdi -e DAYTONA_SERVER_API_URL=https://api-e357a168-b135-4b36-b45d-82a97aaad931.try-eu.daytona.app -e DAYTONA_SERVER_URL=https://e357a168-b135-4b36-b45d-82a97aaad931.try-eu.daytona.app -e DAYTONA_SERVER_VERSION=v0.0.0-dev -e DAYTONA_TELEMETRY_ENABLED=true -e DAYTONA_WS_ID=27b562677ce0 -e DAYTONA_WS_PROJECT_NAME=test-osx-dtn -e DAYTONA_WS_PROJECT_REPOSITORY_URL=https://github.com/unsuman/test-osx-dtn.git --rm -p 9000:8006 --device=/dev/kvm --cap-add=NET_ADMIN --stop-timeout 120 --entrypoint /bin/sh vsc-27b562677ce0-test-osx-dtn-fc8ef59cf6064231d27ac11240ce2e19c1d17163acc74893f14c958154f33732 -c echo Container started
 test-osx-dtn | {"outcome":"success","containerId":"ca190b5325d455713428a6a438e472ad5c362ad448a30af77c84ca713b60ea02","remoteUser":"root","remoteWorkspaceFolder":"/workspaces/test-osx-dtn"}
 test-osx-dtn | Project test-osx-dtn created
 WORKSPACE    | ✓ Workspace creation complete. Pending start...
 WORKSPACE    | ✓ Starting workspace
 test-osx-dtn | Starting project test-osx-dtn
 test-osx-dtn | Reading devcontainer configuration...
 test-osx-dtn | Running devcontainer user commands...
 test-osx-dtn | [1 ms] @devcontainers/cli 0.71.0. Node.js v20.17.0. linux 6.11.5-200.fc40.x86_64 x64.
 test-osx-dtn | {"outcome":"success","result":"done"}
 test-osx-dtn | [1 ms] @devcontainers/cli 0.71.0. Node.js v20.17.0. linux 6.11.5-200.fc40.x86_64 x64.
 test-osx-dtn | {"outcome":"success","containerId":"ca190b5325d455713428a6a438e472ad5c362ad448a30af77c84ca713b60ea02","remoteUser":"root","remoteWorkspaceFolder":"/workspaces/test-osx-dtn"}
 test-osx-dtn | Downloading Daytona from https://api-e357a168-b135-4b36-b45d-82a97aaad931.try-eu.daytona.app/binary/v0.0.0-dev/daytona-linux-amd64
 test-osx-dtn | Project test-osx-dtn started
 WORKSPACE    | ✓ Workspace test-osx-dtn started
 test-osx-dtn | Container started
 test-osx-dtn | Daytona downloaded successfully
 test-osx-dtn | Installing server to /usr/local/bin
 test-osx-dtn | Starting Daytona Agent
 test-osx-dtn | Repository already exists. Skipping clone...
 test-osx-dtn | Starting ssh server on port 2222...

                                                                                                                      
   Workspace       test-osx-dtn                                                                                       
                                                                                                                      
   ID              27b562677ce0                                                                                       
                                                                                                                      
   Editor          Fleet                                                                                              
                                                                                                                      
   State           RUNNING                                                                                            
                                                                                                                      
   Branch          master           (branch not published)                                                            
                                                                                                                      
   Repository      github.com/unsuman/test-osx-dtn.git      

@unsuman
Copy link
Contributor

unsuman commented Nov 19, 2024

@unsuman I also faced this problem when working on dockurr/windows . This because the DockeFile they use to create a qemu instance has no packages such as git and sudo . Install command edit the docker file add these packages . Eg apt install sudo git -y

Yeah did the same, thanks @divanshu-go !

@Tpuljak
Copy link
Member Author

Tpuljak commented Nov 19, 2024

Yeah figured it out and it worked! Thanks!

Are you able to daytona ssh into the workspace now?

@unsuman
Copy link
Contributor

unsuman commented Nov 19, 2024

Yeah figured it out and it worked! Thanks!

Are you able to daytona ssh into the workspace now?

Yes!
image

@Tpuljak
Copy link
Member Author

Tpuljak commented Nov 19, 2024

Yes!

That's great! I'll try it out a bit later today and let you know how we should proceed.

@unsuman
Copy link
Contributor

unsuman commented Nov 19, 2024

@quest-bot embark

Copy link

quest-bot bot commented Nov 19, 2024

@unsuman has embarked on their Quest. 🗡

  • @unsuman has been on GitHub since 2021.
  • They have merged 35 public PRs in that time.
  • Their swords are blessed with Go and Makefile magic ✨
  • They have contributed to this repo before.

This is not an assignment to the issue. Please check the repo’s contribution guidelines before submitting a PR.

Questions? Check out the docs.

@Rutik7066
Copy link
Contributor

@quest-bot embark #1338

Copy link

quest-bot bot commented Nov 19, 2024

⚠️ Woops, I didn't get that...

Are you trying to embark?

Comment @quest-bot embark to begin work on this Quest.

Check the docs for more info.

@Rutik7066
Copy link
Contributor

@quest-bot embark

Copy link

quest-bot bot commented Nov 19, 2024

@Rutik7066 has embarked on their Quest. 🗡

  • @Rutik7066 has been on GitHub since 2019.
  • They have merged 12 public PRs in that time.
  • Their swords are blessed with Dockerfile and JavaScript magic ✨
  • They have contributed to this repo before.

This is not an assignment to the issue. Please check the repo’s contribution guidelines before submitting a PR.

Questions? Check out the docs.

@Tpuljak
Copy link
Member Author

Tpuljak commented Nov 20, 2024

So to build a headless(without GUI) OSX container we need to set things up to use VNC so as to do the disk partitioning and installation but after that we can interact with entirely via SSH. This guide also reflects the above statment.

@unsuman took a look and created a workspace with your example.

While it does work and I can connect to the workspace with Daytona, we're still inside a Linux environment.

For the next step, please do the following:

  1. Set up VNC so we can view the MacOS GUI by opening a URL in our browser. It would be great if the VNC port can be forwarded with daytona forward {PORT} inside the workspace so the VNC is available publicly.
  2. Try to figure out is it possible to mount the workspace folder (/workspaces/test-osx-dtn) inside the Mac VM. We want to be able to interact with the project on MacOS.

@unsuman
Copy link
Contributor

unsuman commented Nov 20, 2024

So to build a headless(without GUI) OSX container we need to set things up to use VNC so as to do the disk partitioning and installation but after that we can interact with entirely via SSH. This guide also reflects the above statment.

@unsuman took a look and created a workspace with your example.

While it does work and I can connect to the workspace with Daytona, we're still inside a Linux environment.

For the next step, please do the following:

  1. Set up VNC so we can view the MacOS GUI by opening a URL in our browser. It would be great if the VNC port can be forwarded with daytona forward {PORT} inside the workspace so the VNC is available publicly.
  2. Try to figure out is it possible to mount the workspace folder (/workspaces/test-osx-dtn) inside the Mac VM. We want to be able to interact with the project on MacOS.

@Tpuljak I will try to figure out these things! Meanwhile here's something I got from the SickCodes community:
We can basically configure a disk image(.img file) beforehand like disk partitioning, installing OSX, enabling SSH and even Xcode toolset in the image. Later, we just need to download that .img file and attach it with their docker command which will spin up a pre-configured OSX exposing ports so that we can use SSH to clone the repo on that OSX container. This will significantly reduce build time and enhance UX.
Let me know what are your views on this.
image
image

@Tpuljak
Copy link
Member Author

Tpuljak commented Nov 20, 2024

@Tpuljak I will try to figure out these things! Meanwhile here's something I got from the SickCodes community:
We can basically configure a disk image(.img file) beforehand like disk partitioning, installing OSX, enabling SSH and even Xcode toolset in the image. Later, we just need to download that .img file and attach it with their docker command which will spin up a pre-configured OSX exposing ports so that we can use SSH to clone the repo on that OSX container. This will significantly reduce build time and enhance UX.
Let me know what are your views on this.

@unsuman that sounds great! We're definitely up for improving the build time as long as it complies with DMCA. You can go in this direction and keep us updated.

@unsuman
Copy link
Contributor

unsuman commented Nov 20, 2024

@Tpuljak Here is the update so far:
I am able to ssh into Ventura and also find the .img file:
image
Screenshot from 2024-11-20 17-22-42

We can use this for directly running commands inside OS X. This can help us mount the workspace folder:

OR if you have an image already and just want to log in and execute arbitrary commands:

docker pull sickcodes/docker-osx:naked-auto

# boot to OS X shell + display + specify commands to run inside OS X!
docker run -it \
    --device /dev/kvm \
    -p 50922:10022 \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e "DISPLAY=${DISPLAY:-:0.0}" \
    -e USERNAME=yourusername \
    -e PASSWORD=yourpassword \
    -e "OSX_COMMANDS=/bin/bash -c \"put your commands here\"" \
    sickcodes/docker-osx:naked-auto

# Boots in a minute or two!

Now from here we can proceed with/without a GUI as per user preference. A possible use-case scenario for the GUI can be building/running an iOS App where GUI is needed. I guess we should proceed with Qemu rather than VNC for the GUI because it adds an layer of user input which cannot be automatic:

Building a headless container to run remotely with secure VNC

Add the following line:

-e EXTRA="-display none -vnc 0.0.0.0:99,password=on"

In the Docker terminal, press enter until you see (qemu).

Type change vnc password someusername

Enter a password for your new vnc username^.

You also need the container IP: docker inspect | jq -r '.[0].NetworkSettings.IPAddress'

Or ip n will usually show the container IP first.

Now VNC connects using the Docker container IP, for example 172.17.0.2:5999

Remote VNC over SSH: ssh -N [email protected] -L 5999:172.17.0.2:5999, where 1.1.1.1 is your remote server IP and 172.17.0.2 is your LAN container IP.

Now you can direct connect VNC to any container built with this command!

Source

@Tpuljak
Copy link
Member Author

Tpuljak commented Nov 20, 2024

@unsuman I see what you're getting at. The appeal for VNC for me was that it would work out of the box for remote workspaces as well. E.g. you create a workspace using the Azure provider and we have a VNC port forwarded, the user could easily view the UI. You can keep this use case in mind while doing the research.

@unsuman
Copy link
Contributor

unsuman commented Nov 21, 2024

I am able to set VNC which can be viewed using a VNC viewer(I'm using RealVNC) on localhost:5999(without a password) but how can we use this in our use case?

@Tpuljak
Copy link
Member Author

Tpuljak commented Nov 25, 2024

@Rutik7066 can you please update Daytona and all the providers to the latest version?

@Tpuljak
Copy link
Member Author

Tpuljak commented Nov 25, 2024

@unsuman would it be possible to mount the workspace folder into the osx image? Similarly to how X11 is mounted here.

@Rutik7066
Copy link
Contributor

Rutik7066 commented Nov 25, 2024

@Rutik7066 can you please update Daytona and all the providers to the latest version?

It is resolved now I think it may be because of wsl2. I was using it for development. Now I have switched to Ubuntu. Now it it working.

@Rutik7066
Copy link
Contributor

Rutik7066 commented Nov 25, 2024

@Tpuljak Yes we can mount the current workspace folder please take look at my devcontainer.json .
Their are two way to do it

  1. By using -v flag
  2. By specifying in devcontainer.json like i did.

Remember: in order to mount the folder. I had to be created before mounting.

@unsuman would it be possible to mount the workspace folder into the osx image? Similarly to how X11 is mounted here.

@Tpuljak
Copy link
Member Author

Tpuljak commented Nov 25, 2024

@Rutik7066 can you please share a video (on Youtube like unsuman) of how this works with Daytona? Show how you open the GUI and how you access the workspace folder inside MacOS.

@unsuman
Copy link
Contributor

unsuman commented Nov 25, 2024

I guess it is possible from what I can see from the community, I will try once the Docker naked image is fixed:
Screenshot 2024-11-25 at 5 42 14 PM
They also have a section in their docs but they are using sshfs to do that.

@Rutik7066
Copy link
Contributor

Rutik7066 commented Dec 2, 2024

@Tpuljak Sorry for not uploading the video. After switching to ubuntu it was not working

@Rutik7066 can you please share a video (on Youtube like unsuman) of how this works with Daytona? Show how you open the GUI and how you access the workspace folder inside MacOS.

@Tpuljak I was wrong it is only mounting volume to the container only not the VM. I am testing different the approaches to solving this issue. Right now i am stuck at this error
Screenshot from 2024-12-02 13-35-07

@Tpuljak
Copy link
Member Author

Tpuljak commented Dec 2, 2024

@Tpuljak I was wrong it is only mounting volume to the container only not the VM. I am testing different the approaches to solving this issue. Right now i am stuck at this error

@Rutik7066 please run LOG_LEVEL=debug daytona serve and let me know what comes up.

@Rutik7066
Copy link
Contributor

Rutik7066 commented Dec 2, 2024

@Tpuljak Same error
Screenshot from 2024-12-02 13-43-39

I am unable to find daytona directory in ubuntu. may be reinstalling can help

@Tpuljak
Copy link
Member Author

Tpuljak commented Dec 2, 2024

I am unable to find daytona directory in ubuntu. may be reinstalling can help

It seems something in the config is not correct so it can't be parsed.

A clean start might be best. Just run rm -rf ~/.config/daytona and you should be able to run the server again.

@Rutik7066
Copy link
Contributor

I am unable to find daytona directory in ubuntu. may be reinstalling can help

It seems something in the config is not correct so it can't be parsed.

A clean start might be best. Just run rm -rf ~/.config/daytona and you should be able to run the server again.

@Tpuljak Started Working

@Rutik7066
Copy link
Contributor

@Tpuljak which image does daytona use to create devcontainer if git repository does not have any devcontainer config. where can I access the image code

@Tpuljak
Copy link
Member Author

Tpuljak commented Dec 2, 2024

@Rutik7066 the image that we use is daytonaio/workspace-project. We build that image from the devcontainer definition you can find here https://github.com/daytonaio/daytona/tree/main/hack/project_image.

@Rutik7066
Copy link
Contributor

@Tpuljak Here is my current progress. I am not using the https://github.com/sickcodes/Docker-OSX image.

clideo_editor_bb6421384fdf4e5c9f8d526a507bf68c.mp4

Current Progress:

  1. I can successfully run a headless macOS VM in a dev container created using Daytona with the command daytona create.
  2. I am able to establish SSH and VNC connections to the VM from outside the dev container.
  3. I can access the files within the VM.

Drawbacks of the Current Approach:

  1. We need to host the pre-installed and pre-configured image file of the desired macOS version.
  2. Human interaction is required each time the VM starts to select the startup disk, after which we can establish the connection via SSH or VNC.

I am looking for solutions to automate the disk selection process and am also trying to understand how we can create a no-picker boot disk at runtime to bypass the selection process.

@Rutik7066
Copy link
Contributor

@Tpuljak which version of macos we want to support? and please share your thoughts on my current progress.

@Tpuljak
Copy link
Member Author

Tpuljak commented Dec 3, 2024

@Tpuljak which version of macos we want to support?

@Rutik7066 ideally, we support all of them but we can focus on one at the moment.

A few notes from my side:

  • Yes, the major drawback here is that the user is expected to run some of the setup manually. We should explore how to automate this process so that the user can boot into the loaded OS
  • Our Agent needs to be present inside the Mac VM for users to be able to run daytona code and daytona ssh into Mac directly. This is the desired outcome of this issue. The way our agent is installed generally can be found here:
    func GetProjectStartScript(daytonaDownloadUrl string, apiKey string) string {
    where the 2 arguments come from environment variables found inside the container. You can inspect these variables with docker inspect {CONTAINER} | grep DAYTONA. This process should be ran in the Mac VM. The only "issue" here is that the network hostname would be the same if you set DAYTONA_WS_ID and DAYTONA_PROJECT_NAME to the same value. You can try to set DAYTONA_PROJECT_NAME to something else to register on a different hostname. An important note here is that, if you're using daytona in development, you need to build the binary for Mac by running: make build OS=darwin in the root. If you're using production Daytona, then you don't need to build it.

@Rutik7066
Copy link
Contributor

@Tpuljak In the above solution I have figured out a solution for this problem

  • Yes, the major drawback here is that the user is expected to run some of the setup manually. We should explore how to automate this process so that the user can boot into the loaded OS

We can host pre-installed disk images (will be 25GB+ uncompressed ). So the user will not need to install and set up Mac on the first startup of the VM and we can also preinstall Daytona or agents in Mac so the Second problem that you specified will be solved. The only problem is that every time the user starts VM it will show the startup disk menu
Screenshot from 2024-12-03 14-25-45

@Tpuljak
Copy link
Member Author

Tpuljak commented Dec 3, 2024

We can host pre-installed disk images (will be 25GB+ uncompressed ). So the user will not need to install and set up Mac on the first startup of the VM and we can also preinstall Daytona or agents in Mac so the Second problem that you specified will be solved.

Can you set up an example of that?

The only problem is that every time the user starts VM it will show the startup disk menu

No way we can work around this?

@Tpuljak
Copy link
Member Author

Tpuljak commented Dec 3, 2024

To clarify, my comment before was referring to that boot disk screen.

@Rutik7066
Copy link
Contributor

@Tpuljak, Ohk.

To clarify, my comment before was referring to that boot disk screen.

That screen sucks

@Rutik7066
Copy link
Contributor

Rutik7066 commented Dec 3, 2024

We can host pre-installed disk images (will be 25GB+ uncompressed ). So the user will not need to install and set up Mac on the first startup of the VM and we can also preinstall Daytona or agents in Mac so the Second problem that you specified will be solved.

Can you set up an example of that?

The only problem is that every time the user starts VM it will show the startup disk menu

No way we can work around this?

Sure I have hosted the preinstalled disk on S3 already (it is around 20GB++). I will create a public repo with my current setup to use that image and share the link of the repo to try .
Daytona is not installed on the currently hosted image. Shall I update the image with pre-installed daytona?

@Tpuljak
Copy link
Member Author

Tpuljak commented Dec 3, 2024

Shall I update the image with pre-installed daytona?

That would be great. You can use the installation script from our README in that case. This will make sure it's installed on the correct path.

@unsuman
Copy link
Contributor

unsuman commented Dec 3, 2024

@Tpuljak I guess earlier, what I mentioned here can have some DMCA compliance issues since we will be distributing a pre-configured OSX that violates the T&Cs of Apple's bug bounty program, which is from where the sick codes/docker-osx project is built around!
Screenshot 2024-12-03 at 3 51 48 PM

You can refer to this article, where SickCodes documented everything that's legal and not. So the user has to manually do the OS setup from what I can see!
Let me know your thoughts.

@Tpuljak
Copy link
Member Author

Tpuljak commented Dec 3, 2024

@unsuman right, I completely forgot about that.

@Rutik7066 seems that your way is not the (legally) viable option.

Maybe you 2 can brainstorm together (here or on Slack) on what might be the best and most seamless option.
We would, of course, reward both of you for your work.

@unsuman
Copy link
Contributor

unsuman commented Dec 3, 2024

@unsuman right, I completely forgot about that.

@Rutik7066 seems that your way is not the (legally) viable option.

Maybe you 2 can brainstorm together (here or on Slack) on what might be the best and most seamless option. We would, of course, reward both of you for your work.

Sure, I'm up! We may discuss this on slack, what say @Rutik7066 ?

@Rutik7066
Copy link
Contributor

Rutik7066 commented Dec 3, 2024

@unsuman we can here. I am reading the article.

@Rutik7066
Copy link
Contributor

Rutik7066 commented Dec 3, 2024

@unsuman I am trying to figure out that what does pre configured means in our case.

@Rutik7066
Copy link
Contributor

@unsuman can you please explain me what is pre configured in our case.
Does it means pre installed or some thing else

@unsuman
Copy link
Contributor

unsuman commented Dec 3, 2024

@Rutik7066 Yes, they both are the same! Pre-configured/pre-installed is a .img file which has all the setup done beforehand like disk partitioning, enabling remote login in Settings -> Sharing, and installing Xcode-toolset and Xcode IDE(but you will need an Apple ID to download the IDE), giving users a seamless experience but since this has legal issues, we might need to rethink a different approach!

I prefer to discuss on Slack(Discord will also be fine) because discussing here will clutter out current findings and annoy maintainers with unnecessary notifications. We will definitely post breakthroughs or ask any questions we may have here on the issue.

@Rutik7066
Copy link
Contributor

@unsuman we will continue conversion on slack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ⚔️ Quest Tracks quest-bot quests
Projects
None yet
Development

No branches or pull requests

4 participants