Post

AI SoMe Automation

Me testing local AI SoMe post generation

AI SoMe Automation

Context

This is a WIP on how to setup AI workflows that will be able to automate SoMe posts. The goal is to publish reals, youtube shorts and tiktoks based on videos and images created from varoius trips.

Setup

1.0 Deploy vm’s

VM 1: AI_SVC

24gb ram 8 cores

VM 2: AI_AUT

16gb ram 4 cores

VM 3: AI_STORAGE

4gb ram 2 cores 200 gb storage

All running ubuntu 24.02 server

AI_SVC

We will install

  • Ollama
  • Open webui
  • Faster Whisper
  • Piper
  • Qdrant
  • LiteLLM (Optional)
1
2
apt update
apt upgrade -y

install docker:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Add Docker's official GPG key:
sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update

sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Make a project folder:

1
2
mkdir -p ~/ai-services
cd ~/ai-services

create folders:

1
2
3
4
5
6
mkdir ollama
mkdir open-webui
mkdir whisper
mkdir piper
mkdir qdrant
mkdir litellm

Create docker compose file:

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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
version: "3.9"

services:

  ollama:
    image: ollama/ollama:latest
    container_name: ollama
    restart: unless-stopped
    ports:
      - "11434:11434"
    volumes:
      - ./ollama:/root/.ollama

  open-webui:
    image: ghcr.io/open-webui/open-webui:main
    container_name: open-webui
    restart: unless-stopped
    ports:
      - "3000:8080"
    volumes:
      - ./open-webui:/app/backend/data
    environment:
      - OLLAMA_BASE_URL=http://ollama:11434
    depends_on:
      - ollama

  faster-whisper:
    image: lscr.io/linuxserver/faster-whisper:latest
    container_name: faster-whisper
    restart: unless-stopped
    ports:
      - "10300:10300"
    volumes:
      - ./whisper:/config

  piper:
    image: lscr.io/linuxserver/piper:latest
    container_name: piper
    restart: unless-stopped
    ports:
      - "10200:10200"
    volumes:
      - ./piper:/data

  qdrant:
    image: qdrant/qdrant
    container_name: qdrant
    restart: unless-stopped
    ports:
      - "6333:6333"
    volumes:
      - ./qdrant:/qdrant/storage

  litellm:
    image: ghcr.io/berriai/litellm:main-latest
    container_name: litellm
    restart: unless-stopped
    ports:
      - "4000:4000"
    command:
      - --host
      - 0.0.0.0

Start everything:

1
docker compose up -d

Install a model: where qwen3:4b is the model at the moment

1
docker exec -it ollama ollama pull qwen3:4b

Troubleshooting:

1
sudo docker exec -it ollama ollama list

Visit http://:3000 this is openwebui, you need to create an admin account, and choose the local model, then ask something and observe the answer - it might take some time - a long time.

AI_AUT

We will install:

On the Automation VM, we’ll install:

Docker n8n FFmpeg Auto-Editor Python (for custom workers)

1
2
3
4
5
6
7
8
9
10
11
sudo mkdir -p /etc/docker/ai-automation


cd /etc/docker/ai-automation
mkdir -p \
  n8n \
  watch \
  scripts \
  ffmpeg \
  auto-editor \
  temp

Create a file named Dockerfile

1
sudo nano Dockerfile

Paste:

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
FROM python:3.12-slim

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
    apt-get install -y \
        ffmpeg \
        git \
        imagemagick \
        curl && \
    rm -rf /var/lib/apt/lists/*

RUN pip install --no-cache-dir \
    fastapi \
    uvicorn \
    auto-editor \
    requests \
    httpx \
    watchdog \
    ffmpeg-python \
    pillow \
    numpy \
    pandas \
    moviepy \
    opencv-python-headless

WORKDIR /app

COPY worker/ /app/

CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]

Create an app in worker directory: ./worker/app.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from fastapi import FastAPI
from pydantic import BaseModel
from jobs import extract_audio

app = FastAPI()

class Job(BaseModel):
    file: str

@app.get("/health")
def health():
    return {"status": "ok"}

@app.post("/extract-audio")
def api_extract_audio(job: Job):
    output = extract_audio(job.file)
    return {"output": output}

creater jobs.py ./worker/jobs.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from fastapi import FastAPI
from pydantic import BaseModel
from jobs import extract_audio

app = FastAPI()

class Job(BaseModel):
    file: str

@app.get("/health")
def health():
    return {"status": "ok"}

@app.post("/extract-audio")
def api_extract_audio(job: Job):
    output = extract_audio(job.file)
    return {"output": output}

Install docker from above step

deploy docker compose:

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
services:

  n8n:
    image: docker.n8n.io/n8nio/n8n:latest
    container_name: n8n
    restart: unless-stopped

    ports:
      - "5678:5678"

    environment:
      TZ: Europe/Copenhagen
      N8N_SECURE_COOKIE: "false"
      N8N_ALLOW_TOOL_USAGE: "true"
      N8N_DEFAULT_BINARY_DATA_MODE: "filesystem"
      N8N_BINARY_DATA_TTL: "0"
      N8N_SECURE_FILE_ACCESS: "true"
      N8N_RESTRICT_FILE_ACCESS_TO: "/workspace"

    volumes:
      - ./n8n:/home/node/.n8n
      - ./worker:/workspace

  worker:
    build: .
    container_name: automation-worker
    restart: unless-stopped

    ports:
      - "8000:8000"

    volumes:
      - ./worker:/workspace
      - ./worker:/app

Build docker:

1
sudo docker compose build

Wait for build to complete then run:

1
sudo docker compose up -d

Test

This post is licensed under CC BY 4.0 by the author.