diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f491a77 --- /dev/null +++ b/Dockerfile @@ -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 diff --git a/README.md b/README.md index 7d3228f..4b267cf 100644 --- a/README.md +++ b/README.md @@ -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! diff --git a/config.example.js b/config.example.js deleted file mode 100644 index 2ac5db3..0000000 --- a/config.example.js +++ /dev/null @@ -1,15 +0,0 @@ -var config = {} - - -// your telegram API credentials -// please go to https://my.telegram.org to create your API credentials -config.telegramApiId = 123456789; -config.telegramApiHash = ''; - - -// server settings -config.hostname = '127.0.0.1'; -config.port = 3000; - - -module.exports = config; \ No newline at end of file diff --git a/config.js b/config.js new file mode 100644 index 0000000..5d36f4e --- /dev/null +++ b/config.js @@ -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; diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..fbb435e --- /dev/null +++ b/docker-compose.yml @@ -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 diff --git a/docker.sample.env b/docker.sample.env new file mode 100644 index 0000000..a7ee08a --- /dev/null +++ b/docker.sample.env @@ -0,0 +1,2 @@ +TELEGRAM_ID= +TELEGRAM_HASH=