add container localai
This commit is contained in:
parent
c879f5ae93
commit
1e8484b180
8 changed files with 65 additions and 0 deletions
5
ansible/roles/deploy_container_localai/defaults/main.yml
Normal file
5
ansible/roles/deploy_container_localai/defaults/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
###########
|
||||||
|
# LocalAI #
|
||||||
|
###########
|
||||||
|
container_localai_version: v3.5.0-aio-cpu # https://hub.docker.com/r/localai/localai/tags?name=cpu
|
||||||
|
container_localai_domain: localai.example.com
|
0
ansible/roles/deploy_container_localai/files/.gitkeep
Normal file
0
ansible/roles/deploy_container_localai/files/.gitkeep
Normal file
0
ansible/roles/deploy_container_localai/handlers/main.yml
Normal file
0
ansible/roles/deploy_container_localai/handlers/main.yml
Normal file
0
ansible/roles/deploy_container_localai/meta/main.yml
Normal file
0
ansible/roles/deploy_container_localai/meta/main.yml
Normal file
25
ansible/roles/deploy_container_localai/tasks/main.yml
Normal file
25
ansible/roles/deploy_container_localai/tasks/main.yml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
- name: Ensure data directories exist
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ container_base_dir }}/data/{{ item }}"
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
loop:
|
||||||
|
- "models"
|
||||||
|
become: false
|
||||||
|
|
||||||
|
- name: Deploy Docker Compose and .env files
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: "{{ item.src }}"
|
||||||
|
dest: "{{ container_base_dir }}/{{ item.dest }}"
|
||||||
|
mode: '0644'
|
||||||
|
loop:
|
||||||
|
- { src: 'docker-compose.yml.j2', dest: 'docker-compose.yml' }
|
||||||
|
- { src: '.env.j2', dest: '.env' }
|
||||||
|
become: false
|
||||||
|
|
||||||
|
- name: Start Container
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: "{{ container_base_dir }}"
|
||||||
|
pull: always
|
||||||
|
docker_host: "unix:///run/user/1000/docker.sock"
|
||||||
|
become: false
|
2
ansible/roles/deploy_container_localai/templates/.env.j2
Normal file
2
ansible/roles/deploy_container_localai/templates/.env.j2
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
LOCALAI_VERSION={{ container_localai_version }}
|
||||||
|
LOCALAI_DOMAIN={{ container_localai_domain }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
services:
|
||||||
|
api:
|
||||||
|
image: localai/localai:${LOCALAI_VERSION}
|
||||||
|
container_name: localai
|
||||||
|
networks:
|
||||||
|
- traefik
|
||||||
|
volumes:
|
||||||
|
- ./data/models:/models:cached
|
||||||
|
environment:
|
||||||
|
- DEBUG=true
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
- "traefik.docker.network=traefik"
|
||||||
|
- "traefik.http.routers.localai.entrypoints=http"
|
||||||
|
- "traefik.http.routers.localai.rule=Host(`${LOCALAI_DOMAIN}`)"
|
||||||
|
- "traefik.http.middlewares.localai-https-redirect.redirectscheme.scheme=https"
|
||||||
|
- "traefik.http.routers.localai.middlewares=localai-https-redirect"
|
||||||
|
- "traefik.http.routers.localai-secure.entrypoints=https"
|
||||||
|
- "traefik.http.routers.localai-secure.rule=Host(`${LOCALAI_DOMAIN}`)"
|
||||||
|
- "traefik.http.routers.localai-secure.tls=true"
|
||||||
|
- "traefik.http.routers.localai-secure.service=localai"
|
||||||
|
- "traefik.http.services.localai.loadbalancer.server.port=8080"
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8080/readyz"]
|
||||||
|
interval: 1m
|
||||||
|
timeout: 20m
|
||||||
|
retries: 5
|
||||||
|
|
||||||
|
networks:
|
||||||
|
traefik:
|
||||||
|
external: true
|
1
ansible/roles/deploy_container_localai/vars/main.yml
Normal file
1
ansible/roles/deploy_container_localai/vars/main.yml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
container_base_dir: /opt/docker/localai
|
Loading…
Add table
Reference in a new issue