Skip to content

Instantly share code, notes, and snippets.

@yaredc
Last active May 12, 2020 19:42
Show Gist options
  • Save yaredc/18b4f9545aa79c98440e5b3e47cc2cff to your computer and use it in GitHub Desktop.
Save yaredc/18b4f9545aa79c98440e5b3e47cc2cff to your computer and use it in GitHub Desktop.
server {
listen 80;
server_name 127.0.0.1;
root /var/www/public;
index index.php;
client_max_body_size 10M;
access_log /proc/self/fd/1 combined;
error_log /proc/self/fd/2 warn;
#add_header X-UA-Compatible "IE=edge";
#add_header X-XSS-Protection "1; mode=block";
#add_header X-Content-Type-Options "nosniff" always;
#add_header X-Frame-Options "DENY" always;
#add_header Referrer-Policy "strict-origin-when-cross-origin";
#add_header Access-Control-Allow-Origin "*";
#add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
#add_header Content-Security-Policy "font-src data: https://maxcdn.bootstrapcdn.com https://use.fontawesome.com https://cdnjs.cloudflare.com https://code.jquery.com https://themes.googleusercontent.com https://fonts.gstatic.com";
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ /(protected|framework|nbproject|config|data|vendor|.idea|.git) {
access_log off;
log_not_found off;
return 404;
}
location /. {
access_log off;
log_not_found off;
return 404;
}
location ~ \.(gitignore|htaccess|bak|bat|config|cfg|yaml|lock|cache|sql|fla|md|psd|ini|log|sh|inc|swp|mwb|dist|bin|exe|bash)$ {
access_log off;
log_not_found off;
return 404;
}
location ~ \.(js|css|png|jpg|jpeg|gif|svg|swf|ico|pdf|mov|zip|rar|woff|woff2|ttf|html|htm)$ {
access_log off;
log_not_found off;
expires 1w;
try_files $uri =404;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_read_timeout 300;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
FROM app/php:1.0.0
USER root
COPY .docker/dev/cron.sh /root/cron.sh
RUN rm -f /etc/crontabs/root &&\
touch /etc/crontabs/root &&\
chown -R www-data:www-data /var/www &&\
chmod -R 0774 /var/www
CMD ["/root/cron.sh"]
#!/bin/sh
/usr/bin/crontab -u www-data /var/www/crontab
/usr/sbin/crond -d 0 -l 0 -f -L /proc/self/fd/1
version: "3"
volumes:
composer:
npm:
postgres:
rabbitmq:
elasticsearch:
services:
php:
image: app/php:1.0.0
build:
context: .
dockerfile: .docker/dev/php.dockerfile
volumes:
- ./:/var/www
- composer:/home/www-data/.composer
working_dir: /var/www
environment:
XDEBUG_CONFIG: "remote_host=192.168.1.32 remote_enable=1 profiler_enable=0 profiler_output_dir=/var/www/profile"
COMPOSER_MEMORY_LIMIT: "-1"
restart: always
cron:
depends_on:
- php
image: app/cron:1.0.0
build:
context: .
dockerfile: .docker/dev/cron.dockerfile
volumes:
- ./:/var/www
working_dir: /var/www
restart: always
node:
image: app/node:1.0.0
build:
context: .
dockerfile: .docker/dev/node.dockerfile
volumes:
- ./:/var/www
- npm:/root/.npm
working_dir: /var/www
nginx:
depends_on:
- php
image: app/nginx:1.0.0
build:
context: .
dockerfile: .docker/dev/nginx.dockerfile
volumes:
- ./.docker/dev/conf.nginx:/etc/nginx/conf.d/conf.nginx
- ./:/var/www
working_dir: /var/www
ports:
- 80:80
- 90:90
restart: always
postgres:
depends_on:
- php
image: postgres:12.1
ports:
- 5432:5432
volumes:
- postgres:/var/lib/postgresql/data
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
POSTGRES_DB: root
restart: always
rabbitmq:
depends_on:
- php
image: rabbitmq:3.7.17-alpine
volumes:
- rabbitmq:/var/lib/rabbitmq
ports:
- 15672:15672
elasticsearch:
depends_on:
- php
image: docker.elastic.co/elasticsearch/elasticsearch:7.5.1
volumes:
- elasticsearch:/usr/share/elasticsearch/data
environment:
- discovery.type=single-node
ports:
- 9200:9200
restart: always
kibana:
depends_on:
- elasticsearch
image: docker.elastic.co/kibana/kibana:7.5.1
environment:
ELASTICSEARCH_HOSTS: http://elasticsearch:9200
ports:
- 5601:5601
restart: always
logstash:
depends_on:
- kibana
image: docker.elastic.co/logstash/logstash:7.5.1
volumes:
- .docker/dev/logstash/pipeline/logstash.conf:/usr/share/logstash/pipeline/logstash.conf
ports:
- 9600:9600
- 5044:5044
restart: always
filebeat:
depends_on:
- logstash
image: docker.elastic.co/beats/filebeat:7.5.1
volumes:
- .docker/dev/filebeat/filebeat.yml:/usr/share/filebeat/filebeat.yml
- ./data:/var/www/data
restart: always
FROM nginx:1.15.5
RUN apk add --no-cache --virtual .deps tzdata &&\
cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime &&\
echo "Europe/Berlin" > /etc/timezone &&\
echo "nameserver 1.1.1.1" >> /etc/resolv.conf &&\
echo "nameserver 1.0.0.1" >> /etc/resolv.conf &&\
echo "nameserver 8.8.8.8" >> /etc/resolv.conf &&\
echo "nameserver 8.8.4.4" >> /etc/resolv.conf &&\
apk del .deps &&\
apk add --no-cache ca-certificates
COPY .docker/dev/conf.nginx /etc/nginx/conf.d/default.conf
EXPOSE 80 443
FROM node:13.6.0-alpine
RUN apk add --no-cache --virtual .deps tzdata &&\
cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime &&\
echo "Europe/Berlin" > /etc/timezone &&\
echo "nameserver 1.1.1.1" >> /etc/resolv.conf &&\
echo "nameserver 1.0.0.1" >> /etc/resolv.conf &&\
echo "nameserver 8.8.8.8" >> /etc/resolv.conf &&\
echo "nameserver 8.8.4.4" >> /etc/resolv.conf &&\
apk del .deps &&\
apk add --no-cache ca-certificates
WORKDIR /var/www
FROM php:7.4-fpm-alpine
#PRODUCTION LAYER
RUN apk add --no-cache --virtual .deps autoconf tzdata build-base libzip-dev postgresql-dev \
libxml2-dev libxslt-dev libpng-dev zlib-dev freetype-dev jpeg-dev icu-dev oniguruma-dev &&\
docker-php-ext-configure gd --with-freetype --with-jpeg &&\
docker-php-ext-install zip xml xsl mbstring json intl gd pdo pdo_pgsql iconv &&\
echo "date.timezone=Europe/Berlin" >> "$PHP_INI_DIR"/php.ini-production &&\
echo "memory_limit=2048M" >> "$PHP_INI_DIR"/php.ini-production &&\
echo "date.timezone=Europe/Berlin" >> "$PHP_INI_DIR"/php.ini-development &&\
echo "memory_limit=2048M" >> "$PHP_INI_DIR"/php.ini-development &&\
cp "$PHP_INI_DIR"/php.ini-production "$PHP_INI_DIR"/php.ini &&\
echo "php_flag[display_errors]=off" >> /usr/local/etc/php-fpm.conf &&\
echo "php_admin_flag[log_errors]=on" >> /usr/local/etc/php-fpm.conf &&\
echo "php_admin_value[error_log]=/proc/self/fd/2" >> /usr/local/etc/php-fpm.conf &&\
echo "php_admin_value[error_reporting]=E_ALL" >> /usr/local/etc/php-fpm.conf &&\
echo "php_admin_value[display_startup_errors]=off" >> /usr/local/etc/php-fpm.conf &&\
cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime &&\
echo "Europe/Berlin" > /etc/timezone &&\
echo "nameserver 1.1.1.1" >> /etc/resolv.conf &&\
echo "nameserver 1.0.0.1" >> /etc/resolv.conf &&\
echo "nameserver 8.8.8.8" >> /etc/resolv.conf &&\
echo "nameserver 8.8.4.4" >> /etc/resolv.conf &&\
mkdir -p /var/www &&\
chown -R www-data:www-data /var/www &&\
chmod -R 0774 /var/www &&\
apk del .deps &&\
apk add --no-cache oniguruma libzip postgresql-client libxml2 libxslt libpng zlib freetype jpeg icu unzip ca-certificates
WORKDIR /var/www
USER www-data
EXPOSE 9000
#DEVELOPMENT LAYER
USER root
RUN apk add --no-cache --virtual .deps autoconf build-base &&\
pecl install xdebug-2.9.2 &&\
docker-php-ext-enable xdebug &&\
cp "$PHP_INI_DIR"/php.ini-development "$PHP_INI_DIR"/php.ini &&\
echo "xdebug.remote_port=9000" >> "$PHP_INI_DIR"/php.ini &&\
echo "php_flag[display_errors]=on" >> /usr/local/etc/php-fpm.conf &&\
echo "php_admin_value[display_startup_errors]=on" >> /usr/local/etc/php-fpm.conf &&\
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" &&\
php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" &&\
php composer-setup.php &&\
php -r "unlink('composer-setup.php');" &&\
mv composer.phar /bin/composer &&\
chmod a+x /bin/composer &&\
su www-data -s /bin/sh -c "composer global require fxp/composer-asset-plugin" &&\
curl -fLs https://www.phing.info/get/phing-latest.phar > /bin/phing &&\
chmod a+x /bin/phing &&\
apk del .deps &&\
apk add --no-cache git subversion
USER www-data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment