-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
50 lines (41 loc) · 1.39 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
FROM php:cli-alpine
# PHP ext dependencies
RUN apk add --update --no-cache linux-headers curl-dev libcap imap-dev openssl-dev \
&& docker-php-ext-install sockets \
&& docker-php-ext-install curl
# PHP pecl dependencies
RUN apk add --update --no-cache $PHPIZE_DEPS krb5-dev \
&& pecl install imap \
&& docker-php-ext-enable imap
# create users and configure
RUN setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/php \
&& addgroup -S php && adduser -S php -G php \
&& mkdir -p /home/php/telegram/ \
&& mkdir /home/php/telegram/log
# Owner for bind-mounted directories
RUN apk add --no-cache --virtual .build-deps build-base \
&& echo "#include <sys/types.h>" > /bin/cchown.c \
&& echo "#include <unistd.h>" >> /bin/cchown.c \
&& echo 'int main (void) { setuid(0); return execl("/bin/chown", "chown", "-R", "php:php", "/home/php/telegram/", NULL); }' >> /bin/cchown.c \
&& gcc /bin/cchown.c -o /bin/cchown \
&& chown root:root /bin/cchown \
&& chmod ugo+x /bin/cchown \
&& chmod u+s /bin/cchown \
&& rm /bin/cchown.c \
&& apk del .build-deps
# copy all files
WORKDIR /home/php/telegram/
COPY --chown=php:php . /home/php/telegram/
RUN rm -rf /home/php/telegram/Dockerfile
# set server vars
ENV TELEGRAM_API_TOKEN=tbf \
MAIL_SERVER=tbf \
MAIL_USER=tbf \
MAIL_PW=tbf \
SYSDOMAIN=tbf \
DELETMAILS=tbf
# open port
EXPOSE 80/tcp
# run
CMD ["php","/home/php/telegram/server.php"]
USER php