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

#690: add support for rancher desktop #727

Merged
merged 24 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fc3fa3c
first implementation for rancher desktop
cinnamon-coder-hub Mar 31, 2022
b771423
#690:modified-docker-cmdlet-and-documentation
cinnamon-coder-hub Apr 19, 2022
8d77856
#690: fix dmg filename
tobka777 Apr 19, 2022
ae72ceb
#690: added License of Rancher Desktop
cinnamon-coder-hub Apr 26, 2022
4e7d88a
Merge branch '690-cmdlet-rancher-desktop' of https://github.com/cinna…
cinnamon-coder-hub Apr 26, 2022
22a360d
Merge branch 'devonfw:master' into 690-cmdlet-rancher-desktop
cinnamon-coder-hub Apr 26, 2022
6b5531e
#690: added instructions to run R D at startup
cinnamon-coder-hub Apr 26, 2022
cb4e1f5
Merge branch '690-cmdlet-rancher-desktop' of https://github.com/cinna…
cinnamon-coder-hub Apr 26, 2022
3e742c3
#690: added/modified file links
cinnamon-coder-hub Apr 27, 2022
f41dc00
#690: edited details, doc and fixed code-typo
cinnamon-coder-hub May 6, 2022
7b3ca37
#690:implemented-spellcheck-recommendations
cinnamon-coder-hub May 6, 2022
860b278
#690: deactivated spellcheck in one line wittingly
cinnamon-coder-hub May 6, 2022
df8117e
Merge branch 'master' into 690-cmdlet-rancher-desktop
hohwille May 12, 2022
245df56
Merge branch 'master' into 690-cmdlet-rancher-desktop
hohwille May 17, 2022
5faf25d
fixed indendation issue
hohwille May 17, 2022
d94cf3e
code-convention improvements
hohwille May 17, 2022
b7e0a8a
Merge branch 'master' into 690-cmdlet-rancher-desktop
hohwille May 23, 2022
ee77d5e
#690: improved version comparision
cinnamon-coder-hub May 24, 2022
71c8512
Merge branch '690-cmdlet-rancher-desktop' of https://github.com/cinna…
cinnamon-coder-hub May 24, 2022
2cca3ee
#690: added quotation marks around number
cinnamon-coder-hub May 24, 2022
6a4c784
#690: fixing mirror issues
cinnamon-coder-hub May 24, 2022
5ac686f
Merge branch 'master' into 690-cmdlet-rancher-desktop
hohwille May 24, 2022
41c8e5e
fixed shellcheck issues and some of my last review comments
hohwille May 24, 2022
34f52cd
more shellcheck fixes
hohwille May 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions documentation/LICENSE.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ The following table shows the components that may be used. The column `inclusion
|https://helm.sh/[helm]|Optional|https://github.com/devonfw/ide/blob/master/LICENSE[ASL 2.0]
|https://terraform.io/[terraform]|Optional|https://github.com/hashicorp/terraform/blob/main/LICENSE[Mozilla Public License 2.0]
|https://www.graalvm.org/[GraalVM] |Optional|https://github.com/oracle/graal/blob/master/LICENSE[GPLv2] (with the “Classpath” Exception)
|https://rancherdesktop.io/[Rancher Desktop]|Optional|https://github.com/rancher-sandbox/rancher-desktop/blob/main/LICENSE[ASL 2.0]
|=======================

== Apache Software License - Version 2.0
Expand Down
44 changes: 29 additions & 15 deletions documentation/docker.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ toc::[]

The Docker commandlet allows to install and use https://www.docker.com/[Docker].
On Windows https://docs.microsoft.com/en-us/windows/wsl/install-win10[WSL 2](Windows Subsystem for Linux) has to be installed properly as a prerequisite.

It also offers the installation of https://rancherdesktop.io/[Rancher Desktop], which works on Windows, Mac and Linux.
To run the tools installed and managed by Rancher Desktop it is necessary to have Rancher Desktop up and running.
To assure that you are able to use these tools directly after startup, you can add Rancher Desktop to the startup programs
of your Operating System. Such instructions will be given below inside the sections for Windows, Mac and Linux.
*ATTENTION:*
Currently this feature is new and therefore experimental.
It may change in incompatible ways in the next releases until we reach a stable state.
Expand All @@ -25,9 +28,20 @@ The arguments (`devon docker «args»`) are explained by the following table:
|=======================

== setup
The Docker commandlet will install Docker automatically.
The Docker commandlet will install Docker Desktop or Rancher Desktop automatically.
This depends on how the variable DOCKER_EDITION was set. We chose to set Rancher Desktop as standard
for our installation, due to it being license free compared to Docker Desktop while offering a similar tool set (please read the document link:docker-desktop-alternative.asciidoc[docker-desktop-alternative.asciidoc] motivating why we added Rancher Desktop to the docker commandlet).
hohwille marked this conversation as resolved.
Show resolved Hide resolved
Docker Desktop can still be used as before, by setting the variable DOCKER_EDITION equal to "DOCKERDESKTOP".
This can be done by your projects ide-admin in the link:usage.asciidoc#developer[settings file]. If you want to switch from Rancher Desktop to Docker Desktop, then add a line with the following content
"DOCKER_EDITION=DOCKERDESKTOP"
(without the quotes around the allocation) to the file devon.properties located at the path ${DEVON_IDE_HOME}/conf/devon.properties.

After successfull installation please start Rancher Desktop and go to the menu point "Kubernetes Settings". Under "Container Runtime" choose dockerd(moby) to enable the docker-cli. If you use Windows, then make sure to go to the Settings named "WSL Integration".
There you can choose the WSL Shells you want Rancher Desktop to work on. Besides that the tools like docker or kubectl should
directly work with CMD or Powershell.

Please note that besides the sandbox concept of devonfw-ide this is a global installation on your system.
When uninstalling devonfw-ide, you may have to manually uninstall Docker and Kubernetes if you do not need it anymore.
When uninstalling devonfw-ide, you may have to manually uninstall Docker and Kubernetes, or Rancher Desktop if you do not need it anymore. At least uninstalling Rancher Desktop should leave way less remains if you did not install one of the related software Rancher Desktop offers separately.

=== requirements
Running Docker and especially link:kubectl.asciidoc[Kubernetes] on your machine in the background will require quite some resources.
Expand All @@ -36,15 +50,17 @@ This will allocate at least 2GB of additional RAM.
You will need at least 8GB of total RAM while we recommend to use 16GB+.

You may also tune and scale it to your needs.
When using Docker Desktop (Windows or MacOS) simply go to the https://docs.docker.com/docker-for-windows/#resources[resources tab in the settings].
When using Docker Desktop (Windows or MacOS) simply go to the https://docs.docker.com/docker-for-windows/#resources[resources tab in the settings].
It will depend on your usage frequency if you want to have it running in the background all the time.
This is a balance between resource utilization and convenience.
If you use Docker and Kubernetes on your local machine on a daily basis this makes sense.

In case you only use Docker rarely, you can save resources by stopping it when not needed after it has been installed.

=== Windows and macOS
To enable or disable autostart, you can launch Docker Desktop on Windows or MacOS got to the `Preferences` (gear icon in the title bar). Then in the `General` tab you can check or uncheck the option `Start Docker Desktop when you login` (see also https://docs.docker.com/docker-for-windows/#general[here]). When autostart is disabled and you launch Docker Desktop it will notice and ask your to start the service or do this automatically for you.
For Windows 10 you can use the following https://www.dell.com/support/kbdoc/de-de/000124550/how-to-add-app-to-startup-in-windows-10[Instructions on how to set startup programs for Windows 10], so that Rancher Desktop starts with your OS.

To enable or disable autostart, you can launch Docker Desktop on Windows or MacOS go to the `Preferences` (gear icon in the title bar). Then in the `General` tab you can check or uncheck the option `Start Docker Desktop when you login` (see also https://docs.docker.com/docker-for-windows/#general[here]). When autostart is disabled and you launch Docker Desktop it will notice and ask your to start the service or do this automatically for you.
On Windows you can also manually tweak this:

* Hit `[windows][r]`
Expand All @@ -55,7 +71,9 @@ On Windows you can also manually tweak this:
* Also when right clicking on Docker Desktop Service and selecting `Options` from the context-menu, you can change the start type to `automatic` or `manual`.

==== Mac A1
In case you have a new Mac with A1 CPU, we automatically download and install the according ARM version of Docker Desktop for macOS.
Have a look at the https://www.makeuseof.com/tag/add-remove-delay-startup-items-mac/[Instructions on how to set startup programs for MacOS] to make Rancher Desktop run directly after starting up your OS.

In case you have a new Mac with A1 CPU, we automatically download and install the according ARM version of Docker Desktop or Rancher Desktop for macOS.
However, if you use Docker and search for images you may end up with errors like:
```
docker: no matching manifest for linux/arm64/v8 in the manifest list entries.
Expand All @@ -64,18 +82,14 @@ docker: no matching manifest for linux/arm64/v8 in the manifest list entries.
So with A1 CPU you may need to add `--platform linux/x86_64` as option to your Docker command to find the expected container image.

=== Linux
There is no Docker Desktop for Linux.
As Docker initially comes from the Linux world, it is easy to set it up on a Linux machine and use it from the commandline.
Therefore we do not install a GUI for you in case you are a Linux user.
In case you need a GUI for Docker and Kubernetes on Linux you can choose from the following options:
Docker Desktop isn't available for Linux, but Rancher Desktop can be used as compareable alternative as mentioned before.

* https://dockstation.io/[DockStation]
* https://portainer.io/[Portainer]
* https://kitematic.com/[Kitematic]
* https://shipyard-project.com/[Shipyard]
To make the usage of Rancher Desktop more comfortable and reliable let your operating system run it after starting up your system.
On many Linux distributions you can just go to your menu (usually by clicking the icon at your screens left bottom), type "startup" and start your systems GUI-startup manager, if popping up. At the following website you can find some https://www.simplified.guide/linux/automatically-run-program-on-startup[examples or other options on how to set startup programs for some Linux distributions].

== usage
Once installed via setup, you can run Docker directly from any shell of your OS directly.
Once installed via setup, you can run Docker from any shell of your OS directly. If you use Rancher Desktop just
make sure that Rancher Desktop runs in the background.
Run `docker help` to get started and use the online documentations and resources on the web to get familiar with Docker.
It is not our intention to repeat this here.

Expand Down
1 change: 1 addition & 0 deletions documentation/variables.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Please note that we are trying to minimize any potential side-effect from `devon
|*`M2_REPO`*|`$DEVON_IDE_HOME/conf/.m2/repository`|Path to your local maven repository. For projects without high security demands, you may change this to the maven default `~/.m2/repository` and share your repository among multiple projects.
|*`MAVEN_HOME`*|`$DEVON_IDE_HOME/software/maven`|Path to Maven
|*`MAVEN_OPTS`*|`-Xmx512m -Duser.home=$DEVON_IDE_HOME/conf`|Maven options
|*`DOCKER_EDITION`*|e.g. `DOCKERDESKTOP`| If set as `DOCKERDESKTOP` the command `devon docker setup` will setup Docker Desktop globally at the users computer. Otherwise the setup of Rancher Desktop will be started.|
|*`GRAALVM_HOME`*|`$DEVON_IDE_HOME/software/extra/graalvm`|Path to GraalVM
|`DEVON_SOFTWARE_REPOSITORY`|`-`|Project specific or custom link:software.asciidoc#repository[software-repository].
|`DEVON_SOFTWARE_PATH`|`-`|Globally shared user-specific link:software.asciidoc#shared[local software installation location].
Expand Down
167 changes: 135 additions & 32 deletions scripts/src/main/resources/scripts/command/docker
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,124 @@ source "$(dirname "${0}")"/../functions

# $1: optional setup
function doSetup() {
if doIsDockerInstalled
if [ ! "$DOCKER_EDITION" = "DOCKERDESKTOP" ]
hohwille marked this conversation as resolved.
Show resolved Hide resolved
then
if [ "${1}" != "silent" ] && ! doIsQuiet
then
doEcho "docker is already installed at $(command -v docker)"
docker version
echo "Rancher Desktop set as option"
if [[ $(uname -r | grep -i microsoft) ]]
then
echo "It seems that you are running the setup from inside a WSL shell."
echo "Please use git-bash for that purpose. Otherwise your OS will be interpreted as Linux"
else
if doIsRancherInstalled
then
doIsWindows
queryWin=$?
if [ "${1}" != "silent" ] && ! doIsQuiet
then
#give the User the installation location when using linux or mac
if [ queryWin != 0 ]
then
doEcho "Rancher Desktop is already installed at $(command -v devon docker)"
else
doEcho "Rancher Desktop is already installed"
fi
fi
else
doRequireNotBatch
latestversion=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/rancher-sandbox/rancher-desktop/releases/latest | sed 's/.*\([0-9]\.[0-9]\.[0-9]\).*/\1/')
previousversion="1.2.1"
if [[ "$latestversion" =~ ^[0-9]\.[0-9].[0-9]$ ]]
then
if [ "$latestversion" > "$previousversion" ]
then
echo "setting RANCHER_VERSION"
RANCHER_VERSION=$latestversion
echo "RANCHER_VERSION is $RANCHER_VERSION"
fi
fi
local version="${RANCHER_VERSION:-1.2.1}"
hohwille marked this conversation as resolved.
Show resolved Hide resolved
local code
#to download Rancher Desktop we need a bit more work compared to Docker-Desktop
#as the download-URL isn't well structured
if doIsWindows
then
arch="-"
ext="windows"
os="windows"
elif doIsMacOs
then
ext="mac"
os="mac"
#options that work with mac OS
#arch="arm64"
#arch="x86_64"
arch="$(uname -m)"
else
arch="-"
ext="other"
os="linux"
fi
hohwille marked this conversation as resolved.
Show resolved Hide resolved
doDownload "-" "" "rancher" "${version}" "" "${arch}" "${os}" "${arch}" "${ext}"
if doIsWindows
then
doEcho "Installing Rancher Desktop for Windows..."
doRunCommand "${DEVON_DOWNLOAD_DIR}/rancher-${version}-Rancher.Desktop.Setup..exe"
elif doIsMacOs
then
doEcho "Installing Rancher Desktop for MacOS..."
local mount_dir="${DEVON_IDE_HOME}/updates/volume"
mkdir -p "${mount_dir}"
doRunCommand "hdiutil attach -quiet -nobrowse -mountpoint '${mount_dir}' '${DEVON_DOWNLOAD_DIR}/rancher-${version}-Rancher.Desktop-.dmg'"
doRunCommand "cp -a '${mount_dir}'/*.app /Applications/"
doRunCommand "hdiutil detach -force '${mount_dir}'"
fi
mkdir "${DEVON_IDE_HOME}"/software/rancher; touch rancher-install-info.txt; echo "Rancher Desktop installed globally" > install-info.txt
ls "${DEVON_IDE_HOME}"/software/rancher
read -r -p "Rancher Desktop has been installed. Please read https://github.com/devonfw/ide/blob/master/documentation/docker.asciidoc#setup for enabling kubernetes and further important details. Press enter to continue" answer
fi
fi
else
doRequireNotBatch
#Start setup
local version="${DOCKER_VERSION:-stable}"
local code
if doIsWindows
then
code="Docker%20Desktop%20Installer"
elif doIsMacOs
if doIsDockerInstalled
then
code="Docker"
if [ "${1}" != "silent" ] && ! doIsQuiet
then
doEcho "docker is already installed at $(command -v docker)"
docker version
fi
else
doFail "Sorry, docker-installation support is not yet implemented for your OS. Please install manually or help devonfw-ide to support it for your OS by contributing a pull-request."
fi
doDownload "-" "" "docker" "${version}" "" "${code}"
if doIsWindows
then
doEcho "Installating Docker Desktop for Windows..."
doRunCommand "${DEVON_DOWNLOAD_DIR}/docker-stable-win.exe"
elif doIsMacOs
then
doEcho "Installating Docker Desktop for MacOS..."
local mount_dir="${DEVON_IDE_HOME}/updates/volume"
mkdir -p "${mount_dir}"
doRunCommand "hdiutil attach -quiet -nobrowse -mountpoint '${mount_dir}' '${DEVON_DOWNLOAD_DIR}/Docker.dmg'"
doRunCommand "cp -a '${mount_dir}'/*.app /Applications/"
doRunCommand "hdiutil detach -force '${mount_dir}'"
doRequireNotBatch
local version="${DOCKER_VERSION:-stable}"
local code
if doIsWindows
then
code="Docker%20Desktop%20Installer"
elif doIsMacOs
then
code="Docker"
else
doFail "Sorry, docker-installation support is not yet implemented for your OS. Please use Rancher Desktop instead, or install manually or help devonfw-ide to support it for your OS by contributing a pull-request."
fi
doDownload "-" "" "docker" "${version}" "" "${code}"
if doIsWindows
then
doEcho "installing Docker Desktop for Windows..."
doRunCommand "${DEVON_DOWNLOAD_DIR}/docker-stable-win.exe"
elif doIsMacOs
then
doEcho "installing Docker Desktop for MacOS..."
local mount_dir="${DEVON_IDE_HOME}/updates/volume"
mkdir -p "${mount_dir}"
doRunCommand "hdiutil attach -quiet -nobrowse -mountpoint '${mount_dir}' '${DEVON_DOWNLOAD_DIR}/Docker.dmg'"
doRunCommand "cp -a '${mount_dir}'/*.app /Applications/"
doRunCommand "hdiutil detach -force '${mount_dir}'"
fi
read -r -p "Docker Desktop has been installed. Please read https://github.com/devonfw/ide/blob/master/documentation/docker.asciidoc#setup for enabling kubernetes and further important details. Press enter to continue" answer
tobka777 marked this conversation as resolved.
Show resolved Hide resolved
fi
read -r -p "Docker Desktop has been installed. Please read https://github.com/devonfw/ide/blob/master/documentation/docker.asciidoc#setup for enabling kubernetes and further important details. Press enter to continue" answer
fi
}

# Call Docker with specified arguments.

# Call Docker with specified arguments.
function doRun() {
doSetup silent
doEcho "Running: docker ${*}"
Expand All @@ -72,6 +150,31 @@ function doIsDockerInstalled() {
fi
}

#OS independent check if Rancher Desktop is installed.
function doIsRancherInstalled() {
if doIsWindows
then
touch tmp-res-install-query rd-install-test.ps1
echo 'if($env:Path -like "*Rancher Desktop*") { set-content .\tmp-res-install-query "installed"} else {set-content .\tmp-res-install-query "not"}' > rd-install-test.ps1
powershell.exe -Command ".\rd-install-test.ps1"
installvar=$(awk 'NR=1' tmp-res-install-query)
rm tmp-res-install-query rd-install-test.ps1
if [ ${installvar}="installed" ]
then
return
else
return 255
fi
else
if command -v rancher-desktop &> /dev/null
then
return
else
return 255
fi
fi
}

# CLI
case ${1} in
"help" | "-h")
Expand All @@ -80,7 +183,7 @@ case ${1} in
echo "Arguments:"
echo " setup setup docker on your machine (global installation)."
echo " «args» call docker with the specified arguments. Call docker help for details or use docker directly as preferred."
echo
echo
;;
"setup" | "s" | "")
doSetup setup "${2}"
Expand Down