forked from Dofamin/MTProxy-Docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
61 lines (61 loc) · 3.87 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# OS
FROM ubuntu:latest
# Set version label
LABEL maintainer="github.com/Dofamin"
LABEL image="MTProxy"
LABEL OS="Ubuntu/latest"
COPY container-image-root/ /
# ARG & ENV
ARG SECRET
ENV SECRET=${SECRET:-ec4dd80983dbf12d6b354cf7bcfe9a48}
ARG WORKERS
ENV WORKERS=${WORKERS:-1}
ARG MTPROTO_REPO_URL
ENV MTPROTO_REPO_URL=${MTPROTO_REPO_URL:-https://github.com/TelegramMessenger/MTProxy}
WORKDIR /srv/
ENV TZ=Europe/Moscow
# Update system packages:
RUN apt -y update > /dev/null 2>&1;\
# Fix for select tzdata region
ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone > /dev/null 2>&1;\
dpkg-reconfigure --frontend noninteractive tzdata > /dev/null 2>&1;\
# Install dependencies, you would need common set of tools.
apt -y install git curl build-essential libssl-dev zlib1g-dev cron wget logrotate ntp > /dev/null 2>&1;\
apt install -y gcc-9 g++-9 cpp-9 > /dev/null 2>&1;\
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100 --slave /usr/bin/g++ g++ /usr/bin/g++-9 --slave /usr/bin/gcov gcov /usr/bin/gcov-9 > /dev/null 2>&1;\
# Clone the repo:
IP_EXT=$(curl ifconfig.co/ip -s) ;\
IP_INT=$(hostname --ip-address) ;\
git clone ${MTPROTO_REPO_URL} /srv/MTProxy > /dev/null 2>&1 ;\
# To build, simply run make, the binary will be in objs/bin/mtproto-proxy:
cd /srv/MTProxy ; \
make > /dev/null 2>&1;\
# Obtain a secret, used to connect to telegram servers.
curl -s https://core.telegram.org/getProxySecret -o /srv/MTProxy/objs/bin/proxy-secret > /dev/null 2>&1 ;\
curl -s https://core.telegram.org/getProxyConfig -o /srv/MTProxy/objs/bin/proxy-multi.conf > /dev/null 2>&1 ;\
# Obtain current telegram configuration. It can change (occasionally), so we encourage you to update it once per day.
(crontab -l 2>/dev/null; echo "@daily curl -s https://core.telegram.org/getProxySecret -o /srv/MTProxy/objs/bin/proxy-secret >> /var/log/cron.log 2>&1") | crontab - ;\
(crontab -l 2>/dev/null; echo "@daily curl -s https://core.telegram.org/getProxyConfig -o /srv/MTProxy/objs/bin/proxy-multi.conf >> /var/log/cron.log 2>&1") | crontab - ;\
(crontab -l 2>/dev/null; echo '@daily wget --output-document="/MTProxy/Stats/$(date +%d.%m.%y).log" localhost:8888/stats >> /var/log/cron.log 2>&1') | crontab - ;\
(crontab -l 2>/dev/null; echo '0 4 * * * pkill -f mtproto-proxy >> /var/log/cron.log 2>&1') | crontab - ;\
# Cleanup
apt-get clean > /dev/null 2>&1;\
# Info message for the build
echo -e "\e[1;31m \n\
███╗ ███╗████████╗██████╗ ██████╗ ██████╗ ██╗ ██╗██╗ ██╗ \n\
████╗ ████║╚══██╔══╝██╔══██╗██╔══██╗██╔═══██╗╚██╗██╔╝╚██╗ ██╔╝ \n\
██╔████╔██║ ██║ ██████╔╝██████╔╝██║ ██║ ╚███╔╝ ╚████╔╝ \n\
██║╚██╔╝██║ ██║ ██╔═══╝ ██╔══██╗██║ ██║ ██╔██╗ ╚██╔╝ \n\
██║ ╚═╝ ██║ ██║ ██║ ██║ ██║╚██████╔╝██╔╝ ██╗ ██║ \n\
╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ \e[0m \n\
All is setup and done! \n\
For access MTProxy use this link: \n\
\e[1;33mhttps://t.me/proxy?server=$IP_EXT&port=443&secret=$Secret\e[0m"
# Change WORKDIR
WORKDIR /srv/MTProxy/objs/bin/
# HEALTHCHECK
HEALTHCHECK --interval=60s --timeout=30s --start-period=10s CMD curl -f http://localhost:8888/stats || exit 1
# Expose Ports:
EXPOSE 8889/tcp 8889/udp
# ENTRYPOINT
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]