aboutsummaryrefslogtreecommitdiff
path: root/roles/services/containers/text_generation
diff options
context:
space:
mode:
Diffstat (limited to 'roles/services/containers/text_generation')
-rw-r--r--roles/services/containers/text_generation/handlers/main.yml29
-rw-r--r--roles/services/containers/text_generation/tasks/main.yml89
2 files changed, 118 insertions, 0 deletions
diff --git a/roles/services/containers/text_generation/handlers/main.yml b/roles/services/containers/text_generation/handlers/main.yml
new file mode 100644
index 0000000..7aab823
--- /dev/null
+++ b/roles/services/containers/text_generation/handlers/main.yml
@@ -0,0 +1,29 @@
1- name: login to docker registry
2 become: yes
3 become_user: "{{ docker_username }}"
4 environment:
5 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
6 docker_login:
7 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
8 registry_url: "{{ docker_registry_url }}"
9 username: "{{ docker_registry_username }}"
10 password: "{{ docker_registry_password }}"
11
12- name: build text-generation image
13 become: yes
14 become_user: "{{ docker_username }}"
15 environment:
16 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
17 docker_image:
18 name: "{{ docker_registry_url }}/{{ docker_registry_username }}/text-generation:latest"
19 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
20 build:
21 path: /srv/docker/text-generation/src
22 source: build
23 push: yes
24 force_source: yes
25
26- name: restart nginx
27 service:
28 name: nginx
29 state: restarted
diff --git a/roles/services/containers/text_generation/tasks/main.yml b/roles/services/containers/text_generation/tasks/main.yml
new file mode 100644
index 0000000..80988a6
--- /dev/null
+++ b/roles/services/containers/text_generation/tasks/main.yml
@@ -0,0 +1,89 @@
1- name: set image fact
2 set_fact:
3 image: gitea.chudnick.com/sam/text-generation:latest
4
5- name: set other facts
6 vars:
7 array: "{{ image.split('/', 1) }}"
8 set_fact:
9 repo_tag: "{{ array.1 }}"
10 custom_registry: "{{ docker_registry_url + '/' + docker_registry_username }}"
11
12- name: create text-generation directory
13 file:
14 path: "{{ docker_home }}/text-generation"
15 state: directory
16 owner: "{{ docker_username }}"
17 group: "{{ docker_username }}"
18 mode: '0755'
19
20- name: create models directory
21 file:
22 path: "{{ docker_home }}/text-generation/models"
23 state: directory
24 owner: "{{ docker_username }}"
25 group: "{{ docker_username }}"
26 mode: '0755'
27
28- name: clone text-generation repository
29 notify:
30 - login to docker registry
31 - build text-generation image
32 git:
33 repo: https://gitea.chudnick.com/sam/text-generation-docker
34 dest: "{{ docker_home }}/text-generation/src"
35
36- meta: flush_handlers
37
38- name: create text-generation network
39 become: yes
40 become_user: "{{ docker_username }}"
41 docker_network:
42 name: "{{ text_generation_network_name }}"
43 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
44 driver: bridge
45 ipam_config:
46 - subnet: "{{ text_generation_subnet }}"
47 gateway: "{{ text_generation_gateway }}"
48
49- name: create and deploy text-generation container
50 become: yes
51 become_user: "{{ docker_username }}"
52 environment:
53 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
54 docker_container:
55 name: "text-generation"
56 hostname: "text-generation"
57 image: "{{ image }}"
58 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
59 purge_networks: yes
60 networks:
61 - name: "{{ text_generation_network_name }}"
62 ipv4_address: "{{ text_generation_ipv4 }}"
63 volumes:
64 - "{{ docker_home }}/text-generation/models:/models"
65 ports:
66 - "127.0.0.1:{{ text_generation_external_port }}:7860"
67 - "127.0.0.1:{{ text_generation_api_port }}:5005"
68 - "127.0.0.1:{{ text_generation_api_stream_port }}:5000"
69 command: "--cpu --listen --listen-port 7860 --chat --auto-devices --mlock"
70 state: 'started'
71 recreate: yes
72 restart_policy: unless-stopped
73
74- name: deploy nginx configuration
75 notify: restart nginx
76 template:
77 src: "{{ text_generation_nginx_config }}"
78 dest: /etc/nginx/sites-available/text-generation.conf
79 owner: root
80 group: root
81 mode: '0644'
82
83- name: symlink site
84 file:
85 src: /etc/nginx/sites-available/text-generation.conf
86 dest: /etc/nginx/sites-enabled/text-generation.conf
87 owner: root
88 group: root
89 state: link