Skip to content

Commit

Permalink
connect NGINX to services, update server configs, continue backend re…
Browse files Browse the repository at this point in the history
…factoring
  • Loading branch information
utarsuno committed Aug 6, 2019
1 parent 369861b commit dc6af1d
Show file tree
Hide file tree
Showing 220 changed files with 4,916 additions and 4,167 deletions.
126 changes: 80 additions & 46 deletions applications/asset_server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,39 @@ FROM alpine:3.9
# ----------------------------------------------------------------------------------------------------------------
# Base OS libs.
# ----------------------------------------------------------------------------------------------------------------
RUN apk update && apk upgrade && apk --no-cache add bash bash-completion nodejs nodejs-npm curl gzip postgresql-dev \
&& apk add --update alpine-sdk wget coreutils
RUN apk update && apk upgrade && apk add --update --no-cache \
bash bash-completion nodejs nodejs-npm curl gzip postgresql-dev alpine-sdk wget coreutils

# ----------------------------------------------------------------------------------------------------------------
# __ __
# |__) |__| |__)
# | | | |
# |__) |__| |__) Not currently needed ever? {php7-apcu}
# | | | | Not currently needed DB drivers/libs: {php7-sqlite3 php7-mysqli php7-pdo_dblib php7-pdo_odbc}
# ----------------------------------------------------------------------------------------------------------------
RUN apk --no-cache add php7 php7-fpm php7-mysqli php7-json php7-openssl php7-curl php7-zlib php7-xml \
php7-phar php7-intl php7-dom php7-xmlreader php7-ctype php7-mbstring php7-gd php7-common php7-doc php7-ftp \
php7-cgi php7-dev php7-iconv php7-zip php7-session php7-pdo php7-pgsql php7-pdo_pgsql php7-tokenizer
RUN apk add --no-cache \
php7 php7-dev php7-fpm php7-json php7-openssl php7-curl php7-zlib php7-xml php7-phar php7-intl php7-dom \
php7-xmlreader php7-xmlrpc php7-ctype php7-mbstring php7-gd php7-common php7-doc php7-ftp php7-cgi php7-iconv \
php7-zip php7-session php7-pdo php7-pgsql php7-pdo_pgsql php7-opcache php7-mcrypt php7-soap php7-gmp \
php7-tokenizer php7-gettext php7-bz2

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer

# ----------------------------------------------------------------------------------------------------------------
# __
# / ` __|__ __|__
# \__, | |
# ----------------------------------------------------------------------------------------------------------------
#RUN apk add --no-cache libc-dev \
# && apk add --no-cache libressl-dev \
# && apk add --no-cache gcc \
# && apk add --no-cache zlib-dev \
# && apk add --no-cache jpeg-dev \
# && apk add --no-cache boost-dev \
# && apk add --no-cache musl-dev \
# && apk add --no-cache cmake \
# && apk add --no-cache libev-dev \
# && apk add --no-cache linux-headers \
# && apk add --no-cache libtool \
# && apk add --no-cache libsodium-dev \
# && apk add --no-cache utomake

RUN rm /var/cache/apk/*

RUN echo $'[PHP] \n\
zend.multibyte=On \n\
engine=On \n\
short_open_tag=Off \n\
asp_tags=Off \n\
precision=14 \n\
output_buffering=4096 \n\
output_buffering=Off \n\
zlib.output_compression=Off \n\
implicit_flush=Off \n\
serialize_precision=-1 \n\
realpath_cache_size=4096k \n\
realpath_cache_size=4M \n\
realpath_cache_ttl=600 \n\
zend.enable_gc=On \n\
expose_php=Off \n\
max_execution_time=30 \n\
max_execution_time=600 \n\
max_input_time=60 \n\
memory_limit=256M \n\
memory_limit=512M \n\
error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT \n\
display_errors=On \n\
display_startup_errors=On \n\
Expand All @@ -68,12 +51,12 @@ variables_order="S" \n\
request_order="GP" \n\
register_argc_argv=On \n\
auto_globals_jit=On \n\
enable_post_data_reading=Off \n\
post_max_size=8M \n\
enable_post_data_reading=On \n\
post_max_size=64M \n\
include_path = ".:/usr/share/php7" \n\
enable_dl = Off \n\
file_uploads=On \n\
upload_max_filesize=2M \n\
upload_max_filesize=100M \n\
max_file_uploads=20 \n\
allow_url_fopen=On \n\
allow_url_include=Off \n\
Expand All @@ -99,7 +82,7 @@ pgsql.allow_persistent=On \n\
pgsql.auto_reset_persistent=On \n\
pgsql.max_persistent=-1 \n\
pgsql.max_links=-1 \n\
pgsql.ignore_notice=1 \n\
pgsql.ignore_notice=0 \n\
pgsql.log_notice=1 \n\
[bcmath] \n\
bcmath.scale=0 \n\
Expand All @@ -112,13 +95,13 @@ session.name=PHPSESSID \n\
session.auto_start=-1\n\
session.serialize_handler = php \n\
session.gc_probability=1 \n\
session.gc_divisor=1000 \n\
session.gc_divisor=100 \n\
session.gc_maxlifetime=1440 \n\
session.cache_limiter=nocache \n\
session.cache_limiter=public \n\
session.cache_expire=180 \n\
session.use_trans_sid=0 \n\
[Assertion] \n\
zend.assertions=-1 \n\
zend.assertions=1 \n\
[Tidy] \n\
tidy.clean_output=Off \n\
[soap] \n\
Expand All @@ -131,15 +114,66 @@ ldap.max_links=-1 \n\
[opcache] \n\
opcache.enable=1 \n\
opcache.enable_cli=1 \n\
opcache.file_cache_only=1 \n\
opcache.file_cache=/tmp/php-opcache \n\
opcache.optimization_level=15 \n\
opcache.opt_debug_level=0x20000 \n\
opcache.max_file_size=0 \n\
opcache.huge_code_pages=1 \n\
opcache.file_cache_consistency_checks=1 \n\
opcache.validate_permission=0 \n\
opcache.file_cache_only=0 \n\
opcache.file_cache=/quasar_source/var/opcache \n\
opcache.validate_timestamps=1 \n\
opcache.enable_file_override=1 \n\
opcache.revalidate_freq=0 \n\
op.cache.revalidate_path=1 \n\
opcache.max_accelerated_files=20000 \n\
opcache.memory_consumption=192 \n\
opcache.max_wasted_percentage=10 \n\
opcache.revalidate_path=1 \n\
opcache.max_accelerated_files=50000 \n\
opcache.memory_consumption=64 \n\
opcache.max_wasted_percentage=15 \n\
opcache.interned_strings_buffer=16 \n\
opcache.fast_shutdown=1\n' > /etc/php7/php.ini
opcache.fast_shutdown=1 \n\
' > /etc/php7/php.ini

RUN wget https://get.symfony.com/cli/installer -O - | bash
RUN mv /root/.symfony/bin/symfony /usr/local/bin/symfony
ENV PATH="$HOME/.symfony/bin:$PATH"

# ----------------------------------------------------------------------------------------------------------------
# __
# / ` __|__ __|__
# \__, | |
# ----------------------------------------------------------------------------------------------------------------
#RUN apk add --no-cache libc-dev \
# && apk add --no-cache libressl-dev \
# && apk add --no-cache gcc \
# && apk add --no-cache zlib-dev \
# && apk add --no-cache jpeg-dev \
# && apk add --no-cache boost-dev \
# && apk add --no-cache musl-dev \
# && apk add --no-cache cmake \
# && apk add --no-cache libev-dev \
# && apk add --no-cache linux-headers \
# && apk add --no-cache libtool \
# && apk add --no-cache libsodium-dev \
# && apk add --no-cache utomake

RUN rm /var/cache/apk/*

RUN apk add --no-cache shadow && adduser -S _www -u 1000 && groupadd _www


#https://stackoverflow.com/questions/49955097/how-do-i-add-a-user-when-im-using-alpine-as-a-base-image
#ENV USER=docker
#ENV UID=12345
#ENV GID=23456
#RUN addgroup --gid "$GID" "$USER" \
# && adduser \
# --disabled-password \
# --gecos "" \
# --home "$(pwd)" \
# --ingroup "$USER" \
# --no-create-home \
# --uid "$UID" \
# "$USER"


CMD ["bash", "/quasar_source/applications/asset_server/src/asset_server.sh"]
3 changes: 0 additions & 3 deletions applications/asset_server/code_manager/.env.dist

This file was deleted.

3 changes: 0 additions & 3 deletions applications/asset_server/code_manager/.env.test

This file was deleted.

4 changes: 4 additions & 0 deletions applications/asset_server/code_manager/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
.phpunit
/phpunit.xml
###< symfony/phpunit-bridge ###

###> symfony/web-server-bundle ###
/.web-server-pid
###< symfony/web-server-bundle ###
12 changes: 7 additions & 5 deletions applications/asset_server/code_manager/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@
"symfony/orm-pack" : "^1.0",
"symfony/phpunit-bridge" : "4.*",
"symfony/process" : "4.*",
"symfony/yaml" : "4.*"
"symfony/yaml" : "4.*",
"symfony/web-server-bundle": "4.2.*"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": false
"sort-packages": false,
"optimize-autoloader": true,
"classmap-authoritative": true,
"apcu-autoloader": false
},
"autoload": {
"psr-4": {
Expand All @@ -37,9 +41,7 @@
},
"autoload-dev": {
"psr-4": {
"CodeManager\\": "src/",
"CodeManager\\Tests\\": "tests/",
"QuasarSource\\": "./../../../libraries/php/"
"CodeManager\\Tests\\": "tests/"
}
},
"replace": {
Expand Down
26 changes: 10 additions & 16 deletions applications/asset_server/code_manager/config/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
<?php declare(strict_types=1);

use Symfony\Component\Dotenv\Dotenv;

require dirname(__DIR__).'/vendor/autoload.php';

// Load cached env vars if the .env.local.php file exists
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) {
$_ENV += $env;
} else if (!class_exists(Dotenv::class)) {
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
} else {
// load all the .env files
(new Dotenv(false))->loadEnv(dirname(__DIR__).'/.env');
}

# ----------------------------------- {A U T O G E N E R A T E D C O D E}:{0x0} ------------------------------------
$_ENV += [
'APP_ENV' => 'dev',
'KERNEL_CLASS' => 'CodeManager\Kernel',
'APP_SECRET' => 's$cretf0rt3st',
'SYMFONY_DEPRECATIONS_HELPER' => '999999',
'YES' => 'HELLO!',
];
# --------------------------------------------------- {E N D}:{0x0} ----------------------------------------------------
$_SERVER += $_ENV;
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
3 changes: 2 additions & 1 deletion applications/asset_server/code_manager/config/bundles.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php declare(strict_types=1);
<?php

return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true],
];
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@ monolog:
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: ["!event"]
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine", "!console"]
channels: ["!event", "!doctrine", "!console"] #["!event", "!doctrine", "!console"]
deprecation:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.deprecations.log"
deprecation_filter:
type: filter
handler: deprecation
max_level: info
channels: ["php"]
8 changes: 0 additions & 8 deletions applications/asset_server/code_manager/config/routes.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +0,0 @@
qa_test:
path: /qa_test
controller: CodeManager\Controller\QAController::test_response

run_unit_tests:
path: /run_unit_tests
controller: CodeManager\Controller\QAController::run_unit_tests

21 changes: 21 additions & 0 deletions applications/asset_server/code_manager/php/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php declare(strict_types=1);

use CodeManager\Kernel;
use Symfony\Component\Debug\Debug;
use Symfony\Component\HttpFoundation\Request;
require dirname(__DIR__).'/config/bootstrap.php';
if ($_SERVER['APP_DEBUG']) {
umask(0000);
Debug::enable();
}
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
Request::setTrustedHosts([$trustedHosts]);
}
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
6 changes: 6 additions & 0 deletions applications/asset_server/code_manager/php/test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
declare(strict_types=1);


var_dump('hi');

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions applications/asset_server/code_manager/public/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

use CodeManager\Kernel;
use Symfony\Component\Debug\Debug;
Expand All @@ -8,18 +8,14 @@

if ($_SERVER['APP_DEBUG']) {
umask(0000);

Debug::enable();
}

if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}

if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
Request::setTrustedHosts([$trustedHosts]);
}

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
Expand Down
Loading

0 comments on commit dc6af1d

Please sign in to comment.