-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile.nginx
126 lines (119 loc) · 4.34 KB
/
Dockerfile.nginx
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
120
121
122
123
124
125
126
FROM php:8.4-fpm
ARG BRANCH=dev
# Install Composer
ENV COMPOSER_VERSION=2.5.5 \
COMPOSER_HOME=/var/www/.composer \
COMPOSER_MEMORY_LIMIT=-1 \
PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}" \
DEBIAN_FRONTEND=noninteractive
WORKDIR /var/www/
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/download/2.7.13/install-php-extensions /usr/local/bin/
RUN set +x \
&& 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 \
&& apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
## Standard
nginx \
libnginx-mod-rtmp \
locales \
locales-all \
git \
gosu \
zip \
unzip \
libzip-dev \
libcurl4-openssl-dev \
m4 \
## Image Optimization
optipng \
pngquant \
jpegoptim \
gifsicle \
## Image Processing
libjpeg62-turbo-dev \
libpng-dev \
libmagickwand-dev \
# Required for GD
libxpm4 \
libxpm-dev \
libwebp7 \
libwebp-dev \
## Video Processing
ffmpeg \
## Database
libpq-dev \
libsqlite3-dev \
mariadb-client \
procps \
telnet \
# Locales Update
&& sed -i '/en_US/s/^#//g' /etc/locale.gen \
&& locale-gen \
&& update-locale \
# Install PHP extensions
&& docker-php-source extract \
# PHP GD extensions
&& docker-php-ext-configure gd \
--with-freetype \
--with-jpeg \
--with-webp \
--with-xpm \
&& docker-php-ext-install gd \
#PHP Imagemagick extensions
&& install-php-extensions imagick \
#PHP Redis extensions
&& pecl install redis \
&& docker-php-ext-enable redis \
#PHP Database extensions
&& docker-php-ext-install pdo_mysql pdo_pgsql pdo_sqlite \
#PHP extensions (dependencies)
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl bcmath zip pcntl exif curl \
#APACHE Bootstrap
# && a2enmod rewrite remoteip \
# && {\
# echo RemoteIPHeader X-Real-IP ;\
# echo RemoteIPTrustedProxy 10.0.0.0/8 ;\
# echo RemoteIPTrustedProxy 172.16.0.0/12 ;\
# echo RemoteIPTrustedProxy 192.168.0.0/16 ;\
# echo SetEnvIf X-Forwarded-Proto "https" HTTPS=on ;\
# } > /etc/apache2/conf-available/remoteip.conf \
# && a2enconf remoteip \
#Cleanup
&& docker-php-source delete \
&& apt-get autoremove --purge -y \
&& apt-get clean \
&& rm -rf /var/cache/apt \
&& rm -rf /var/lib/apt/lists/
RUN cd /var && rm -fr www && git clone https://github.com/pixelfed/pixelfed.git www && cd www && git checkout ${BRANCH}
COPY nginx.conf start.nginx.sh /var/www/contrib/docker/
# Use the default production configuration
COPY php.production.ini "$PHP_INI_DIR/php.ini"
# for detail why storage is copied this way, pls refer to https://github.com/pixelfed/pixelfed/pull/2137#discussion_r434468862
RUN cp -r storage storage.skel \
&& cp -r bootstrap bootstrap.skel \
&& cp /var/www/contrib/docker/nginx.conf /etc/nginx \
&& composer update \
&& composer install --prefer-dist --no-interaction --no-ansi --optimize-autoloader \
&& rm -rf html && ln -s public html \
&& mkdir -p /var/lib/nginx \
&& chown -R www-data:www-data /etc/nginx/nginx.conf /var/www /var/lib/nginx \
&& find /var/www -type d -exec chmod 755 {} \; \
&& find /var/www -type f -exec chmod 644 {} \; \
&& chmod 755 /var/www/contrib/docker/start.nginx.sh \
&& chmod 1777 /run \
&& mkdir -p /run/php-fpm \
&& chown www-data:www-data /run/php-fpm \
&& sed -i 's/listen = 127.0.0.1:9000/listen = \/run\/php-fpm\/php-fpm.sock/' /usr/local/etc/php-fpm.d/www.conf \
# since we're specifing running as the www-data user below, we can remove the following lines from our php-fpm config to avoid a benign warning
&& sed -i '/user = www-data/d' /usr/local/etc/php-fpm.d/www.conf \
&& sed -i '/group = www-data/d' /usr/local/etc/php-fpm.d/www.conf \
&& rm -f /usr/local/etc/php-fpm.d/zz-docker.conf \
&& php artisan storage:link
VOLUME /var/www/storage /var/www/bootstrap
USER www-data
CMD ["/var/www/contrib/docker/start.nginx.sh"]