- name: set image fact set_fact: image: gitea.chudnick.com/sam/text-generation:latest - name: set other facts vars: array: "{{ image.split('/', 1) }}" set_fact: repo_tag: "{{ array.1 }}" custom_registry: "{{ docker_registry_url + '/' + docker_registry_username }}" - name: create text-generation directory file: path: "{{ docker_home }}/text-generation" state: directory owner: "{{ docker_username }}" group: "{{ docker_username }}" mode: '0755' - name: create models directory file: path: "{{ docker_home }}/text-generation/models" state: directory owner: "{{ docker_username }}" group: "{{ docker_username }}" mode: '0755' - name: clone text-generation repository notify: - login to docker registry - build text-generation image git: repo: https://gitea.chudnick.com/sam/text-generation-docker dest: "{{ docker_home }}/text-generation/src" - meta: flush_handlers - name: create text-generation network become: yes become_user: "{{ docker_username }}" docker_network: name: "{{ text_generation_network_name }}" docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" driver: bridge ipam_config: - subnet: "{{ text_generation_subnet }}" gateway: "{{ text_generation_gateway }}" - name: create and deploy text-generation container become: yes become_user: "{{ docker_username }}" environment: XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" docker_container: name: "text-generation" hostname: "text-generation" image: "{{ image }}" docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" purge_networks: yes networks: - name: "{{ text_generation_network_name }}" ipv4_address: "{{ text_generation_ipv4 }}" volumes: - "{{ docker_home }}/text-generation/models:/models" ports: - "127.0.0.1:{{ text_generation_external_port }}:7860" - "127.0.0.1:{{ text_generation_api_port }}:5005" - "127.0.0.1:{{ text_generation_api_stream_port }}:5000" command: "--cpu --listen --listen-port 7860 --chat --auto-devices --mlock" state: 'started' recreate: yes restart_policy: unless-stopped - name: deploy nginx configuration notify: restart nginx template: src: "{{ text_generation_nginx_config }}" dest: /etc/nginx/sites-available/text-generation.conf owner: root group: root mode: '0644' - name: symlink site file: src: /etc/nginx/sites-available/text-generation.conf dest: /etc/nginx/sites-enabled/text-generation.conf owner: root group: root state: link