Skip to content

Commit

Permalink
docker: Add docker buildx functionality to dockernode playbook for ar…
Browse files Browse the repository at this point in the history
…m32 containers (#3601)

* debug

* debug

* debug

* add arm32 suffix to image and container

* remove debug

* docs update

* docs update

* rename arm variable to arm32
  • Loading branch information
Haroon-Khel committed Jun 20, 2024
1 parent a0795b9 commit 8fc8be4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ The `dockerhost.yml` playbook can deploy single, multiple and duplicate containe

will deploy 1 Ubuntu 22.04 container, 1 Alpine 3.19 container and 3 Ubuntu 18.04 containers.

If you would like to build an arm32 container on an arm64 dockerhost, pass the `build_arm32` variable:

```
ansible-playbook -u root -i <host-file> AdoptOpenJDK_Unix_Playbook
/dockernode.yml -t "deploy" -e "docker_images=u2204 build_arm32=yes"
```

## Setting up a new DockerStatic container (manually)

If you would like to setup an individual container on one of these machines, follow these instructions:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
---

- name: Set docker build command
set_fact:
docker_build_command: "docker build"
arm32_suffix: ""

- name: Set docker buildx command if building arm32 container
set_fact:
docker_build_command: "docker buildx build --platform linux/v7/arm"
arm32_suffix: ".ARM32"
ansible_architecture: arm
when: build_arm32 is defined and build_arm32 == "yes"

# Dockerfiles are transferred from the controller node onto the dockerhost to be used to build and run docker containers
- name: Transfer dockerfile
copy:
Expand All @@ -19,8 +32,8 @@
regexp: "Jenkins_User_SSHKey"
replace: "{{ Jenkins_User_SSHKey }}"

- name: Build {{ docker_image }} docker images
command: docker build --cpu-period=100000 --cpu-quota=800000 -t aqa_{{ docker_image }} --memory=6G -f /tmp/Dockerfile.{{ docker_image }} /tmp/
- name: Build {{ docker_image }} docker images {{ docker_build_command }}
command: "{{ docker_build_command }} --cpu-period=100000 --cpu-quota=800000 -t aqa_{{ docker_image }}{{ arm32_suffix }} --memory=6G -f /tmp/Dockerfile.{{ docker_image }} /tmp/"

# Finds the highest port number already assigned and +1
- name: Find available port
Expand All @@ -38,4 +51,4 @@
when: not (docker_port_output.stdout == "")

- name: Run {{ docker_image }} docker container
command: docker run --restart unless-stopped -p {{ docker_port }}:22 --cpuset-cpus="0-3" --memory=6G --detach --name {{ docker_image | upper }}.{{ docker_port }} aqa_{{ docker_image }}
command: docker run --restart unless-stopped -p {{ docker_port }}:22 --cpuset-cpus="0-3" --memory=6G --detach --name {{ docker_image | upper }}.{{ docker_port }}{{ arm32_suffix }} aqa_{{ docker_image }}{{ arm32_suffix }}

0 comments on commit 8fc8be4

Please sign in to comment.