Last active
March 9, 2020 11:35
-
-
Save YannickFricke/c81e8a3c3418fb6ac35db544ef7241de to your computer and use it in GitHub Desktop.
NGINX + PHP-FPM + Composer + Symfony + Redis
This file contains hidden or 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
--- | |
version: "3.6" | |
services: | |
web: | |
image: nginx:latest | |
container_name: web | |
ports: | |
- 8080:80 | |
volumes: | |
- ./:/app | |
- ./site.conf:/etc/nginx/conf.d/default.conf | |
php: | |
build: . | |
container_name: php | |
volumes: | |
- ./:/app | |
database: | |
image: mysql:5 | |
container_name: database | |
ports: | |
- 3306:3306 | |
environment: | |
MYSQL_ROOT_PASSWORD: root | |
MYSQL_DATABASE: symfony-starter | |
session: | |
image: redis:latest | |
container_name: session | |
ports: | |
- 6379:6379 | |
sessionManager: | |
image: rediscommander/redis-commander:latest | |
container_name: sessionManager | |
environment: | |
REDIS_HOST: session | |
ports: | |
- 8081:8081 | |
This file contains hidden or 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
FROM php:7.4.2-fpm as symfonyStage | |
RUN apt-get update | |
RUN apt-get install -y wget | |
RUN wget https://get.symfony.com/cli/installer -O - | bash | |
RUN mv $HOME/.symfony/bin/symfony /usr/local/bin/symfony | |
FROM php:7.4.2-fpm as composerStage | |
WORKDIR /app | |
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
RUN php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" | |
RUN php composer-setup.php | |
RUN php -r "unlink('composer-setup.php');" | |
FROM php:7.4.2-fpm | |
RUN apt-get update | |
RUN apt-get install -y git libzip-dev unzip | |
RUN docker-php-ext-install zip pdo pdo_mysql | |
COPY --from=symfonyStage /usr/local/bin/symfony /usr/local/bin/symfony | |
COPY --from=composerStage /app/composer.phar /usr/local/bin/composer | |
WORKDIR /app | |
COPY . . | |
RUN composer install |
This file contains hidden or 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
server { | |
index index.php index.html; | |
error_log /var/log/nginx/error.log; | |
access_log /var/log/nginx/access.log; | |
root /app/public; | |
location / { | |
# try to serve file directly, fallback to app.php | |
try_files $uri /index.php$is_args$args; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass php:9000; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment