Skip to content

Instantly share code, notes, and snippets.

@gridhead
Last active May 12, 2021 17:42
Show Gist options
  • Save gridhead/9a93289839200b45a90b9c50ee94a18a to your computer and use it in GitHub Desktop.
Save gridhead/9a93289839200b45a90b9c50ee94a18a to your computer and use it in GitHub Desktop.
Automating arm64 Docker Image Builds Locally for SuperVisor Driver Service
- name: Build SuperVisor Driver Service Docker image
hosts: server1
remote_user: ubuntu
tasks:
- name: "STEP 1 - Clone the repository in the working directory and checkout the release branch"
ansible.builtin.git:
repo: "https://github.com/t0xic0der/supervisor-driver-service.git"
dest: "/home/ubuntu/data/svdriver"
version: "v1.2.1-beta"
- name: "STEP 2 - Change the current working directory to the repository directory"
community.docker.docker_compose:
project_src: "/home/ubuntu/data/svdriver"
build: "yes"
# - name: "STEP 2 - Change the current working directory to the repository directory"
# command: "chdir=/home/ubuntu/data/svdriver docker build . -f Dockerfile -t t0xic0der/supervisor-driver-server:v1.2.1b-arm64 --rm"
- name: "STEP 3 - Clean up the repository directory after the build has succeeded"
file:
state: "absent"
path: "/home/ubuntu/data/svdriver"
- name: "STEP 4 - Tagging the image properly and push it to DockerHub"
community.docker.docker_image:
name: "svdriver_endpoint"
repository: "t0xic0der/supervisor-driver-service:v1.2.1b-arm64"
push: "yes"
source: "local"
- name: "STEP 5.1 - Clean up the locally built images (svdriver_endpoint)"
community.docker.docker_image:
state: "absent"
force_absent: "yes"
name: "svdriver_endpoint:latest"
- name: "STEP 5.2 - Clean up the locally built images (t0xic0der/supervisor-driver-service:v1.2.1b-arm64)"
community.docker.docker_image:
state: "absent"
force_absent: "yes"
name: "t0xic0der/supervisor-driver-service:v1.2.1b-arm64"
- name: Install Docker Compose on Ubuntu
hosts: server1
remote_user: ubuntu
become: yes
become_method: sudo
become_user: root
tasks:
- name: "STEP 1 - Update all the repositories and existing packages"
apt:
update_cache: "yes"
name: "*"
state: "latest"
- name: "STEP 2 - Install Docker Compose from official repositories"
apt:
name: "docker-compose"
state: "latest"
[web]
server1 ansible_host=192.168.0.163
server1 ansible_ssh_user=ubuntu
server1 ansible_ssh_pass=<type-your-ssh-password-here>
server1 ansible_sudo_pass=<type-your-sudo-password-here>

Automating arm64 Docker Image Builds Locally for SuperVisor Driver Service

Do not forget to enter your SSH password and sudo password in the inventory.ini file before proceeding ahead.

Make sure that install-docker-compose-on-ubuntu.yml, inventory.ini and build-svdriver-docker-image.yml are in the same directory.

Run the following commands in succession to build an image and push it to DockerHub.

$ ansible-playbook -i inventory.ini install-docker-compose-on-ubuntu.yml -vvv
$ ansible-playbook -i inventory.ini build-svdriver-docker-image.yml -vvv

This assumes that you have already logged in to your Docker account in your remote machine and hence, the push takes place without asking for any kind of authentication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment