-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
119 lines (110 loc) · 5.44 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
FROM debian:buster
LABEL maintainer="mrnaeem@tutanota.com"
# Let the container know that there is no tty
ENV DEBIAN_FRONTEND noninteractive
ENV NGINX_VERSION 1.19.10-1~buster
ENV php_conf /etc/php/8.0/fpm/php.ini
ENV fpm_conf /etc/php/8.0/fpm/pool.d/www.conf
ENV COMPOSER_VERSION 2.0.13
# Install Basic Requirements
RUN buildDeps='curl gcc make autoconf libc-dev zlib1g-dev pkg-config' \
&& set -x \
&& apt-get update \
&& apt-get install --no-install-recommends $buildDeps --no-install-suggests -q -y gnupg2 dirmngr wget apt-transport-https lsb-release ca-certificates \
&& \
NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
found=''; \
for server in \
#ha.pool.sks-keyservers.net \
hkp://keyserver.ubuntu.com:80 \
#hkp://p80.pool.sks-keyservers.net:80 \
pgp.mit.edu \
; do \
echo "Fetching GPG key $NGINX_GPGKEY from $server"; \
apt-key adv --batch --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \
done; \
test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \
echo "deb http://nginx.org/packages/mainline/debian/ buster nginx" >> /etc/apt/sources.list \
&& wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg \
&& echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list \
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -q -y \
apt-utils \
nano \
zip \
unzip \
python-pip \
python-setuptools \
git \
libmemcached-dev \
libmemcached11 \
libmagickwand-dev \
nginx=${NGINX_VERSION} \
php8.0-fpm \
php8.0-cli \
php8.0-bcmath \
php8.0-dev \
php8.0-common \
php8.0-opcache \
php8.0-readline \
php8.0-mbstring \
php8.0-curl \
php8.0-gd \
php8.0-imagick \
php8.0-mysql \
php8.0-zip \
php8.0-pgsql \
php8.0-intl \
php8.0-xml \
php-pear \
&& pecl -d php_suffix=8.0 install -o -f redis memcached \
&& mkdir -p /run/php \
&& pip install wheel \
&& pip install supervisor supervisor-stdout \
&& echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d \
&& rm -rf /etc/nginx/conf.d/default.conf \
&& sed -i -e "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" ${php_conf} \
&& sed -i -e "s/memory_limit\s*=\s*.*/memory_limit = 256M/g" ${php_conf} \
&& sed -i -e "s/upload_max_filesize\s*=\s*2M/upload_max_filesize = 100M/g" ${php_conf} \
&& sed -i -e "s/post_max_size\s*=\s*8M/post_max_size = 100M/g" ${php_conf} \
&& sed -i -e "s/variables_order = \"GPCS\"/variables_order = \"EGPCS\"/g" ${php_conf} \
&& sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php/8.0/fpm/php-fpm.conf \
&& sed -i -e "s/;catch_workers_output\s*=\s*yes/catch_workers_output = yes/g" ${fpm_conf} \
&& sed -i -e "s/pm.max_children = 5/pm.max_children = 4/g" ${fpm_conf} \
&& sed -i -e "s/pm.start_servers = 2/pm.start_servers = 3/g" ${fpm_conf} \
&& sed -i -e "s/pm.min_spare_servers = 1/pm.min_spare_servers = 2/g" ${fpm_conf} \
&& sed -i -e "s/pm.max_spare_servers = 3/pm.max_spare_servers = 4/g" ${fpm_conf} \
&& sed -i -e "s/pm.max_requests = 500/pm.max_requests = 200/g" ${fpm_conf} \
&& sed -i -e "s/www-data/nginx/g" ${fpm_conf} \
&& sed -i -e "s/^;clear_env = no$/clear_env = no/" ${fpm_conf} \
&& echo "extension=redis.so" > /etc/php/8.0/mods-available/redis.ini \
&& echo "extension=memcached.so" > /etc/php/8.0/mods-available/memcached.ini \
&& echo "extension=imagick.so" > /etc/php/8.0/mods-available/imagick.ini \
&& ln -sf /etc/php/8.0/mods-available/redis.ini /etc/php/8.0/fpm/conf.d/20-redis.ini \
&& ln -sf /etc/php/8.0/mods-available/redis.ini /etc/php/8.0/cli/conf.d/20-redis.ini \
&& ln -sf /etc/php/8.0/mods-available/memcached.ini /etc/php/8.0/fpm/conf.d/20-memcached.ini \
&& ln -sf /etc/php/8.0/mods-available/memcached.ini /etc/php/8.0/cli/conf.d/20-memcached.ini \
&& ln -sf /etc/php/8.0/mods-available/imagick.ini /etc/php/8.0/fpm/conf.d/20-imagick.ini \
&& ln -sf /etc/php/8.0/mods-available/imagick.ini /etc/php/8.0/cli/conf.d/20-imagick.ini \
# Install Composer
&& curl -o /tmp/composer-setup.php https://getcomposer.org/installer \
&& curl -o /tmp/composer-setup.sig https://composer.github.io/installer.sig \
&& php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }" \
&& php /tmp/composer-setup.php --no-ansi --install-dir=/usr/local/bin --filename=composer --version=${COMPOSER_VERSION} \
&& rm -rf /tmp/composer-setup.php \
# Clean up
&& rm -rf /tmp/pear \
&& apt-get purge -y --auto-remove $buildDeps \
&& apt-get clean \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*
# Supervisor config
COPY ./supervisord.conf /etc/supervisord.conf
# Override nginx's default config
COPY ./default.conf /etc/nginx/conf.d/default.conf
# Override default nginx welcome page
COPY ./simasjid /usr/share/nginx/html/simasjid
# Copy Scripts
COPY ./start.sh /start.sh
EXPOSE 8080
CMD ["bash", "./start.sh"]