-
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 #31 from shyim/add-fpm-base-image
docs: change fpm example to symfony demo
- Loading branch information
Showing
7 changed files
with
121 additions
and
19 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# runtime dependencies | ||
FROM ghcr.io/shyim/wolfi-php/fpm:8.2 as base | ||
ENV APP_ENV=prod | ||
|
||
RUN apk add --no-cache \ | ||
php-8.2-intl \ | ||
php-8.2-simplexml \ | ||
php-8.2-iconv \ | ||
php-8.2-dom \ | ||
php-8.2-xml \ | ||
php-8.2-simplexml \ | ||
php-8.2-pdo \ | ||
php-8.2-pdo_sqlite | ||
|
||
# download symfony demo and build it | ||
FROM base as composer | ||
|
||
RUN apk add --no-cache \ | ||
git \ | ||
composer \ | ||
unzip \ | ||
php-8.2 \ | ||
php-8.2-curl \ | ||
php-8.2-openssl \ | ||
php-8.2-phar | ||
|
||
WORKDIR /app | ||
RUN git clone https://github.com/symfony/demo.git --depth=1 . | ||
RUN composer install | ||
RUN bin/console asset-map:compile | ||
RUN rm -rf .git | ||
|
||
# build fpm | ||
FROM base as fpm | ||
|
||
COPY --link --from=composer --chown=82 /app /var/www/html | ||
|
||
# build nginx | ||
FROM cgr.dev/chainguard/wolfi-base as nginx | ||
|
||
RUN <<EOF | ||
set -eo pipefail | ||
apk add --no-cache nginx | ||
adduser -u 82 www-data -D | ||
chown -R www-data:www-data /var/lib/nginx | ||
EOF | ||
|
||
COPY --link nginx.conf /etc/nginx/nginx.conf | ||
COPY --link --from=composer --chown=82 /app/public /var/www/html/public | ||
USER www-data | ||
|
||
CMD [ "/usr/sbin/nginx" ] |
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,13 @@ | ||
# FPM | ||
|
||
This example uses two containers to run a Symfony application with PHP-FPM and Nginx. | ||
|
||
The base fpm is can be [found here](../../images/fpm). | ||
|
||
We build in the `Dockerfile` the PHP-FPM container and setup a small nginx container. | ||
|
||
The traffic is as follows: | ||
|
||
``` | ||
Browser -> Nginx -> 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,11 @@ | ||
services: | ||
fpm: | ||
build: | ||
context: . | ||
target: fpm | ||
nginx: | ||
build: | ||
context: . | ||
target: nginx | ||
ports: | ||
- "8000:8000" |
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,44 @@ | ||
worker_processes auto; | ||
pid /tmp/nginx.pid; | ||
daemon off; | ||
|
||
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; | ||
|
||
server { | ||
listen 8000; | ||
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 fpm:9000; | ||
} | ||
|
||
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.