at the end of the day, it was inevitable

This commit is contained in:
Mo Elzubeir
2022-12-09 08:36:26 -06:00
commit 1218570914
1768 changed files with 887087 additions and 0 deletions
+252
View File
@@ -0,0 +1,252 @@
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
parameters:
locale: en
framework:
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
translator:
fallback: "%locale%"
csrf_protection: { enabled: false }
validation: { enable_annotations: true }
serializer: { enable_annotations: true }
templating:
engines: ['twig']
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
fragments: ~
http_method_override: true
# Monolog Configuration
monolog:
# Define new channel for errors occurred in api methods.
channels: [ 'api_error', 'es_error', 'queue_command', 'mailer', 'payment_api' ]
handlers:
api_exceptions:
type: rotating_file
path: "%kernel.logs_dir%/%kernel.environment%_api_error.log"
level: debug
# Store log for 10 days.
max_files: 10
channels: [ 'api_error' ]
formatter: 'app.formatter.trace'
# Log all notifications received from elasticsearch.
notification:
type: rotating_file
path: "%kernel.logs_dir%/%kernel.environment%_es_error.log"
level: error
# Store log for 10 days.
max_files: 10
channels: [ 'es_error' ]
formatter: 'api.log_formatter.api_errors'
# Log all notifications received from queue command.
queue_command:
type: rotating_file
path: "%kernel.logs_dir%/%kernel.environment%_queue_command.log"
level: error
# Store log for 10 days.
max_files: 10
channels: [ 'queue_command' ]
formatter: 'app.formatter.trace'
payment_api:
type: rotating_file
path: "%kernel.logs_dir%/payment_api.log"
level: info
# Store log for 10 days.
max_files: 10
channels: [ 'payment_api' ]
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
form_themes:
- 'bootstrap_3_layout.html.twig'
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
options:
1002: 'SET sql_mode=(SELECT REPLACE(@@sql_mode, "ONLY_FULL_GROUP_BY", ""))'
schema_filter: '/^(?!internal_)/'
types:
datetimezone: 'AppBundle\Doctrine\DBAL\Types\DateTimeZoneType'
theme_type: 'UserBundle\Doctrine\DBAL\Types\ThemeTypeEnumType'
notification_type: 'UserBundle\Doctrine\DBAL\Types\NotificationTypeEnumType'
payment_gateway: 'PaymentBundle\Doctrine\DBAL\Types\PaymentGatewayEnumType'
payment_status: 'PaymentBundle\Doctrine\DBAL\Types\PaymentStatusEnumType'
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
default_repository_class: AppBundle\Doctrine\ORM\BaseEntityRepository
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
port: "%mailer_port%"
encryption: tls
spool: { type: memory }
fos_user:
db_driver: orm
firewall_name: main
user_class: UserBundle\Entity\User
use_authentication_listener: false
service:
user_manager: 'user.user_manager'
from_email:
address: 'not used'
sender_name: 'not used'
registration:
form:
type: UserBundle\Form\RegistrationType
name: registration
confirmation:
# Disable standard FOSUserBundle registration confirmation.
# In our application we use different registration logic.
# see UserBundle\EventListener\UserSubscriber::onRegistrationSuccess
enabled: true
template: UserBundle:Registration:email.txt.twig
knp_paginator:
template:
pagination: KnpPaginatorBundle:Pagination:twitter_bootstrap_v3_pagination.html.twig
lexik_jwt_authentication:
private_key_path: '%jwt_private_key_path%'
public_key_path: '%jwt_public_key_path%'
pass_phrase: '%jwt_key_pass_phrase%'
token_ttl: '%jwt_token_ttl%'
gesdinet_jwt_refresh_token:
ttl: 2592000
ttl_update: true
# If not set, refresh token will create default symfony user.
user_provider: authentication_bundle.user_provider
miracode_stripe:
secret_key: "%stripe_secret_key%"
nelmio_cors:
paths:
'^/(api|security)':
allow_credentials: true
allow_origin: [ '*' ]
allow_headers: ['X-Custom-Auth', 'Accept', 'Authorization', 'Content-Type']
allow_methods: [ 'POST', 'PUT', 'GET', 'DELETE' ]
max_age: 3600
ivory_ck_editor:
configs:
default:
toolbar: [ [ 'Cut','Copy','Paste','Undo','Redo' ], [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ], [ 'NumberedList','BulletedList','-','Outdent','Indent','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock' ], [ 'Styles','Format','Font','FontSize' ], [ 'TextColor','BGColor' ] ]
old_sound_rabbit_mq:
connections:
default:
host: '%rabbit_mq.host%'
port: '%rabbit_mq.port%'
user: '%rabbit_mq.username%'
password: '%rabbit_mq.password%'
vhost: '/'
lazy: false
connection_timeout: 3
read_write_timeout: 3
keepalive: false
producers:
documents_fetch:
connection: 'default'
exchange_options:
name: 'documents_fetch'
type: 'direct'
service_alias: 'queue.producer.documents_fetch'
documents_email:
connection: 'default'
exchange_options:
name: 'documents_email'
type: 'direct'
service_alias: 'queue.producer.documents_email'
notifications_fetch:
connection: 'default'
exchange_options:
name: 'notifications_fetch'
type: 'direct'
service_alias: 'queue.producer.notifications_fetch'
notifications_send:
connection: 'default'
exchange_options:
name: 'notifications_send'
type: 'direct'
service_alias: 'queue.producer.notifications_send'
consumers:
documents_fetch:
connection: 'default'
exchange_options:
name: 'documents_fetch'
type: 'direct'
queue_options:
name: 'documents_fetch'
callback: 'queue.consumer.documents_fetch'
documents_email:
connection: 'default'
exchange_options:
name: 'documents_email'
type: 'direct'
queue_options:
name: 'documents_email'
callback: 'queue.consumer.documents_email'
notifications_fetch:
connection: 'default'
exchange_options:
name: 'notifications_fetch'
type: 'direct'
queue_options:
name: 'notifications_fetch'
callback: 'queue.consumer.notifications_fetch'
notifications_send:
connection: 'default'
exchange_options:
name: 'notifications_send'
type: 'direct'
queue_options:
name: 'notifications_send'
callback: 'queue.consumer.notifications_send'
+10
View File
@@ -0,0 +1,10 @@
nelmio_api_doc:
name: 'API documentation'
default_sections_opened: false
sandbox:
body_format:
default_format: json
authentication:
delivery: header
name: Authorization
type: bearer
+35
View File
@@ -0,0 +1,35 @@
imports:
- { resource: config.yml }
- { resource: config_api_doc.yml }
framework:
router:
resource: "%kernel.root_dir%/config/routing_dev.yml"
strict_requirements: true
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: false
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: [!event]
console:
type: console
channels: [!event, !doctrine]
# Log all notifications received from queue command.
queue_command:
level: debug
payment_api:
level: debug
swiftmailer:
delivery_address: "%test.delivery_address%"
logging: '%kernel.debug%'
+27
View File
@@ -0,0 +1,27 @@
imports:
- { resource: config.yml }
#framework:
# validation:
# cache: validator.mapping.cache.doctrine.apc
# serializer:
# cache: serializer.mapping.cache.apc
#doctrine:
# orm:
# metadata_cache_driver: apc
# result_cache_driver: apc
# query_cache_driver: apc
monolog:
handlers:
main:
type: rotating_file
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: error
channels: [!event, !notification, !queue_command, !payment_api]
# Store log for 10 days.
max_files: 10
console:
type: console
channels: [!event, !doctrine]
+24
View File
@@ -0,0 +1,24 @@
imports:
- { resource: config_prod.yml }
- { resource: config_api_doc.yml }
framework:
router:
resource: "%kernel.root_dir%/config/routing_stage.yml"
monolog:
handlers:
main:
type: rotating_file
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
max_files: 10 # Store log for 10 days.
channels: [!event]
console:
type: console
channels: [!event, !doctrine]
# Log all notifications received from queue command.
queue_command:
level: info
+17
View File
@@ -0,0 +1,17 @@
imports:
- { resource: config_dev.yml }
framework:
test: ~
session:
storage_id: session.storage.mock_file
doctrine:
dbal:
dbname: "%database_name%_test"
lexik_jwt_authentication:
token_ttl: 8640 # 1 day
swiftmailer:
delivery_address: "%test.delivery_address%"
+126
View File
@@ -0,0 +1,126 @@
# Stages
set :stages, %w(production demo development staging)
set :default_stage, "development"
set :stage_dir, "app/config/stage"
set :keep_releases, 3
# Capifony settings
require 'capistrano/ext/multistage'
require 'fileutils'
require 'zlib'
# Application
set :application, "socialhose" #application name
set :app_path, "app"
set :web_path, "web"
set :model_manager, "doctrine"
set :deploy_dir, "deploy"
set :log_path, "var/logs"
set :cache_path, "var/cache"
set :session_path, "var/sessions"
set :node_modules_path, "frontend/node_modules"
# Version control
# pass branch as parameter: example: cap development deploy -S branch=origin/development
set :scm, :git
set :repository, "git@github.com:melzubeir/socialhose.git" #application repository URL
set :git_shallow_clone, 1
set :branch, fetch(:branch, '').sub!(/^.*\//, "")
# Directories
set :writable_dirs, [log_path, cache_path, session_path]
set :shared_files, ["app/config/parameters.yml"]
set :shared_children, [log_path, node_modules_path]
# Permissions
set :permission_method, :acl
set :use_set_permissions, true
set :use_sudo, false
set :webserver_user, "apache"
ssh_options[:forward_agent] = true
# Symfony
set :use_composer, true
set :composer_options, "--verbose --prefer-dist --optimize-autoloader --no-progress --no-interaction"
set :update_vendors, false
set :copy_vendors, true
set :dump_assetic_assets, true
set :interactive_mode, false
set :update_cmd, "./update.sh" # will run after deploy
set :clear_controllers, false
set :symfony_env, "dev"
set :symfony_console, "bin/console"
# Custom tasks
namespace :deployment do
desc "Update site config"
task :update_site_config do
capifony_pretty_print "--> Update site config"
run "#{try_sudo} sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} socialhose:site-settings:sync #{console_options}'"
capifony_puts_ok
end
namespace :update_code do
desc "Rewrite parameters"
task :rewrite_params do
capifony_pretty_print "--> Rewriting parameters.yml with app/config/parameters.yml.#{stage}"
run "sh -c 'cd #{latest_release} && cp app/config/parameters.yml.#{stage} app/config/parameters.yml'"
capifony_puts_ok
end
desc "Rewrite .htaccess"
task :rewrite_htaccess do
capifony_pretty_print "--> Rewriting .htaccess with .htaccess.#{stage}"
run "sh -c 'cd #{latest_release} && cp web/.htaccess.#{stage} web/.htaccess'"
capifony_puts_ok
end
end
namespace :frontend do
desc "Rewrite frontend/app/appConfig.js"
task :rewrite_config do
set :file, "frontend/app/appConfig.js"
capifony_pretty_print "--> Rewriting #{file} with #{file}.#{stage}"
run "sh -c 'cd #{latest_release} && cp #{file}.#{stage} #{file}'"
capifony_puts_ok
end
desc "Install node modules"
task :install do
capifony_pretty_print "--> Install node modules"
run "sh -c 'cd #{latest_release}/frontend && npm install'"
capifony_puts_ok
end
desc "Build"
task :build do
capifony_pretty_print "--> Build forntend"
run "sh -c 'cd #{latest_release}/frontend && npm run build'"
capifony_puts_ok
end
end
end
# Dependences
before "symfony:composer:install", "deployment:update_code:rewrite_params"
before "symfony:composer:install", "deployment:update_code:rewrite_htaccess"
before "symfony:composer:install", "deployment:frontend:rewrite_config"
before "symfony:composer:update", "deployment:update_code:rewrite_params"
before "symfony:composer:update", "deployment:update_code:rewrite_htaccess"
before "symfony:composer:update", "deployment:frontend:rewrite_config"
before "symfony:cache:warmup", "symfony:doctrine:migrations:migrate"
after "deployment:frontend:rewrite_config", "deployment:frontend:install"
after "deployment:frontend:install", "deployment:frontend:build"
after "deploy", "deploy:cleanup"
after "deploy:cleanup", "deployment:update_site_config"
# Logging
logger.level = Logger::MAX_LEVEL
+42
View File
@@ -0,0 +1,42 @@
#
# Administrative panel
#
admin:
resource: '@AdminBundle/Controller'
prefix: /admin
#
# First versions of api.
#
api_v1:
resource: 'routing_api_v1.yml'
prefix: /api/v1
#
# Security routes for creating and refreshing JWT tokens and also for
# registration.
#
security:
resource: 'routing_api_security.yml'
prefix: /security
#
# Main application.
#
app:
resource: '@AppBundle/Controller/IndexController.php'
type: annotation
payment:
resource: '@PaymentBundle/Controller/IpnController.php'
type: annotation
prefix: '/billing'
register_finish:
path: '/auth/register-finish'
methods: [ 'GET' ]
defaults:
_controller: 'AppBundle:Index:index'
miracode_stripe:
resource: '@MiracodeStripeBundle/Resources/config/routing.xml'
+17
View File
@@ -0,0 +1,17 @@
user_security:
resource: '@UserBundle/Resources/config/routing/security.yml'
authentication:
resource: '@AuthenticationBundle/Controller/TokenController.php'
type: annotation
fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
fos_user_registration_confirm:
path: /registration/confirm/{token}
defaults: { _controller: user.controller.registration:confirmAction }
fos_user_registration_confirmed:
path: /registration/confirmed
defaults: { _controller: UserBundle:Security:Registration:confirmed }
+5
View File
@@ -0,0 +1,5 @@
app_v1:
resource: '@AppBundle/Resources/config/routing/v1.yml'
user_v1:
resource: '@UserBundle/Resources/config/routing/v1.yml'
+23
View File
@@ -0,0 +1,23 @@
_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_errors:
resource: "@TwigBundle/Resources/config/routing/errors.xml"
prefix: /_error
api_doc:
resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
prefix: /doc
_email:
type: annotation
resource: "@UserBundle/Controller/Developing"
prefix: /developing
_main:
resource: routing.yml
+6
View File
@@ -0,0 +1,6 @@
api_doc:
resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
prefix: /doc
_main:
resource: routing.yml
+68
View File
@@ -0,0 +1,68 @@
security:
encoders:
FOS\UserBundle\Model\UserInterface: bcrypt
role_hierarchy:
# Ordinary users hierarchy.
ROLE_SUBSCRIBER: []
ROLE_MASTER_USER: [ ROLE_SUBSCRIBER ]
# Admins hierarchy.
ROLE_ADMIN: []
ROLE_SUPER_ADMIN: [ ROLE_ADMIN ]
providers:
socialhose_user:
id: authentication_bundle.user_provider
socialhose_admin:
id: fos_user.user_provider.username
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
registration:
pattern: ^/security/registration
stateless: true
anonymous: true
token_create:
pattern: ^/security/token/create
stateless: true
anonymous: true
socialhose_auth: ~
token_refresh:
pattern: ^/security/token/refresh
stateless: true
anonymous: true
api:
pattern: ^/api
stateless: true
provider: socialhose_user
guard:
authenticators:
- lexik_jwt_authentication.jwt_token_authenticator
admin:
pattern: ^/admin
anonymous: ~
provider: socialhose_admin
form_login:
login_path: admin_login
check_path: admin_login_check
target_path_parameter: admin_dashboard
default_target_path: admin_dashboard
logout:
path: admin_logging_out
target: admin_login
access_control:
- { path: ^/security, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/api, roles: IS_AUTHENTICATED_FULLY }
- { path: ^/admin/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin, roles: ROLE_ADMIN }
- { path: ^/, roles: IS_AUTHENTICATED_ANONYMOUSLY }
+8
View File
@@ -0,0 +1,8 @@
imports:
- { resource: '@ApiBundle/Resources/config/services.yml' }
- { resource: '@CacheBundle/Resources/config/services.yml' }
- { resource: '@UserBundle/Resources/config/services.yml' }
- { resource: '@AuthenticationBundle/Resources/config/services.yml' }
- { resource: '@AdminBundle/Resources/config/services.yml' }
- { resource: '@QueueBundle/Resources/config/services.yml' }
- { resource: '@PaymentBundle/Resources/config/services.yml' }
+13
View File
@@ -0,0 +1,13 @@
server "10.1.1.55", :web, :app, :db, :primary => true, :no_release => false
set :deploy_root, "/var/www/html/new/" #project root path on server
set :deploy_to, "#{deploy_root}/#{deploy_dir}"
set :user, "jenkins"
after "deploy:create_symlink" do
capifony_pretty_print "--> run #{update_cmd}"
run "sh -c 'cd #{latest_release}; #{update_cmd}'"
capifony_pretty_print "--> Creating symlimk for web folder"
run "sh -c 'rm -rf #{deploy_root}/web && ln -s #{latest_release}/web #{deploy_root}/web'"
capifony_puts_ok
end
+23
View File
@@ -0,0 +1,23 @@
server "192.168.0.110", :web, :app, :db, :primary => true, :no_release => false
set :deploy_root, "/var/www/html/new" #project root path on server
set :deploy_to, "#{deploy_root}/#{deploy_dir}"
set :user, "socialhose"
ssh_options[:forward_agent] = true
ssh_options[:port] = "22"
set :deploy_via, :rsync_with_remote_cache
set :rsync_options, "--recursive --delete --delete-excluded --exclude .git* --exclude .build*"
set :controllers_to_clear, [ "app_dev.php", "app_test.php" ]
set :symfony_env_prod, "stage"
after "deploy:create_symlink" do
capifony_pretty_print "--> Creating symlimk for web folder"
run "sh -c 'rm -rf #{deploy_root}/web && ln -s #{latest_release}/web #{deploy_root}/web'"
capifony_puts_ok
capifony_pretty_print "--> Restart workers"
run "sh -c 'supervisorctl restart documents_email'"
run "sh -c 'supervisorctl restart documents_fetching'"
run "sh -c 'supervisorctl restart notification_fetching'"
run "sh -c 'supervisorctl restart notification_sending'"
capifony_puts_ok
end
+23
View File
@@ -0,0 +1,23 @@
server "34.228.99.0", :web, :app, :db, :primary => true, :no_release => false
set :deploy_root, "/var/www/socialhose/" #project root path on server
set :deploy_to, "#{deploy_root}/#{deploy_dir}"
set :user, "deploy"
set :branch, "master"
set :webserver_user, "nginx"
set :controllers_to_clear, ['app_dev.php', 'app_test.php', 'app_stage.php']
set :symfony_env_prod, "prod"
set :deploy_via, :rsync_with_remote_cache
set :rsync_options, "--recursive --delete --delete-excluded --exclude .git* --exclude .build*"
after "deploy:create_symlink" do
capifony_pretty_print "--> Creating symlimk for web folder"
run "sh -c 'rm -rf #{deploy_root}/web && ln -s #{latest_release}/web #{deploy_root}/web'"
capifony_puts_ok
capifony_pretty_print "--> Restart workers"
run "sh -c 'supervisorctl restart documents_email:*'"
run "sh -c 'supervisorctl restart documents_fetching:*'"
run "sh -c 'supervisorctl restart notification_fetching:*'"
run "sh -c 'supervisorctl restart notification_sending:*'"
capifony_puts_ok
end