diff --git a/Dockerfile b/Dockerfile index c3858e9..998a8af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM golang:1.19-bookworm AS base RUN apt-get update -run apt-get install -y libssl-dev cmake build-essential gperf libz-dev make git +RUN apt-get install -y libssl-dev cmake build-essential gperf libz-dev make git FROM base AS tdlib @@ -28,9 +28,13 @@ ARG MAKEOPTS WORKDIR /src RUN make ${MAKEOPTS} -FROM scratch AS telegabber +# Build to image +FROM debian:bookworm AS telegabber +RUN apt-get update +RUN apt-get install -y libssl-dev gperf COPY --from=build /src/release/telegabber /usr/local/bin/ +RUN ls -l /usr/local/bin/ ENTRYPOINT ["/usr/local/bin/telegabber"] +CMD ["/usr/local/bin/telegabber", "--help"] + -FROM scratch AS binaries -COPY --from=telegabber /usr/local/bin/telegabber / diff --git a/Makefile b/Makefile index fccaf92..09f4305 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ lint: $(GOPATH)/bin/golint ./... build_indocker: - docker build --build-arg "TD_COMMIT=${TD_COMMIT}" --build-arg "VERSION=${VERSION}" --build-arg "MAKEOPTS=${MAKEOPTS}" --output=release --target binaries . + docker build --build-arg "TD_COMMIT=${TD_COMMIT}" --build-arg "VERSION=${VERSION}" --build-arg "MAKEOPTS=${MAKEOPTS}" -t telegabber:latest . ; docker build -f lighttpd . -t lighttpd:telegabber build_indocker_staging: DOCKER_BUILDKIT=1 docker build --build-arg "TD_COMMIT=${TD_COMMIT}" --build-arg "MAKEOPTS=${MAKEOPTS}" --network host --output=release --target binaries -f staging.Dockerfile . diff --git a/docker/config/config.yml b/docker/config/config.yml new file mode 100755 index 0000000..4fb7fcb --- /dev/null +++ b/docker/config/config.yml @@ -0,0 +1,24 @@ +:telegram: + :loglevel: :warn + :content: + :path: '/data' # webserver workdir + :link: 'https://uploads.porno4free.ru/content' # webserver public address + :upload: 'https://uploads.porno4free.ru' # xmpp http upload address + :tdlib_verbosity: 1 + :tdlib: + :datadir: '/etc/telegabber/db/sessions/' + :client: + :api_id: '11471191' + :api_hash: 'f7667171b1a8f1e2f8f2702a8a09e9d2' + :device_model: 'telegabber' + :application_version: '2.0' + :use_chat_info_database: false + :use_secret_chats: true + +:xmpp: + :loglevel: :warn + :jid: 'btg.porno4free.ru' + :host: 'prosody' + :port: 5347 + :password: 'YCvxuyXYQwpW3Y7IARN' + :db: '/etc/telegabber/db/dbsessions.dat' diff --git a/docker/config/config_schema.json b/docker/config/config_schema.json new file mode 100755 index 0000000..ab25307 --- /dev/null +++ b/docker/config/config_schema.json @@ -0,0 +1,104 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "required": [":telegram", ":xmpp"], + "properties": { + ":telegram": { + "type": "object", + "required": [":loglevel", ":content", ":tdlib"], + "properties": { + ":loglevel": { + "$ref": "#/definitions/non-empty-string" + }, + ":content": { + "type": "object", + "properties": { + ":path": { + "type": "string" + }, + ":link": { + "type": "string" + }, + ":upload": { + "type": "string" + }, + ":user": { + "type": "string" + }, + ":quota": { + "type": "string" + } + } + }, + ":tdlib_verbosity": { + "type": "integer" + }, + ":tdlib": { + "required": [":client"], + "type": "object", + "properties": { + ":datadir": { + "type": "string" + }, + ":client": { + "type": "object", + "required": [":api_id", ":api_hash"], + "properties": { + ":api_id": { + "type": "string", + "pattern": "^[0-9]+$" + }, + ":api_hash": { + "$ref": "#/definitions/non-empty-string" + }, + ":device_model": { + "type": "string" + }, + ":application_version": { + "type": "string" + }, + ":use_chat_info_database": { + "type": "boolean" + }, + ":use_secret_chats": { + "type": "boolean" + } + } + } + } + } + } + }, + ":xmpp": { + "type": "object", + "required": [":loglevel", ":jid", ":host", ":port", ":password", ":db"], + "properties": { + ":loglevel": { + "$ref": "#/definitions/non-empty-string" + }, + ":jid": { + "$ref": "#/definitions/non-empty-string" + }, + ":host": { + "$ref": "#/definitions/non-empty-string" + }, + ":port": { + "type": "integer", + "minimum": 1 + }, + ":password": { + "$ref": "#/definitions/non-empty-string" + }, + ":db": { + "$ref": "#/definitions/non-empty-string" + } + } + } + }, + "definitions": { + "non-empty-string": { + "type": "string", + "minLength": 1 + } + } +} diff --git a/docker/data/test.jpg b/docker/data/test.jpg new file mode 100755 index 0000000..fdd62dd Binary files /dev/null and b/docker/data/test.jpg differ diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100755 index 0000000..f40df5e --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,22 @@ +services: + telegabber: + image: telegabber:latest + container_name: telegabber + volumes: + - ./config:/etc/telegabber/:ro + - ./config/db:etc/telegabber/db:rw + - ./data:/data/:rw + restart: unless-stopped + entrypoint: ["/usr/local/bin/telegabber"] + command: ["-schema", "/etc/telegabber/config_schema.json", "--config", "/etc/telegabber/config.yml"] + + lighttpd: + image: lighttpd:telegabber + container_name: lighttpd-telegabber + volumes: + - ./data:/data:rw + - ./config:/etc/telegabber:ro + ports: + - "80:80" + restart: unless-stopped + diff --git a/lighttpd b/lighttpd new file mode 100644 index 0000000..dafdfd8 --- /dev/null +++ b/lighttpd @@ -0,0 +1,4 @@ +FROM jitesoft/lighttpd +COPY lighttpd.conf /etc/lighttpd/lighttpd.conf +EXPOSE 80 +CMD ["lighttpd", "-D", "-f", "/etc/lighttpd/lighttpd.conf"] diff --git a/lighttpd.conf b/lighttpd.conf new file mode 100644 index 0000000..a8ba5d8 --- /dev/null +++ b/lighttpd.conf @@ -0,0 +1,3 @@ +server.document-root = "/data" +server.port = 80 +index-file.names = ("index.html")