Skip to content

Latest commit

 

History

History
57 lines (45 loc) · 2.41 KB

README.docker.md

File metadata and controls

57 lines (45 loc) · 2.41 KB

Using tg-archive as Docker container

In examples below we assume that:

  • all files created will be owned by current user, that is why we have --user="$(id -u):$(id -g)" in Docker commands
  • code is in folder /home/user/tg-archive
  • main all sites folder is /home/user/tg-archive/sites This folder will keep all sites in sub-folders, with their DBs, configurations.
  • example site created below will be named test
  • build data will go into folder: /var/www/public/test

Build

  1. Get source code and put it into: /home/user/tg-archive
  2. In terminal cd to folder /home/user/tg-archive
  3. Build tg-archive image:
docker-compose build

Create new site

  1. Make sure folder /home/user/sites exists
  2. Create default site based on templates
 docker run --rm --user="$(id -u):$(id -g)" -v /home/user/sites:/sites tg-archive --new --path=/sites/test
  1. Edit new site configuration, specially set api_id, api_hash and group parameters in file config.yaml

Create session file

Skip this step if file session.session you already created before. Executing below will result in asking you about phone number and code sent you by Telegram

docker run --rm -it --user="$(id -u):$(id -g)" -v /home/user/sites:/sites tg-archive --config=/sites/test/config.yaml --session=/sites/session.session

Download site data

docker run --rm --user="$(id -u):$(id -g)" -v /home/user/sites:/sites tg-archive --config=/sites/test/config.yaml --session=/sites/session.session --sync

For media folder placed at build destination to avoid duplicate and copy media files. Before downloading - create manually folder /var/www/public/test/media

docker run --rm --user="$(id -u):$(id -g)" -v /home/user/sites:/sites -v /var/www/public/test/media:/sites/test/media tg-archive --config=/sites/test/config.yaml --session=/sites/session.session --sync

Build static site (publish)

docker run --rm --user="$(id -u):$(id -g)" -v /home/user/sites:/sites -v /var/www/public/test:/sites/test/site tg-archive --config=/sites/test/config.yaml --build

For media folder placed at build destination to avoid duplicate and copy media files.

docker run --rm --user="$(id -u):$(id -g)" -v /home/user/sites:/sites -v /var/www/public/test:/sites/test/site -v /var/www/public/test/media:/sites/test/media tg-archive --config=/sites/test/config.yaml --build