Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit c4cb165
Author: Alex Borisov <79996669747@ya.ru>
Date:   Fri Nov 29 00:08:14 2024 +0300

    Revert "Squashed commit of the following:"

    This reverts commit b268dec.

commit b268dec
Author: Alex Borisov <79996669747@ya.ru>
Date:   Fri Nov 29 00:00:05 2024 +0300

    Squashed commit of the following:

    commit d9c9dfd
    Author: Alex Borisov <113920954+soaska@users.noreply.github.com>
    Date:   Sun Nov 24 21:05:19 2024 +0300

        Making telegram circles

        Бот в качестве тестовой нагрузки может создавать кружки в телеграме, управляя очередью задач.

        * /status command, new file structure for telegram bot.

        * Custom endpoints. I think its ready to use. Next step:
        create a worker.

        * Ok, now it can make video notes.

        * readme

        ---------

        Co-authored-by: AleX <soaska@cornspace.su>

commit bdd3e88
Author: AleX <soaska@boobook.local>
Date:   Thu Nov 28 23:47:47 2024 +0300

    run with docker

commit c0053e1
Author: AleX <soaska@boobook.local>
Date:   Sun Nov 24 21:12:00 2024 +0300

    Remove junk from repo folder

commit 5651221
Author: AleX <soaska@boobook.local>
Date:   Sun Nov 24 20:57:42 2024 +0300

    readme

commit e041037
Author: AleX <soaska@boobook.local>
Date:   Sun Nov 24 20:34:04 2024 +0300

    Исправлена ошибка обработки цепочки сообщений, исправлено кадрирование

commit c51ad01
Author: AleX <soaska@boobook.local>
Date:   Sat Nov 23 20:27:12 2024 +0300

    ...

commit ea368de
Author: AleX <soaska@boobook.local>
Date:   Sat Nov 23 20:25:22 2024 +0300

    oops..

commit 0954d9b
Author: AleX <soaska@boobook.local>
Date:   Sat Nov 23 20:24:27 2024 +0300

    Ok, now it can make video notes.

commit ceb4d2a
Author: AleX <soaska@boobook.local>
Date:   Sat Nov 23 18:37:13 2024 +0300

    Custom endpoints. I think its ready to use. Next step:
    create a worker.

commit dd21bc1
Author: AleX <soaska@boobook.local>
Date:   Sat Nov 23 16:58:39 2024 +0300

    /status command, new file structure for telegram bot.

commit 14d26b0
Author: AleX <soaska@boobook.local>
Date:   Sat Nov 23 14:30:49 2024 +0300

    Database face job reation now can be called "operational"

commit faea72c
Author: AleX <soaska@boobook.local>
Date:   Sat Nov 23 00:14:41 2024 +0300

    Cleaned go.mod. Now bot can add new users to the database.

commit ade282d
Author: AleX <soaska@boobook.local>
Date:   Fri Nov 22 23:49:23 2024 +0300

    Just day 2 progress. I hope it will work in few days... Unusable.

commit 889b850
Author: AleX <soaska@boobook.local>
Date:   Wed Nov 20 20:29:08 2024 +0300

    Just a snapshot of day1. Pocketbase will be removed.
  • Loading branch information
soaska committed Nov 28, 2024
1 parent d9c9dfd commit a1dd58d
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# Go workspace file
go.work
go.work.sum
.DS_Store

# env file
.env
Expand All @@ -30,3 +31,4 @@ pocketbase/pb_data
notes.txt
cache
docker-compose.yaml
pb_data
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,31 @@
отслеживания ошибок, которые сохраняются в базе данных с графическим интерфейсом. Задачи можно перезапускать,
и они не сбрасываются при перезапуске бота.

# Запуск в контейнере
Скопируем код
```shell
git clone https://github.com/soaska/faceswaper.git
cd faceswaper
```

Заполним окружение
```shell
cp example.env .env
vim .env
```

Запустим pocketbase, удалим существующую коллекцию users, затем перейдем во вкладку
settings / import collections. Далее в меню load from json выбираем [файл](https://github.com/soaska/faceswaper/blob/main/pocketbase/collections/PB%20Schema.json)
`pocketbase/collections/PB Schema.json`
```shell
podman compose up pocketbase
```

Теперь можем запускать бота и воркер.
```shell
podman compose up -d --build
```

# Запуск
Запустим pocketbase по [этой](https://pocketbase.io/docs/) инструкции.
Зайдем во вкладку settings / import collections. Далее в меню load from json выбираем [файл](https://github.com/soaska/faceswaper/blob/main/pocketbase/collections/PB%20Schema.json)
Expand Down Expand Up @@ -49,6 +74,6 @@ go run .
Бот отвечает на сообщения с помощью компонента *telegram-bot*, задачи выполняются *job-manager*.
Компоненты связаны базой данных pocketbase, все операции выполняются через нее, ее наличие
обязательно. Папки `telegram-bot/data` и `job-manager/cache` содержат только временные файлы и
могут быть удалены в период неактивности программы.
могут быть удалены в период неактивности программы. job-manager требует ffmpeg.

По вопросам пишите в [issues](https://github.com/soaska/faceswaper/issues) или на почту soaska@cornspace.su.
34 changes: 34 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
services:
pocketbase:
build:
context: ./pocketbase
dockerfile: Dockerfile
restart: unless-stopped
ports:
- 8080:8080
volumes:
- ./pb_data:/pb/pb_data

telegram-bot:
build:
context: ./job-manager
dockerfile: Dockerfile
environment:
- DOCKER_BUILD=yas
env_file:
- .env
restart: unless-stopped
depends_on:
- pocketbase

job-manager:
build:
context: ./telegram-bot
dockerfile: Dockerfile
environment:
- DOCKER_BUILD=yas
env_file:
- .env
restart: unless-stopped
depends_on:
- pocketbase
9 changes: 9 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# telegram
TELEGRAM_API = https://api.telegram.org
TELEGRAM_APITOKEN = 1294890:asdasfdewioru3o2ier
BOT_DEBUG = false

# pocketbase
POCKETBASE_URL = http://0.0.0.0:8080
POCKETBASE_LOGIN = admin@supermario.carts
POCKETBASE_PASSWORD = MAShsRoOm
12 changes: 12 additions & 0 deletions job-manager/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM golang:latest as builder
WORKDIR /build
COPY ./ ./
RUN go mod download
RUN CGO_ENABLED=0 go build -o ./main


FROM alpine:latest
WORKDIR /app
COPY --from=builder /build/main ./main
RUN apk --no-cache add ca-certificates tzdata ffmpeg
ENTRYPOINT ["./main"]
22 changes: 22 additions & 0 deletions pocketbase/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM alpine:latest

ARG PB_VERSION=0.23.2

RUN apk add --no-cache \
unzip \
ca-certificates

# download and unzip PocketBase
ADD https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_amd64.zip /tmp/pb.zip
RUN unzip /tmp/pb.zip -d /pb/

# uncomment to copy the local pb_migrations dir into the image
COPY ./collections/* /pb/pb_migrations/

# uncomment to copy the local pb_hooks dir into the image
# COPY ./pb_hooks /pb/pb_hooks

EXPOSE 8080

# start PocketBase
CMD ["/pb/pocketbase", "serve", "--http=0.0.0.0:8080"]
12 changes: 12 additions & 0 deletions telegram-bot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM golang:latest as builder
WORKDIR /build
COPY ./ ./
RUN go mod download
RUN CGO_ENABLED=0 go build -o ./main


FROM alpine:latest
WORKDIR /app
COPY --from=builder /build/main ./main
RUN apk --no-cache add ca-certificates tzdata
ENTRYPOINT ["./main"]

0 comments on commit a1dd58d

Please # to comment.