-
-
Notifications
You must be signed in to change notification settings - Fork 102
/
deploy.yml
35 lines (29 loc) · 1.61 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
---
# Dockerfiles are transferred from the controller node onto the dockerhost to be used to build and run docker containers
- name: Transfer dockerfile
copy:
src: "roles/DockerStatic/Dockerfiles/Dockerfile.{{ docker_image }}"
dest: "/tmp/Dockerfile.{{ docker_image }}"
# For images built on non x86_64 dockerhosts
- name: Translate architecture in dockerfile
replace:
dest: /tmp/Dockerfile.{{ docker_image }}
regexp: "x64"
replace: "{{ ansible_architecture }}"
when: ansible_architecture != "x86_64"
- name: Set jenkins authorized_Key in dockerfiles
replace:
dest: /tmp/Dockerfile.{{ docker_image }}
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/
# Without specifying a port here, docker will give the container a random unused port
- name: Run {{ docker_image }} docker container
command: docker run --restart unless-stopped -p 22 --cpuset-cpus="0-3" --memory=6G --detach --name {{ docker_image | upper }}.PORT aqa_{{ docker_image }}
# Now we want to rename the running container with the port name
- name: Find assigned port of {{ docker_image }} container
shell: docker port {{ docker_image | upper }}.PORT | head -n 1 | cut -d ':' -f 2
register: docker_port
- name: Rename {{ docker_image }} container to {{ docker_image | upper }}.{{ docker_port.stdout_lines[0] }}
command: docker rename {{ docker_image | upper }}.PORT {{ docker_image | upper }}.{{ docker_port.stdout_lines[0] }}