Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
piterssson committed Nov 4, 2018
0 parents commit df19017
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Symfony application's path (absolute or relative)
SYMFONY_APP_PATH=./src/

# MySQL
MYSQL_ROOT_PASSWORD=root
MYSQL_DATABASE=sulu
MYSQL_USER=sulu
MYSQL_PASSWORD=sulu

# MySQL test
TEST_MYSQL_ROOT_PASSWORD=root_test
TEST_MYSQL_DATABASE=sulu_test
TEST_MYSQL_USER=sulu_test
TEST_MYSQL_PASSWORD=sulu_test

# Timezone
TIMEZONE=Europe/Paris
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea
.data
data
logs
64 changes: 64 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
version: '2'

services:
db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
ports:
- 8989:3306
db_test:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: ${TEST_MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${TEST_MYSQL_DATABASE}
MYSQL_USER: ${TEST_MYSQL_USER}
MYSQL_PASSWORD: ${TEST_MYSQL_PASSWORD}
ports:
- 8990:3306
php:
build:
context: docker/php7-fpm
args:
TIMEZONE: ${TIMEZONE}
volumes:
- ${SYMFONY_APP_PATH}:/var/www/symfony
- ./logs/symfony:/var/www/symfony/app/logs
links:
- db:db
- db_test:db_test
nginx:
build: docker/nginx
ports:
- 80:80
volumes_from:
- php
volumes:
- ./logs/nginx/:/var/log/nginx
phpmyadmin:
image: phpmyadmin/phpmyadmin
environment:
- PMA_ARBITRARY=1
- PMA_HOST=db
- PMA_USER=${MYSQL_USER}
- PMA_PASSWORD=${MYSQL_PASSWORD}
restart: always
ports:
- 181:80
volumes:
- /sessions
phpmyadmin_test:
image: phpmyadmin/phpmyadmin
environment:
- PMA_ARBITRARY=1
- PMA_HOST=db_test
- PMA_USER=${TEST_MYSQL_USER}
- PMA_PASSWORD=${TEST_MYSQL_PASSWORD}
restart: always
ports:
- 183:80
volumes:
- /sessions
21 changes: 21 additions & 0 deletions docker/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM debian:jessie

MAINTAINER Maxence POUTORD <[email protected]>

RUN apt-get update && apt-get install -y \
nginx

ADD nginx.conf /etc/nginx/
ADD symfony.conf /etc/nginx/sites-available/

RUN ln -s /etc/nginx/sites-available/symfony.conf /etc/nginx/sites-enabled/symfony
RUN rm /etc/nginx/sites-enabled/default

RUN echo "upstream php-upstream { server php:9000; }" > /etc/nginx/conf.d/upstream.conf

RUN usermod -u 1000 www-data

CMD ["nginx"]

EXPOSE 80
EXPOSE 443
29 changes: 29 additions & 0 deletions docker/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
worker_connections 2048;
multi_accept on;
use epoll;
}

http {
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 15;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log off;
error_log off;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
open_file_cache max=100;
}

daemon off;
47 changes: 47 additions & 0 deletions docker/nginx/symfony.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
server {
server_name symfony.local;
root /var/www/symfony/web;

error_log /var/log/nginx/project_error.log;
access_log /var/log/nginx/project_access.log;

# strip app.php/ prefix if it is present
rewrite ^/app\.php/?(.*)$ /$1 permanent;

location /admin {
index admin.php;
try_files $uri @rewriteadmin;
}

location @rewriteadmin {
rewrite ^(.*)$ /admin.php/$1 last;
}

location / {
index website.php;
try_files $uri @rewritewebsite;
}

# expire
location ~* \.(?:ico|css|js|gif|jpe?g|png|svg|woff|woff2|eot|ttf)$ {
try_files $uri /website.php/$1?$query_string;
access_log off;
expires 30d;
add_header Pragma public;
add_header Cache-Control "public";
}

location @rewritewebsite {
rewrite ^(.*)$ /website.php/$1 last;
}

# pass the PHP scripts to FastCGI server from upstream phpfcgi
location ~ ^/(website|admin|app|app_dev|config)\.php(/|$) {
fastcgi_pass php-upstream;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SYMFONY_ENV dev;
fastcgi_param HTTPS off;
}
}
45 changes: 45 additions & 0 deletions docker/php7-fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM php:7.2-fpm
ARG TIMEZONE

MAINTAINER Maxence POUTORD <[email protected]>

RUN apt-get update && apt-get install -y \
openssl \
git \
unzip \
libpng-dev \
zlib1g-dev \
zip && docker-php-ext-install zip

# Set timezone
RUN ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && echo ${TIMEZONE} > /etc/timezone
RUN printf '[PHP]\ndate.timezone = "%s"\n', ${TIMEZONE} > /usr/local/etc/php/conf.d/tzone.ini
RUN "date"

# Type docker-php-ext-install to see available extensions
RUN docker-php-ext-install pdo pdo_mysql

# Install Composer
RUN curl --insecure https://getcomposer.org/composer.phar -o /usr/bin/composer && chmod +x /usr/bin/composer

RUN echo "memory_limit = -1" \
> /usr/local/etc/php/conf.d/php.ini

RUN docker-php-ext-install gd

# install xdebug
RUN pecl install xdebug
RUN docker-php-ext-enable xdebug
RUN echo "error_reporting = E_ALL" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "display_startup_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "display_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_connect_back=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.idekey=\"docker\"" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini


RUN echo 'alias sf="php app/console"' >> ~/.bashrc
RUN echo 'alias sf3="php bin/console"' >> ~/.bashrc

WORKDIR /var/www/symfony

0 comments on commit df19017

Please sign in to comment.