Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker build added #38

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:17-bullseye-slim AS BUILDER
WORKDIR /usr/src/app
RUN apt update && apt install --no-install-recommends --no-install-suggests -y git ca-certificates python3 python3-pip make build-essential
COPY . ./
RUN ls
#RUN git clone https://github.com/tejado/telegram-nearby-map .
RUN npm install

FROM node:17-bullseye-slim as FINAL
WORKDIR /usr/src/app
COPY --from=BUILDER /usr/src/app ./
#COPY docker_config.js ./config.js
EXPOSE 3000
CMD npm start
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ Requirements: node.js and an Telegram account
6. Look carefully at the output: you will need to confirm your Telegram login
7. Go to http://localhost:3000 and have fun

## Docker

Requirements: docker and docker-compose installed (in new version of docker-cli it's built in syntax instead of `docker-compose` just `docker compose`)
To make session and data presistent I created two mount points for TDlib files. First as cold run start with downloading this repo

1. Copy docker.sample.env to .env and edit file to add your telegram bot id and hash
2. First as a cold run to establish session run `docker-compose run telegram-map` and type in your phone number added to telegram account and then type in your confirmation code, then just exit session with Ctrl+C

If you want to have presistent directories somewhere else go into that directory and run

```docker-compose -f /full/path/to/docker-compose.yml run telegram-map```

3. From now we can start our service with `docker-compose up -d` or `docker-compose -f /full/path/to/docker-compose.yml up -d`
4. Enjoy

## Dependencies
To avoid that you have to build TDLib yourself (https://github.com/tdlib/td#building), I added [tdlib.native](https://github.com/ForNeVeR/tdlib.native/releases) in the lib/tdlib folder. Please note that this is an external dependency that has not been fully reviewed by me!

Expand Down
15 changes: 0 additions & 15 deletions config.example.js

This file was deleted.

15 changes: 15 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var config = {}


// your telegram API credentials
// please go to https://my.telegram.org to create your API credentials
config.telegramApiId = process.env.TELEGRAM_API_ID;
config.telegramApiHash = process.env.TELEGRAM_API_HASH;


// server settings
config.hostname = process.env.HOST || "0.0.0.0";
config.port = process.env.PORT || 3000;


module.exports = config;
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3"
services:
telegram-map:
container_name: telegram-map
build: ./.
environment:
# - HOST=0.0.0.0 # optional this default value is not need to be changed
# - PORT=3000 # optional and if you change this don't forget to change ports below
- TELEGRAM_API_ID=${TELEGRAM_ID} #set before use
- TELEGRAM_API_HASH=${TELEGRAM_HASH} #set before use
volumes:
- $PWD/tmdb:/usr/src/app/_td_database
- $PWD/tmfiles:/usr/src/app/_td_files
# - $PWD/tmlog:/usr/src/app/bot.log #optional
ports:
- 3000:3000 # if default PORT environment changed don't forget to change this as well
2 changes: 2 additions & 0 deletions docker.sample.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
TELEGRAM_ID=
TELEGRAM_HASH=