daytonaio / daytona

The Open Source Dev Environment Manager.
https://daytona.io
Apache License 2.0
11.44k stars 845 forks source link

OSX Daytona workspace #1338

Open Tpuljak opened 1 week ago

Tpuljak commented 1 week ago

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.

quest-bot[bot] commented 1 week ago

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 commented 1 week ago

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 commented 1 week ago

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

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

unsuman commented 1 week ago

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 commented 4 days ago

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 commented 4 days ago

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

Tpuljak commented 3 days ago

@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 commented 3 days ago

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 commented 3 days ago

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 commented 3 days ago

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 commented 3 days ago

@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

unsuman commented 3 days ago

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 commented 3 days ago

@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 commented 3 days ago

Yeah figured it out and it worked! Thanks!

Are you able to daytona ssh into the workspace now?

unsuman commented 3 days ago

Yeah figured it out and it worked! Thanks!

Are you able to daytona ssh into the workspace now?

Yes! image

Tpuljak commented 3 days ago

Yes!

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

unsuman commented 3 days ago

@quest-bot embark

quest-bot[bot] commented 3 days ago

@unsuman has embarked on their Quest. 🗡

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 commented 2 days ago

@quest-bot embark #1338

quest-bot[bot] commented 2 days ago

⚠️ 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 commented 2 days ago

@quest-bot embark

quest-bot[bot] commented 2 days ago

@Rutik7066 has embarked on their Quest. 🗡

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 commented 2 days ago

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 commented 2 days ago

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 commented 2 days ago

@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 commented 2 days ago

@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 root@1.1.1.1 -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 commented 2 days ago

@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 commented 1 day ago

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?

unsuman commented 1 day ago

In regards to the pre-configured OSX container, the sickcodes/docker-osx:naked is not working at the moment but the maintainer has assured a fix to be released soon.

Tpuljak commented 1 day ago

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?

This can allow users to view the GUI of their workspace. Can you please record how the flow works now? How the workspace is created and how you open the VNC.

unsuman commented 1 day ago

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?

This can allow users to view the GUI of their workspace. Can you please record how the flow works now? How the workspace is created and how you open the VNC.

Yup, on my way!

unsuman commented 1 day ago

But I am manually creating the container and not by daytona create <URL>. If I spin the OSX-container using my repo's devcontainer.json and daytona create <URL>, how should I then connect to VNC like what should be the URL to connect?

https://github.com/user-attachments/assets/461c7247-1888-46fc-b29a-df78e4b2ac75

Tpuljak commented 1 day ago

@unsuman before I view the entire video, please revoke the github token that you showed in the first 5 seconds 😅

unsuman commented 1 day ago

Ik, already did that :rofl:

Tpuljak commented 1 day ago

But I am manually creating the container and not by daytona create . If I spin the OSX-container using my repo's devcontainer.json and daytona create , how should I then connect to VNC like what should be the URL to connect?

First of all, I suggest that you try to use the devcontainer onCreateCommand to execute the CMD of the docker-osx image (https://github.com/sickcodes/Docker-OSX/blob/master/Dockerfile#L364). Devcontainers override the CMD of the image to sleep infinity so that the container stays alive. I suggest that you put the CMD in a script that you can then execute in onCreateCommand.

Then, check that daytona create https://github.com/unsuman/test-osx-dtn will wait for the OSX to install.

At this point, if daytona does wait, you can print out (e.g. using echo in postStartCommand) which VNC port can be used to view the UI. I can try it out then and see if it works.

unsuman commented 1 day ago

Cool!

Rutik7066 commented 1 day ago

My progress as of now

https://github.com/user-attachments/assets/d917cea2-3e13-4e58-8e89-3bce8645e873

  1. We can set the password to VNC in -e EXTRA="-display none -vnc 0.0.0.0:99,password=on" \ command since it is QEMU args and change the port as per requirements here -vnc 0.0.0.0:PORT .
  2. We can attach the volume to the container using -v /workspaces/test-osx-dtn:/workspaces/test-osx-dtn \ Doc Ref Code Docs
Tpuljak commented 1 day ago

@Rutik7066 thanks. Please read through the comments I left for @unsuman. They are applicable to you as well.

Rutik7066 commented 1 day ago

@Tpuljak, how could this happen? Screenshot 2024-11-21 203438

unsuman commented 1 day ago

@Tpuljak, how could this happen?

Screenshot 2024-11-21 203438

It's also happening on my side! For the time being you can add Github as a git-provider and only daytona create shall do the job!

Rutik7066 commented 1 day ago

@unsuman Yes, your right I am using daytona create for now. @Tpuljak I can solve this. Shall I create new PR for this fix?

Tpuljak commented 1 day ago

@Rutik7066 @unsuman are you both updated to the latest version of Daytona?

We had some breaking changes recently that affected git providers. Specifically the v0.38.0 release. Please make sure to update to the latest version and to comply with all the breaking changes from the releases page.

unsuman commented 1 day ago

@Tpuljak I'm using build to use daytona so it's v0.0.0-dev. But my main is updated to the latest. Screenshot from 2024-11-21 21-13-20

Tpuljak commented 1 day ago

@unsuman okay, this might be related to GitHub's api having issues (https://www.githubstatus.com/).

If it works with the URL, use that for now.

Rutik7066 commented 23 hours ago

@unsuman okay, this might be related to GitHub's api having issues (https://www.githubstatus.com/).

If it works with the URL, use that for now.

ahh, I thought there was something wrong with the code. My bad

Rutik7066 commented 3 hours ago

@Tpuljak While testing the changes i am getting this error Screenshot 2024-11-22 182232

Rutik7066 commented 3 hours ago

@Tpuljak While testing the changes i am getting this error Screenshot 2024-11-22 182232

Not sure why but it is trying to mount the volume which I have not specified in .devcontainer config

Tpuljak commented 3 hours ago

@Rutik7066 can you please send me the link to the repo you're using?

Rutik7066 commented 3 hours ago

@Rutik7066 can you please send me the link to the repo you're using?

@Tpuljak https://github.com/Rutik7066/osx-daytona this the repo.

unsuman commented 3 hours ago

But I am manually creating the container and not by daytona create . If I spin the OSX-container using my repo's devcontainer.json and daytona create , how should I then connect to VNC like what should be the URL to connect?

First of all, I suggest that you try to use the devcontainer onCreateCommand to execute the CMD of the docker-osx image (https://github.com/sickcodes/Docker-OSX/blob/master/Dockerfile#L364). Devcontainers override the CMD of the image to sleep infinity so that the container stays alive. I suggest that you put the CMD in a script that you can then execute in onCreateCommand.

Then, check that daytona create https://github.com/unsuman/test-osx-dtn will wait for the OSX to install.

At this point, if daytona does wait, you can print out (e.g. using echo in postStartCommand) which VNC port can be used to view the UI. I can try it out then and see if it works.

@Tpuljak I tried extracting out the CMD of the sickcode's Dockerfile and putting that to a script and then tried running that using devcontainer's onCreateCommand but I faced so many dependency issues like some scripts were not available like start-ssh.sh & Launch.sh. Even then, I tried creating them manually by seeing from the original Dockerfile still I was facing issues like make: targets not specified, qemu-system-x86_64: -drive id=InstallMedia,if=none,file=/home/arch/OSX-KVM/BaseSystem.img,format=qcow2: Could not open '/home/arch/OSX-KVM/BaseSystem.img': No such file or directory etc. I learned that by putting overrideCommand to false in devcontainer.json will force to run the CMD of the image. But sadly that didn't work.

Now I might sound insane but I installed Docker inside Docker(DinD) and it worked but I don't know how relevant is it in our use-case but do checkout this video. First I tried to run the script using onCreateCommand, I was able to spin up an OSX container but the logs and IDE forwarding freezed: Screenshot from 2024-11-22 18-02-51

That's why included the script in postCreateCommand, here's the devcontainer.json, Dockerfile, start-docker-osx.sh & the video that demonstrates the flow:

https://github.com/user-attachments/assets/e4660367-067b-480b-b3cc-53bd8bb3882c