-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from OpenPlaceGuide/14-optimize-build
#14 optimize build
- Loading branch information
Showing
12 changed files
with
174 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,87 @@ | ||
FROM composer:2.6.6 as composer | ||
FROM composer:latest as composer | ||
|
||
FROM php:8.1-apache-bookworm | ||
COPY . /var/www/html | ||
RUN cd /var/www/html && composer install --no-dev --no-scripts | ||
|
||
|
||
FROM node:22 as node | ||
|
||
COPY . /var/www/html | ||
WORKDIR /var/www/html | ||
RUN npm install && npm run build | ||
|
||
|
||
FROM cgr.dev/chainguard/wolfi-base:latest | ||
|
||
ARG PHP_VERSION=8.1 | ||
|
||
RUN apt-get update && apt-get install -y zip | ||
RUN <<EOF | ||
set -eo pipefail | ||
apk add --no-cache \ | ||
php-${PHP_VERSION}-fpm | ||
adduser -u 82 www-data -D | ||
mkdir -p /var/www/html | ||
chown www-data:www-data /var/www/html | ||
EOF | ||
|
||
RUN apt-get -y update \ | ||
&& apt-get install -y libicu-dev \ | ||
&& docker-php-ext-configure intl \ | ||
&& docker-php-ext-install intl | ||
WORKDIR /var/www/html | ||
ENV PHP_FPM_USER=www-data \ | ||
PHP_FPM_GROUP=www-data \ | ||
PHP_FPM_ACCESS_LOG=/proc/self/fd/2 \ | ||
PHP_FPM_LISTEN=[::]:9000 \ | ||
PHP_FPM_PM=dynamic \ | ||
PHP_FPM_PM_MAX_CHILDREN=5 \ | ||
PHP_FPM_PM_START_SERVERS=2 \ | ||
PHP_FPM_PM_MIN_SPARE_SERVERS=1 \ | ||
PHP_FPM_PM_MAX_SPARE_SERVERS=3 \ | ||
PHP_FPM_PM_MAX_REQUESTS=0 \ | ||
PHP_FPM_PM_STATUS_PATH=/-/fpm/status \ | ||
PHP_FPM_PING_PATH=/-/fpm/ping \ | ||
PHP_ERROR_REPORTING=E_ALL\ | ||
PHP_UPLOAD_MAX_FILESIZE=2M \ | ||
PHP_POST_MAX_SIZE=2M \ | ||
PHP_MAX_EXECUTION_TIME=30 \ | ||
PHP_MEMORY_LIMIT=128M \ | ||
PHP_SESSION_HANDLER=files \ | ||
PHP_SESSION_SAVE_PATH= \ | ||
PHP_SESSION_GC_PROBABILITY=1 | ||
|
||
RUN apt-get install -y \ | ||
nodejs npm \ | ||
libfreetype6-dev \ | ||
libjpeg62-turbo-dev \ | ||
libpng-dev \ | ||
libwebp-dev \ | ||
libxpm-dev \ | ||
zlib1g-dev && \ | ||
docker-php-ext-configure gd --enable-gd --with-webp --with-jpeg \ | ||
--with-xpm --with-freetype && \ | ||
docker-php-ext-install gd | ||
COPY --link docker/rootfs / | ||
|
||
RUN a2enmod rewrite | ||
|
||
ENV LOG_CHANNEL=stderr | ||
ENV PHP_FPM_LISTEN=/tmp/php-fpm.sock \ | ||
PHP_FPM_ACCESS_LOG=/dev/null | ||
|
||
RUN sed -ri -e 's!/var/www/html!/var/www/html/public!g' /etc/apache2/sites-available/*.conf | ||
RUN sed -ri -e 's!/var/www/!/var/www/html/public!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf | ||
RUN <<EOF | ||
set -eo pipefail | ||
apk add --no-cache \ | ||
hivemind \ | ||
nginx | ||
EOF | ||
|
||
RUN sed -ri -e 's!^</!<Directory "/var/www/html/public">\nAllowOverride all\n</Directory>\n</!g' /etc/apache2/sites-available/*.conf | ||
EXPOSE 8000 | ||
|
||
|
||
RUN apk add --no-cache zip php-8.1 php-8.1-intl php-8.1-gd php-8.1-cgi php-8.1-phar php-8.1-iconv php-8.1-mbstring php-8.1-openssl php-8.1-dom | ||
|
||
#ENV LOG_CHANNEL=stderr | ||
|
||
COPY . /var/www/html | ||
|
||
RUN mkdir -p storage/framework/cache/data storage/framework/sessions storage/framework/views | ||
RUN chown -R www-data:www-data /var/www/html/storage || true | ||
RUN chown -R www-data:www-data /var/www/html/bootstrap/cache || true | ||
|
||
COPY --from=composer /var/www/html/vendor /var/www/html/vendor | ||
COPY --from=composer /usr/bin/composer /usr/bin/composer | ||
RUN composer install --no-dev | ||
RUN npm install | ||
RUN npm run build | ||
COPY --from=node /var/www/html/public/build /var/www/html/public/build | ||
|
||
RUN composer dump-autoload | ||
|
||
# RUN npm install | ||
# RUN npm run build | ||
# RUN mkdir -p public/assets \ | ||
# ln -s storage/app/repositories/opg-data-ethiopia/places public/assets/ethiopia | ||
|
||
CMD ["/usr/bin/hivemind", "/etc/Procfile"] | ||
# CMD ["php", "artisan"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM cgr.dev/chainguard/wolfi-base:latest | ||
|
||
WORKDIR /var/www/html | ||
|
||
COPY . . | ||
|
||
RUN apk add --no-cache php-8.1 | ||
|
||
CMD [ "php", "./test_error.php" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
nginx: /usr/sbin/nginx | ||
php-fpm: /usr/sbin/php-fpm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
worker_processes auto; | ||
pid /tmp/nginx.pid; | ||
daemon off; | ||
user www-data; | ||
error_log /dev/fd/2 error; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
client_body_temp_path /tmp/client_body_temp; | ||
proxy_temp_path /tmp/proxy_temp; | ||
fastcgi_temp_path /tmp/fastcgi_temp; | ||
uwsgi_temp_path /tmp/uwsgi_temp; | ||
scgi_temp_path /tmp/scgi_temp; | ||
access_log /dev/fd/1; | ||
|
||
server { | ||
listen 80; | ||
server_name localhost; | ||
|
||
root /var/www/html/public; | ||
index index.php; | ||
include /etc/nginx/mime.types; | ||
|
||
location / { | ||
try_files $uri /index.php$is_args$args; | ||
} | ||
|
||
location ~ \.php$ { | ||
fastcgi_split_path_info ^(.+\.php)(/.+)$; | ||
include fastcgi.conf; | ||
fastcgi_buffers 8 16k; | ||
fastcgi_buffer_size 32k; | ||
fastcgi_read_timeout 300s; | ||
client_body_buffer_size 128k; | ||
fastcgi_pass unix:/tmp/php-fpm.sock; | ||
} | ||
|
||
gzip on; | ||
gzip_min_length 1000; | ||
gzip_proxied expired no-cache no-store private auth; | ||
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
upload_max_filesize = ${PHP_UPLOAD_MAX_FILESIZE} | ||
post_max_size = ${PHP_POST_MAX_SIZE} | ||
max_execution_time = ${PHP_MAX_EXECUTION_TIME} | ||
memory_limit = ${PHP_MEMORY_LIMIT} | ||
|
||
session.save_handler = ${PHP_SESSION_HANDLER} | ||
session.save_path = ${PHP_SESSION_SAVE_PATH} | ||
session.gc_probability = ${PHP_SESSION_GC_PROBABILITY} | ||
|
||
error_log = /dev/fd/2 | ||
log_errors = On |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[www] | ||
user = ${PHP_FPM_USER} | ||
group = ${PHP_FPM_GROUP} | ||
access.log = ${PHP_FPM_ACCESS_LOG} | ||
listen = ${PHP_FPM_LISTEN} | ||
listen.owner = ${PHP_FPM_USER} | ||
listen.group = ${PHP_FPM_GROUP} | ||
pm = ${PHP_FPM_PM} | ||
pm.max_children = ${PHP_FPM_PM_MAX_CHILDREN} | ||
pm.start_servers = ${PHP_FPM_PM_START_SERVERS} | ||
pm.min_spare_servers = ${PHP_FPM_PM_MIN_SPARE_SERVERS} | ||
pm.max_spare_servers = ${PHP_FPM_PM_MAX_SPARE_SERVERS} | ||
pm.max_requests = ${PHP_FPM_PM_MAX_REQUESTS} | ||
|
||
[global] | ||
error_log = /proc/self/fd/2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
phpinfo(); |