Skip to content

Commit

Permalink
Merge pull request #31 from shyim/add-fpm-base-image
Browse files Browse the repository at this point in the history
docs: change fpm example to symfony demo
  • Loading branch information
shyim authored Apr 7, 2024
2 parents 560f889 + f006f80 commit 3e8b4a5
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,5 @@ To get the excact current version of a package, you can run `apk info php-8.2`.
## Examples

- [Symfony Demo with FrankenPHP](examples/frankenphp-symfony-demo/README.md)
- [Symfony demo with FPM](examples/fpm-symfony-demo/README.md)
- [Nginx + PHP-FPM](examples/nginx-php-fpm/README.md)
- [FPM standalone](examples/fpm/README.md)
52 changes: 52 additions & 0 deletions examples/fpm-symfony-demo/Dockerfile
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" ]
13 changes: 13 additions & 0 deletions examples/fpm-symfony-demo/README.md
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
```
11 changes: 11 additions & 0 deletions examples/fpm-symfony-demo/compose.yaml
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"
44 changes: 44 additions & 0 deletions examples/fpm-symfony-demo/nginx.conf
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;
}
}
15 changes: 0 additions & 15 deletions examples/fpm/Dockerfile

This file was deleted.

3 changes: 0 additions & 3 deletions examples/fpm/README.md

This file was deleted.

0 comments on commit 3e8b4a5

Please sign in to comment.