Updated docker ansible script

This commit is contained in:
Trial97
2021-07-23 13:03:24 +03:00
committed by Dan Christian Bogos
parent 2450cf56d0
commit 81af66f247
3 changed files with 18 additions and 9 deletions

View File

@@ -53,7 +53,7 @@
- name: Start registry
become: yes
shell: docker run -d --name {{ registry_name }} --restart=always -v "$(pwd)":/var/lib/{{ registry_name }} -p 5000:5000 registry:2
shell: docker run -d --name {{ registry_name }} --restart=always -v "$(pwd)":/var/lib/{{ registry_name }} -p {{ registry_port }}:5000 registry:2
args:
chdir: /var/docker/{{ registry_name }}
when: continerList.stdout_lines|length == 0

View File

@@ -28,6 +28,7 @@
registry_site: "dkr.cgrates.org" # the web site
registry_name: "registry" # the name of the registry container
users_filename: "" # the file containing the htpasswd users
registry_port: 5000
dependencies:
- build-essential
@@ -99,6 +100,13 @@
###########################################################################################################################
###########################################################################################################################
# Install CGRateS
- name: create cgrates directory
become: yes
file:
state: absent
dest: '{{ cgrates_dir }}'
become_user: "{{ user }}"
- name: create cgrates directory
become: yes
file:
@@ -184,7 +192,7 @@
- name: build Docker image
become: yes
shell:
docker build -t 127.0.0.1:5000/{{ cgrates_distribution }}/{{ item }}:{{ docker_tag }} -f="{{ item }}.doker" {{ cgrates_dir }}/data/docker/scratch/;
docker build -t 127.0.0.1:{{ registry_port }}/{{ cgrates_distribution }}/{{ item }}:{{ docker_tag }} -f="{{ item }}.doker" {{ cgrates_dir }}/data/docker/scratch/;
args:
chdir: '{{ cgrates_dir }}/data/docker/scratch'
with_items: "{{ build_execs }}"
@@ -192,20 +200,20 @@
- name: push docker image to repo
become: yes
shell:
docker image push 127.0.0.1:5000/{{ cgrates_distribution }}/{{ item }}:{{ docker_tag }};
docker image push 127.0.0.1:{{ registry_port }}/{{ cgrates_distribution }}/{{ item }}:{{ docker_tag }};
with_items: "{{ build_execs }}"
- name: tag docker master image
become: yes
shell:
docker tag 127.0.0.1:5000/{{ cgrates_distribution }}/{{ item }}:{{ docker_tag }} 127.0.0.1:5000/{{ cgrates_distribution }}/{{ item }}:latest;
docker tag 127.0.0.1:{{ registry_port }}/{{ cgrates_distribution }}/{{ item }}:{{ docker_tag }} 127.0.0.1:{{ registry_port }}/{{ cgrates_distribution }}/{{ item }}:latest;
when: cgrates_branch == "master" or cgrates_branch == "1.0"
with_items: "{{ build_execs }}"
- name: push docker master image to repo
become: yes
shell:
docker image push 127.0.0.1:5000/{{ cgrates_distribution }}/{{ item }}:latest;
docker image push 127.0.0.1:{{ registry_port }}/{{ cgrates_distribution }}/{{ item }}:latest;
when: cgrates_branch == "master" or cgrates_branch == "1.0"
with_items: "{{ build_execs }}"

View File

@@ -25,19 +25,20 @@ server {
}
# To add basic authentication to v2 use auth_basic setting.
limit_except GET HEAD OPTIONS {
deny all;
}
{% if users_filename|length > 0 %}
auth_basic "Registry realm";
auth_basic_user_file /etc/nginx/conf.d/nginx.htpasswd;
{% else %}
limit_except GET HEAD OPTIONS {
deny all;
}
{% endif %}
## If $docker_distribution_api_version is empty, the header is not added.
## See the map directive above where this variable is defined.
add_header 'Docker-Distribution-Api-Version' $docker_distribution_api_version always;
proxy_pass http://127.0.0.1:5000;
proxy_pass http://127.0.0.1:{{ registry_port }};
proxy_set_header Host $http_host; # required for docker client's sake
proxy_set_header X-Real-IP $remote_addr; # pass on real client's IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;