Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

[WIP] Dockerize #38

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/docker-compose.override.yml
/.web-server-pid
/app/config/parameters.yml
/build/
Expand Down
28 changes: 14 additions & 14 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ imports:

framework:
#esi: ~
translator: { fallbacks: ['%locale%'] }
secret: '%secret%'
translator: { fallbacks: ['%env(SYMFONY_LOCALE)%'] }
secret: '%env(SYMFONY_SECRET)%'
router:
resource: '%kernel.project_dir%/app/config/routing.yml'
strict_requirements: ~
Expand All @@ -22,7 +22,7 @@ framework:
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
default_locale: '%locale%'
default_locale: '%env(SYMFONY_LOCALE)%'
trusted_hosts: ~
session:
# http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
Expand All @@ -43,11 +43,11 @@ twig:
doctrine:
dbal:
driver: pdo_mysql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
host: '%env(SYMFONY_DB_HOST)%'
port: '%env(SYMFONY_DB_PORT)%'
dbname: '%env(SYMFONY_DB_NAME)%'
user: '%env(SYMFONY_DB_USERNAME)%'
password: '%env(SYMFONY_DB_PASSWORD)%'
charset: utf8mb4
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
Expand Down Expand Up @@ -77,19 +77,19 @@ doctrine_migrations:

# Swiftmailer Configuration
swiftmailer:
transport: '%mailer_transport%'
host: '%mailer_host%'
username: '%mailer_user%'
password: '%mailer_password%'
transport: '%env(SYMFONY_MAILER_TRANSPORT)%'
host: '%env(SYMFONY_MAILER_HOST)%'
username: '%env(SYMFONY_MAILER_USERNAME)%'
password: '%env(SYMFONY_MAILER_PASSWORD)%'
spool: { type: memory }

fos_user:
db_driver: orm # other valid values are 'mongodb' and 'couchdb'
firewall_name: main
user_class: AppBundle\Entity\User
from_email:
address: "%mailer_user%"
sender_name: "%mailer_user%"
address: "%env(SYMFONY_MAILER_USER)%"
sender_name: "%env(SYMFONY_MAILER_USER)%"
registration:
form:
type: AppBundle\Form\RegistrationFormType
Expand Down
2 changes: 1 addition & 1 deletion app/config/config_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ monolog:
handlers:
main:
type: stream
path: '%kernel.logs_dir%/%kernel.environment%.log'
path: '/tmp/stdout'
level: debug
channels: ['!event']
console:
Expand Down
2 changes: 1 addition & 1 deletion app/config/config_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ monolog:
handler: nested
nested:
type: stream
path: '%kernel.logs_dir%/%kernel.environment%.log'
path: '/tmp/stdout'
level: debug
console:
type: console
Expand Down
22 changes: 0 additions & 22 deletions app/config/parameters.yml.dist

This file was deleted.

4 changes: 0 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
},
"scripts": {
"symfony-scripts": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
Expand All @@ -69,9 +68,6 @@
"symfony-web-dir": "web",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": "NULL"
}
}
63 changes: 63 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
version: '2.2'

services:
app:
build:
dockerfile: docker/app/Dockerfile
context: .
environment:
COMPOSER_ALLOW_SUPERUSER: 1
SYMFONY_ENV: dev
SYMFONY_LOCALE: en
SYMFONY_DB_HOST: mysql
SYMFONY_DB_PORT: 3306
SYMFONY_DB_NAME: tania
SYMFONY_DB_USERNAME: tania
SYMFONY_DB_PASSWORD: tania
SYMFONY_MAILER_TRANSPORT: smtp
SYMFONY_MAILER_HOST: ~
SYMFONY_MAILER_PORT: ~
SYMFONY_MAILER_USERNAME: ~
SYMFONY_MAILER_PASSWORD: ~
SYMFONY_SECRET: ThisTokenIsNotSoSecretChangeIt
volumes:
- '.:/var/www'
- '$HOME/.composer:/var/www/.composer'

nginx:
build:
dockerfile: ./docker/nginx/Dockerfile
context: .
environment:
VIRTUAL_HOST: tania.docker.local
networks:
- default
- gateway
volumes:
- '.:/var/www'
- './docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro'

mysql:
image: 'mysql:5.6'
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: tania
MYSQL_USER: tania
MYSQL_PASSWORD: tania

phpmyadmin:
image: 'phpmyadmin/phpmyadmin:4.7'
environment:
PMA_HOST: mysql
PMA_ABSOLUTE_URI: http://pma.tania.docker.local
MYSQL_ROOT_PASSWORD: root
VIRTUAL_HOST: pma.tania.docker.local
networks:
- default
- gateway

networks:
default:
gateway:
external:
name: 'docker_public'
24 changes: 24 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '2.2'

services:
app:
image: taniabox/tania:latest
environment:
SYMFONY_ENV: prod
SYMFONY_LOCALE: en
SYMFONY_SECRET: ThisTokenIsNotSoSecretChangeIt
SYMFONY_DB_HOST: ~
SYMFONY_DB_PORT: ~
SYMFONY_DB_NAME: ~
SYMFONY_DB_USERNAME: ~
SYMFONY_DB_PASSWORD: ~
SYMFONY_MAILER_TRANSPORT: ~
SYMFONY_MAILER_HOST: ~
SYMFONY_MAILER_PORT: ~
SYMFONY_MAILER_USERNAME: ~
SYMFONY_MAILER_PASSWORD: ~

nginx:
image: taniabox/tania-nginx:latest
depends_on:
- app
23 changes: 23 additions & 0 deletions docker/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM mathewpeterson/php7:7.1.5-fpm

MAINTAINER Mathew Peterson <[email protected]>

ARG BUILD_DATE
ARG VERSION
ARG VCS_URL
ARG VCS_REF

LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="Tania Web Application" \
org.label-schema.description="Build artifact for Tania" \
org.label-schema.url="http://gettania.org/" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/Tanibox/tania.git" \
org.label-schema.vendor="Tania" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0"

ADD . /var/www

VOLUME /var/www/var/cache
WORKDIR /var/www
7 changes: 7 additions & 0 deletions docker/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM nginx:1.12

MAINTAINER Mathew Peterson <[email protected]>

ADD docker/nginx/nginx.conf /etc/nginx/nginx.conf

ADD . /var/www
50 changes: 50 additions & 0 deletions docker/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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";
open_file_cache max=100;

upstream php-upstream { server app:9000; }

server {
root /var/www/web;

location / {
try_files $uri @rewriteapp;
}

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

location ~ ^/(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 HTTPS off;
}

error_log /dev/stdout info;
access_log /dev/stdout;
}
}
18 changes: 9 additions & 9 deletions web/app.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php

use Symfony\Component\Debug\Debug;
use Symfony\Component\HttpFoundation\Request;

/** @var \Composer\Autoload\ClassLoader $loader */
$loader = require __DIR__.'/../vendor/autoload.php';
if (PHP_VERSION_ID < 70000) {
include_once __DIR__.'/../var/bootstrap.php.cache';
}
require __DIR__.'/../vendor/autoload.php';


$kernel = new AppKernel('prod', false);
if (PHP_VERSION_ID < 70000) {
$kernel->loadClassCache();
if ('dev' == getenv('SYMFONY_ENV')) {
Debug::enable();
$kernel = new AppKernel('dev', true);
} else {
$kernel = new AppKernel('prod', false);
//$kernel = new AppCache($kernel);
}
//$kernel = new AppCache($kernel);

// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
//Request::enableHttpMethodParameterOverride();
Expand Down
32 changes: 0 additions & 32 deletions web/app_dev.php

This file was deleted.