-
Notifications
You must be signed in to change notification settings - Fork 272
/
Dockerfile
186 lines (163 loc) · 5.43 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
FROM php:8.2-fpm AS base
ARG saxon=12.5.0
# Install system dependencies
RUN apt-get update && apt-get install -y \
curl \
default-mysql-client \
fonts-liberation \
fonts-noto-cjk \
fonts-noto-cjk-extra \
fonts-wqy-microhei \
fonts-wqy-zenhei \
git \
gnupg2 \
gosu \
libasound2 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libatspi2.0-0 \
libcups2 \
libdbus-1-3 \
libdrm2 \
libgbm1 \
libgtk-3-0 \
libnspr4 \
libnss3 \
libonig-dev \
libpng-dev \
libwayland-client0 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxkbcommon0 \
libxml2-dev \
libxrandr2 \
supervisor \
unzip \
wget \
xdg-utils \
xfonts-wqy \
zip \
&& if [ "$(dpkg --print-architecture)" = "amd64" ]; then \
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update \
&& apt-get install -y google-chrome-stable; \
fi \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Set permissions for www-data to execute
RUN mkdir -p /var/www/.chrome/chrome-profile \
&& chown -R www-data:www-data /var/www/.chrome \
&& chmod -R 755 /var/www/.chrome \
&& if [ "$(dpkg --print-architecture)" = "amd64" ]; then \
chown root:root /usr/bin/google-chrome \
&& chmod 4755 /usr/bin/google-chrome \
&& chown -R root:root /opt/google/chrome \
&& chmod -R 755 /opt/google/chrome; \
fi \
&& chown -R www-data:www-data /var/www
# Create required directories with proper permissions
RUN mkdir -p /tmp/chrome \
&& if [ "$(dpkg --print-architecture)" = "amd64" ]; then \
chown -R www-data:www-data /tmp/chrome \
&& chmod -R 755 /tmp/chrome; \
fi
# Copy Install PHP extensions installer
#COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
# Install Required PHP extensions.
RUN install-php-extensions \
bcmath \
# curl \ Already installed
exif \
gd \
gmp \
imagick \
# mbstring \ Already installed
mysqli \
opcache \
pcntl \
pdo_mysql \
redis \
# saxon \ outdated
soap \
zip \
@composer
# Configure PHP
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
COPY php/php.ini /usr/local/etc/php/conf.d/app.ini
COPY php/php-fpm.conf /usr/local/etc/php-fpm.d/www.conf
# Configure Saxon
WORKDIR /opt
RUN if [ "$(dpkg --print-architecture)" = "amd64" ]; then \
curl https://downloads.saxonica.com/SaxonC/HE/12/libsaxon-HEC-linux-x86_64-v${saxon}.zip --output saxon.zip \
&& unzip saxon.zip -d saxon \
&& rm saxon.zip \
&& mv saxon/libsaxon-HEC-linux-amd64-v${saxon}/libs/nix/libsaxon-hec-${saxon}.so /usr/lib/ \
&& cd /opt/saxon/libsaxon-HEC-linux-amd64-v${saxon}/Saxon.C.API \
&& phpize \
&& ./configure --enable-saxon \
&& make \
&& make install \
&& rm -rf /opt/saxon \
&& echo 'extension=saxon.so' > "$PHP_INI_DIR/conf.d/saxon.ini"; \
fi
# Copy scripts
COPY rootfs /
# Set working directory
WORKDIR /var/www/html
# Download and extract application
RUN set -eux; \
DOWNLOAD_URL=$(curl -s "https://api.github.com/repos/invoiceninja/invoiceninja/releases/latest" | \
grep -o '"browser_download_url": "[^"]*invoiceninja.tar"' | cut -d '"' -f 4) && \
curl -L "$DOWNLOAD_URL" | tar -xvz -C /var/www/html && \
chown -R www-data:www-data /var/www/html
USER www-data
# Install dependencies
RUN composer install --no-dev --no-scripts --no-autoloader
# Generate optimized autoloader and clear cache
RUN composer dump-autoload --optimize \
&& php artisan optimize \
&& php artisan view:cache \
&& php artisan config:cache \
&& php artisan route:cache \
&& php artisan storage:link
USER root
# Setup supervisor
COPY supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Add initialization script
COPY --chmod=0755 scripts/init.sh /usr/local/bin/init.sh
# Configure PHP-FPM
RUN sed -i "s/user = www-data/user = www-data/g" /usr/local/etc/php-fpm.d/www.conf \
&& sed -i "s/group = www-data/group = www-data/g" /usr/local/etc/php-fpm.d/www.conf
# Create volume directories
RUN mkdir -p \
/var/www/html/storage/app/public \
/var/www/html/storage/framework/cache \
/var/www/html/storage/framework/sessions \
/var/www/html/storage/framework/views \
/var/www/html/storage/logs \
/var/www/html/public/uploads \
/var/run \
/var/log/supervisor
RUN cp /var/www/html/resources/views/react/index.blade.php /var/www/html/public/index.html
# Set permissions
RUN chown -R www-data:www-data \
/var/www/html/storage \
/var/www/html/bootstrap/cache \
/var/www/html/public/uploads \
/var/run \
/var/log/supervisor \
&& chmod -R 775 \
/var/www/html/public/uploads \
/var/www/html/storage \
/var/www/html/bootstrap/cache \
/var/run \
/var/log/supervisor
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD php -v || exit 1
EXPOSE 9000
ENTRYPOINT ["/usr/local/bin/init.sh"]
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]