-
Notifications
You must be signed in to change notification settings - Fork 103
Jenkins
For Dhis2 Jenkins, Cloud init images are used. It's a cloud instance initialization method similar to Docker but is supported across all major public cloud providers, provisioning systems for private cloud infrastructure, and bare-metal installations.
If you would like to work with cloud init locally, the basic requirement is to have an Ubuntu or any other similar Linux distribution installed on your machine.
The first step is to install LXD (https://linuxcontainers.org/lxd/), to do so just type:
sudo snap install lxd
Set up minimal configuration
lxd init --minimal
Now that we have LDX installed, let's test a dummy image.
vi /tmp/my-user-data
And paste the following code:
#cloud-config
runcmd:
- echo 'Hello, World!' > /var/tmp/hello-world.txt
Save the file with :wq
and launch the container
lxc launch ubuntu:focal my-test --config=user.user-data="$(cat /tmp/my-user-data)"
After the container is launched, let's try to get a shell of the container
lxc shell my-test
You should now be in a shell inside the LXD instance. Before validating the user data, let’s wait for cloud-init to complete successfully:
cloud-init status --wait
From this point, you will get either an error
message if something happened or a done
message if the deployment of the container was successful.
Now, let's verify the creation of the txt file
cat /var/tmp/hello-world.txt
Hello, World!
You can see that everything went well ;).
To stop and remove the container:
lxc stop my-test
lxc rm my-test
If you need to deploy the Android Image, the process is very similar to the one that was explained above, but you will need to keep a couple of things in mind:
- Once you have a shell container add $PATH to your .profile/bashrc (for example default user, ubuntu)
vim /home/ubuntu/.profile
PATH=$PATH:/opt/gradle/bin:/opt/kotlinc/bin:/opt/android-sdk/cmdline-tools/latest/bin:/opt/android-sdk/cmdline-tools/tools/bin:/opt/android-sdk/platform-tools:/opt/android-sdk/emulator
- If you need to compile a branch of the project, you will need to clone it manually once you have a shell container. If this become very repetitive add the following steps to a script:
git init
git remote add origin" https://github.com/dhis2/dhis2-android-capture-app.git
git fetch origin refs/heads/develop
git checkout develop
--> or git checkout hash
git submodule update --init --recursive
- If you would like to modify the image please consider the following documentation and examples
https://cloudinit.readthedocs.io/en/latest/
https://cloudinit.readthedocs.io/en/latest/topics/examples.html