Skip to content

Commit

Permalink
Merge pull request #78 from makasim/docker
Browse files Browse the repository at this point in the history
Docker container.
  • Loading branch information
makasim authored Sep 14, 2016
2 parents fd07eb4 + 66e36ba commit 7fe005d
Show file tree
Hide file tree
Showing 21 changed files with 1,485 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git
!docker/container
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM ubuntu:16.04

RUN mkdir -p /payum /var/log/payum /run/php

## libs
RUN apt-get update && \
apt-get install -y --no-install-recommends wget curl openssl ca-certificates nano && \
apt-get install -y --no-install-recommends php php-fpm php-mysql php-curl php-intl php-soap php-gd php-mbstring php-xml php-ldap php-zip php-mcrypt php-xdebug php-bcmath && \
apt-get install -y --no-install-recommends nginx && \
service nginx stop

RUN apt-get install -y --no-install-recommends supervisor

RUN apt-get install -y --no-install-recommends nodejs npm

RUN rm -f /etc/php/7.0/fpm/pool.d/* && \
rm -f /etc/php/7.0/cli/conf.d/*xdebug.ini && \
rm -f /etc/nginx/sites-enabled/*

COPY ./docker/container/php/payum_cli.ini /etc/php/7.0/cli/conf.d/1-payum_cli.ini
COPY ./docker/container/php/payum_fpm.ini /etc/php/7.0/fpm/conf.d/1-payum_fpm.ini
COPY ./docker/container/php/payum-fpm.conf /etc/php/7.0/fpm/pool.d/payum_fpm.conf
COPY ./docker/container/nginx/payum.dev /etc/nginx/sites-enabled/payum.dev
COPY ./docker/container/supervisor/payum_app.conf /etc/supervisor/conf.d/payum_app.conf
COPY ./docker/container/bin/entrypoint.sh /entrypoint.sh
COPY ./docker/container/phpstorm/ide-phpunit.php /usr/local/bin/ide-phpunit.php
COPY ./docker/container/phpstorm/ide-phpinfo.php /usr/local/bin/ide-phpinfo.php

WORKDIR /payum

CMD /entrypoint.sh
4 changes: 2 additions & 2 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ sonata_block:
doctrine_mongodb:
connections:
default:
server: mongodb://localhost:27017
server: 'mongodb://%mongodb_host%:mongodb_port'
options: {}
default_database: "%database_name%"
default_database: "%mongodb_name%"
document_managers:
default:
auto_mapping: true
Expand Down
4 changes: 4 additions & 0 deletions app/config/parameters.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ parameters:
# You should uncomment this if you want use pdo_sqlite
# database_path: "%kernel.root_dir%/data.db3"

mongodb_host: 127.0.0.1
mongodb_port: 27017
mongodb_name: symfony

mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: ~
Expand Down
16 changes: 8 additions & 8 deletions app/config/routing.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
app:
resource: "@AppBundle/Controller/"
type: annotation

_demo:
resource: "@AcmeDemoBundle/Controller/DemoController.php"
type: annotation
prefix: /demo
_homepage:
path: /
defaults: { _controller: AcmePaymentBundle:Default:index }

payum_capture:
resource: "@PayumBundle/Resources/config/routing/capture.xml"
Expand Down Expand Up @@ -51,6 +46,11 @@ acme_klarna:
resource: "@AcmeKlarnaBundle/Resources/config/routing.yml"
prefix: /

acme_redsys:
resource: "@AcmePaymentBundle/Controller/"
type: annotation
prefix: /

acme_other_examples:
resource: "@AcmeOtherExamplesBundle/Resources/config/routing.yml"
prefix: /
Expand Down
46 changes: 46 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: '2'
services:
web:
build: .
ports:
- "80:80"
depends_on:
- mongodb
- mysql
volumes:
- .:${PAYUM_ROOT_DIR}
- ${PAYUM_ROOT_DIR}/app/cache
- ${PAYUM_ROOT_DIR}/app/logs
environment:
- PAYUM_ROOT_DIR=${PAYUM_ROOT_DIR}
- SYMFONY__ENV_DATABASE_HOST=mysql
- SYMFONY__ENV_DATABASE_PORT=3306
- SYMFONY__ENV_DATABASE_NAME=payum
- SYMFONY__ENV_DATABASE_USER=root
- SYMFONY__ENV_DATABASE_PASSWORD=rootpass
- SYMFONY__ENV_MONGODB_HOST=mongodb
- SYMFONY__ENV_MONGODB_PORT=27017
- SYMFONY__ENV_MONGODB_NAME=payum

mysql:
image: mariadb:10
ports:
- "3306:3306"
volumes:
- ./docker/container/mysql:/etc/mysql/conf.d
- mysql-data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: rootpass

mongodb:
image: mongo:3.0.4
volumes:
- mongo-data:/data/db
ports:
- "27017:27017"

volumes:
mysql-data:
driver: local
mongo-data:
driver: local
5 changes: 5 additions & 0 deletions docker/bin/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

. docker/bin/envs

PAYUM_ROOT_DIR=$PAYUM_ROOT_DIR docker-compose -p $COMPOSE_PROJECT_NAME build $PAYUM_EXTRA_ARGS
5 changes: 5 additions & 0 deletions docker/bin/enter
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

. docker/bin/envs

docker exec -it ${1:-$PAYUM_WEB_CONTAINER} env TERM=xterm /bin/bash
14 changes: 14 additions & 0 deletions docker/bin/envs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

PAYUM_DEBUG=${PAYUM_DEBUG:-false}
if [ "$PAYUM_DEBUG" = true ] ; then
set -x
set -e
fi

PAYUM_ROOT_DIR="$( pwd )"

COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME:-payum}

PAYUM_EXTRA_ARGS="$@"
PAYUM_WEB_CONTAINER=$COMPOSE_PROJECT_NAME"_web_1"
15 changes: 15 additions & 0 deletions docker/bin/php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

. docker/bin/envs

PAYUM_EXTRA_ARGS=$(echo "$PAYUM_EXTRA_ARGS" | sed -e "s/[^ ]*ide-phpunit.php/\/usr\/local\/bin\/ide-phpunit\.php/g")
PAYUM_EXTRA_ARGS=$(echo "$PAYUM_EXTRA_ARGS" | sed -e "s/[^ ]*ide-phpinfo.php/\/usr\/local\/bin\/ide-phpinfo.php/g")


#fix for --filter /::testShouldImplementMessageProcessorInterface( .*)?$/
PAYUM_EXTRA_ARGS=$(echo "$PAYUM_EXTRA_ARGS" | sed -e "s/\/\:\:/\"\/\:\:/g")
PAYUM_EXTRA_ARGS=$(echo "$PAYUM_EXTRA_ARGS" | sed -e "s/\?\$\//\?\$\/\"/g")

IDE_PHPUNIT_ENVS=$(printenv | grep IDE_PHPUNIT | cat)

docker exec -i "$PAYUM_WEB_CONTAINER" /bin/bash -c "cd $(pwd);$IDE_PHPUNIT_ENVS php $PAYUM_EXTRA_ARGS"
5 changes: 5 additions & 0 deletions docker/bin/stop
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

. docker/bin/envs

PAYUM_ROOT_DIR=$PAYUM_ROOT_DIR COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME docker-compose stop $PAYUM_EXTRA_ARGS
5 changes: 5 additions & 0 deletions docker/bin/up
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

. docker/bin/envs

PAYUM_ROOT_DIR=$PAYUM_ROOT_DIR COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME docker-compose up $PAYUM_EXTRA_ARGS
9 changes: 9 additions & 0 deletions docker/container/bin/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

mkdir -p $PAYUM_ROOT_DIR;
(rm -rf /payum && cd / && ln -s $PAYUM_ROOT_DIR payum)

/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf -l /var/log/payum/supervisor.log

tail --pid $$ -F /payum/app/logs/* &
tail --pid $$ -F /var/log/payum/* &
Empty file.
54 changes: 54 additions & 0 deletions docker/container/nginx/payum.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
server {
server_name payum.dev;
root /payum/web;

location / {
# try to serve file directly, fallback to app.php
try_files $uri /app.php$is_args$args;
}
# DEV
# This rule should only be placed on your development environment
# In production, don't include this and don't deploy app_dev.php or config.php
location ~ ^/(app_dev|config)\.php(/|$) {
fastcgi_pass unix:/run/payum-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
# When you are using symlinks to link the document root to the
# current version of your application, you should pass the real
# application path instead of the path to the symlink to PHP
# FPM.
# Otherwise, PHP's OPcache may not properly detect changes to
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
# for more information).
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
# PROD
location ~ ^/app\.php(/|$) {
fastcgi_pass unix:/var/run/payum-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
# When you are using symlinks to link the document root to the
# current version of your application, you should pass the real
# application path instead of the path to the symlink to PHP
# FPM.
# Otherwise, PHP's OPcache may not properly detect changes to
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
# for more information).
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
# Prevents URIs that include the front controller. This will 404:
# http://domain.tld/app.php/some-path
# Remove the internal directive to allow URIs like this
internal;
}

# return 404 for all other php files not matching the front controller
# this prevents access to other php files you don't want to be accessible.
location ~ \.php$ {
return 404;
}

error_log /var/log/payum/nginx_error.log;
access_log /var/log/payum/nginx_access.log;
}
Loading

0 comments on commit 7fe005d

Please sign in to comment.