Self-Contained docToolchain

When you work in a restricted environment where you don’t have direct access to the internet, you might need a self-contained version of docToolchain. A version which does not need to download dependencies but already has them on board.

Docker Solution

If you have docker available, then this might already be the solution. The docker image already contains all dependencies and the docToolchain wrapper (dtcw) already checks if docker is available and running and thus will use docker in this case. In order to fetch the docker image from your local docker proxy, please check the source of dtcw and update the docker image reference.

Local Solution

If you don’t have Docker available, you need a local, self-contained install.

Download wrapper

Start on an unrestricted system and download the docToolchain wrapper:

mkdir dtc-self-contained
cd dtc-self-contained
curl -Lo dtcw doctoolchain.org/dtcw
chmod +x dtcw

Check and install correct Java Development Kit (JDK)

We start with ensuring that we have the correct Java Development Kit (JDK) installed. Execute

./dtcw local install java

to fetch and install the correct JDK. It will be installed to $HOME/.doctoolchain/jdk.

Start first tasks to install docToolchain locally

Now, let’s start a simple task to download and install docToolchain locally:

./dtcw local tasks

local will ensure that docker is ignored, even when docker is up and running.
tasks is a simple task which just shows all available tasks.

When you run this command, docToolchain will ask if it is allowed to install itself to $HOME/.doctoolchain and if it should create a simple config file. It will also fetch some first dependencies in order to execute the task. These dependencies will be downloaded to $HOME/.doctoolchain/.gradle.

Fetch remaining dependencies

To fetch the remaining dependencies, execute

./dtcw downloadDependencies

this will fetch the remaining dependencies and download them to $HOME/.doctoolchain/.gradle

Get an offline gradle binary

The last needed step is to download an offline version of gradle for docToolchain to use. This was inspired by https://chengl.com/gradle-offline-build/.

Steps
  1. download a gradle binary-zip from https://services.gradle.org/distributions/

  2. place it in the folder .doctoolchain/docToolchain-$VERSION/gradle/wrapper (replace $VERSION with current docToolchain version that you installed)

  3. go to folder .doctoolchain/docToolchain-$VERSION/gradle/wrapper and open the file gradle-wrapper.properties

  4. change the distributionUrl to distributionUrl=gradle-$GRADLEVERSION-bin.zip (replace $GRADLEVERSION with the version of the binary-zip you just downloaded)

docToolchain now uses an offline version of Gradle.

Finalize

As a result, we now have docToolchain, a JDK, gradle and all dependencies installed to $HOME/.doctoolchain.

You can now zip this folder and copy it to your restricted environment to the $HOME/.doctoolchain folder. The wrapper of your project will recognize it as local installation and use it.

the installed JDK is for one specific PU architecture. So, if your team works with different Systems (Windows, Mac, Linux), you have to create several versions.