forked from mapasculturais/mapasculturais
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adiciona RoadRunner como alternativa de web server
- Loading branch information
Showing
17 changed files
with
477 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
RR_VERSION=2024.1.0 | ||
PHP_IMAGE_VERSION=8.1-cli-alpine | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
$psr17Factory = new Nyholm\Psr7\Factory\Psr17Factory(); | ||
$containerBuilder = new DI\ContainerBuilder(); | ||
$containerBuilder->addDefinitions([ | ||
Psr\Http\Message\ResponseFactoryInterface::class => $psr17Factory, | ||
Psr\Http\Message\ServerRequestFactoryInterface::class => $psr17Factory, | ||
Psr\Http\Message\StreamFactoryInterface::class => $psr17Factory, | ||
Psr\Http\Message\UploadedFileFactoryInterface::class => $psr17Factory, | ||
Spiral\RoadRunner\WorkerInterface::class => Spiral\RoadRunner\Worker::create(), | ||
Spiral\RoadRunner\Http\PSR7WorkerInterface::class => DI\autowire(Spiral\RoadRunner\Http\PSR7Worker::class), | ||
]); | ||
$container = $containerBuilder->build(); | ||
|
||
$app = DI\Bridge\Slim\Bridge::create($container); | ||
// define routes | ||
$app->get('/', function (Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response) { | ||
$config = require_once(__DIR__ . '/src/conf/config.php'); | ||
$container2 = MapasCulturais\App::i('web'); | ||
$container2->init($config); | ||
|
||
return $container2->run(); | ||
// $response->getBody()->write('Hello world from RoadRunner and Slim!'); | ||
// return $response; | ||
}); | ||
|
||
// set routing error handling | ||
$app->add(App\ErrorHandlingMiddleware::class); | ||
|
||
return $app; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
$__process_assets = false; | ||
|
||
return [ | ||
/* MAIN */ | ||
'themes.active' => 'MapasCulturais\Themes\BaseV2', | ||
'app.mode' => $_ENV['APP_MODE'], | ||
'doctrine.isDev' => false, // deixe true somente se estiver trabalhando nos mapeamentos das entidades | ||
|
||
/* SELOS */ | ||
'app.verifiedSealsIds' => [1], | ||
|
||
/* ASSET MANAGER */ | ||
'themes.assetManager' => new \MapasCulturais\AssetManagers\FileSystem([ | ||
'publishPath' => BASE_PATH . 'assets/', | ||
|
||
'mergeScripts' => $__process_assets, | ||
'mergeStyles' => $__process_assets, | ||
|
||
'process.js' => !$__process_assets ? | ||
'cp {IN} {OUT}': | ||
'terser {IN} --source-map --output {OUT} ', | ||
|
||
'process.css' => !$__process_assets ? | ||
'cp {IN} {OUT}': | ||
'uglifycss {IN} > {OUT}', | ||
|
||
'publishFolderCommand' => 'cp -R {IN} {PUBLISH_PATH}{FILENAME}' | ||
]), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
return [ | ||
'auth.provider' => 'Fake', | ||
// 'auth.provider' => '\MultipleLocalAuth\Provider', | ||
'auth.config' => [ | ||
'salt' => env('AUTH_SALT', null), | ||
'timeout' => '24 hours', | ||
'strategies' => [ | ||
'Facebook' => [ | ||
'app_id' => env('AUTH_FACEBOOK_APP_ID', null), | ||
'app_secret' => env('AUTH_FACEBOOK_APP_SECRET', null), | ||
'scope' => env('AUTH_FACEBOOK_SCOPE', 'email'), | ||
], | ||
'LinkedIn' => [ | ||
'api_key' => env('AUTH_LINKEDIN_API_KEY', null), | ||
'secret_key' => env('AUTH_LINKEDIN_SECRET_KEY', null), | ||
'redirect_uri' => '/autenticacao/linkedin/oauth2callback', | ||
'scope' => env('AUTH_LINKEDIN_SCOPE', 'r_emailaddress') | ||
], | ||
'Google' => [ | ||
'client_id' => env('AUTH_GOOGLE_CLIENT_ID', null), | ||
'client_secret' => env('AUTH_GOOGLE_CLIENT_SECRET', null), | ||
'redirect_uri' => '/autenticacao/google/oauth2callback', | ||
'scope' => env('AUTH_GOOGLE_SCOPE', 'email'), | ||
], | ||
'Twitter' => [ | ||
'app_id' => env('AUTH_TWITTER_APP_ID', null), | ||
'app_secret' => env('AUTH_TWITTER_APP_SECRET', null), | ||
], | ||
] | ||
] | ||
|
||
//auth.provider' => 'MapasCulturais\AuthProviders\OpauthAuthentik', | ||
//'auth.config' => [ | ||
// 'salt' => env('AUTH_SALT', 'SECURITY_SALT'), | ||
// 'timeout' => '24 hours', | ||
// 'client_id' => env('AUTH_AUTHENTIK_APP_ID', ''), | ||
// 'client_secret' => env('AUTH_AUTHENTIK_APP_SECRET', ''), | ||
// 'scope' => env('AUTH_AUTHENTIK_SCOPE', 'openid profile email'), | ||
// 'login_url' => env('AUTH_AUTHENTIK_LOGIN_URL', ''), | ||
//] | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
return [ | ||
// 'app.useRegisteredAutoloadCache' => false, | ||
'app.useAssetsUrlCache' => false, | ||
// 'app.useFileUrlCache' => false, | ||
// 'app.useEventsCache' => false, | ||
// 'app.useSubsiteIdsCache' => false, | ||
// 'app.usePermissionsCache' => false, | ||
// 'app.useRegisterCache' => false, | ||
// 'app.useApiCache' => false, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
return [ | ||
/* | ||
Nível do log do monolog | ||
DEBUG (100): Detailed debug information. | ||
INFO (200): Interesting events. Examples: User logs in, SQL logs. | ||
NOTICE (250): Normal but significant events. | ||
WARNING (300): Exceptional occurrences that are not errors. Examples: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong. | ||
ERROR (400): Runtime errors that do not require immediate action but should typically be logged and monitored. | ||
CRITICAL (500): Critical conditions. Example: Application component unavailable, unexpected exception. | ||
ALERT (550): Action must be taken immediately. Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up. | ||
EMERGENCY (600): Emergency: system is unusable. | ||
*/ | ||
'monolog.defaultLevel' => env('LOG_LEVEL', 'DEBUG'), | ||
|
||
/* | ||
Configuração dos handlers do monolog. | ||
se for uma string os handlers serão instanciados pela aplicação, | ||
se for um array, a aplicação esperará que seja uma lista de handlers | ||
ex: 'file:WARNING,error_log:DEBUG,browser:DEBUG' | ||
ex: [new \Monolog\Handler\ErrorLogHandler(level: Level::Debug)] | ||
*/ | ||
'monolog.handlers' => env('LOG_HANDLERS', 'error_log,browser'), | ||
|
||
'monolog.processors' => [], | ||
|
||
/* | ||
Pasta onde serão salvos os arquivos de log | ||
o padrão é ~/var/logs, onde ~ é a raíz do projeto, no docker é /var/www | ||
*/ | ||
'monolog.logsDir' => env('LOG_DIR', VAR_PATH . 'logs/'), | ||
|
||
// 'app.log.query' => true, | ||
// 'app.log.hook' => true, | ||
// 'app.log.requestData' => true, | ||
// 'app.log.texts' => true, | ||
// 'app.log.translations' => true, | ||
// 'app.log.apiCache' => true, | ||
// 'app.log.apiDql' => true, | ||
// 'app.log.assets' => true, | ||
// 'app.log.auth' => true, | ||
|
||
// 'app.log.components' => true, | ||
// 'app.log.assetManager' => true, | ||
|
||
// 'app.log.jobs' => true, | ||
// 'app.log.pcache' => true, | ||
// 'app.log.pcache.users' => true, | ||
|
||
'app.queryLogger' => env('LOG_QUERYLOG_CLASS', null) | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
return [ | ||
'middlewares' => [ | ||
MapasCulturais\Middlewares\ExecutionTime::class | ||
] | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return [ | ||
'plugins' => [ | ||
"MultipleLocalAuth" | ||
] | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
ARG RR_VERSION | ||
ARG RR_IMAGE=spiralscout/roadrunner:${RR_VERSION} | ||
ARG PHP_IMAGE_VERSION | ||
ARG PHP_IMAGE=php:${PHP_IMAGE_VERSION} | ||
|
||
FROM ${RR_IMAGE} as rr | ||
|
||
FROM ${PHP_IMAGE} | ||
|
||
RUN apk update && \ | ||
apk add --no-cache --virtual wget zip unzip libzip-dev freetype-dev libjpeg-turbo-dev libpng-dev sqlite sqlite-dev openssl-dev \ | ||
git bash freetype-dev \ | ||
libpng-dev libjpeg-turbo-dev \ | ||
libxml2-dev autoconf \ | ||
g++ imagemagick-dev \ | ||
libtool make postgresql-dev \ | ||
libzip-dev curl-dev gnu-libiconv | ||
|
||
|
||
RUN docker-php-ext-install zip \ | ||
&& docker-php-ext-install sockets \ | ||
# && docker-php-ext-install opcache \ | ||
&& docker-php-ext-install pdo_pgsql \ | ||
&& docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \ | ||
&& docker-php-ext-install -j$(nproc) gd \ | ||
# && docker-php-ext-enable opcache \ | ||
# && docker-php-ext-install gd \ | ||
&& docker-php-ext-install intl \ | ||
&& docker-php-ext-install opcache \ | ||
&& docker-php-ext-install xml \ | ||
&& docker-php-ext-install curl \ | ||
# && docker-php-ext-install iconv \ | ||
&& docker-php-ext-install xmlwriter \ | ||
&& docker-php-ext-install simplexml | ||
|
||
# Copy Composer | ||
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer | ||
|
||
# Copy RoadRunner | ||
COPY --from=rr /usr/bin/rr /usr/bin/rr | ||
|
||
# Copy RoadRunner config | ||
COPY --from=rr /etc/rr.yaml /etc/rr.yaml | ||
|
||
CMD ["/usr/bin/rr", "serve", "-d", "-c", "/etc/rr.yaml"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
version: "2.7" | ||
|
||
rpc: | ||
listen: tcp://127.0.0.1:6001 | ||
server: | ||
command: "php /app/worker.php" | ||
|
||
http: | ||
address: :8080 | ||
pool: | ||
num_workers: 4 | ||
max_jobs: 64 | ||
|
||
reload: | ||
interval: 1s | ||
patterns: [ ".php" ] | ||
services: | ||
http: | ||
recursive: true | ||
dirs: [ "/app" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
services: | ||
adminer: | ||
image: adminer | ||
ports: | ||
- 8888:8080 | ||
roadrunner: | ||
build: | ||
context: ./containers/roadrunner | ||
args: | ||
RR_VERSION: ${RR_VERSION} | ||
PHP_IMAGE_VERSION: ${PHP_IMAGE_VERSION} | ||
ports: | ||
- 8080:8080 | ||
environment: | ||
RR_VERSION: ${RR_VERSION} | ||
APP_MODE: development | ||
working_dir: /app | ||
volumes: | ||
- ./:/app | ||
- ./containers/roadrunner/config/.rr.yaml:/etc/rr.yaml:ro | ||
|
||
db: | ||
image: postgis/postgis:14-master | ||
environment: | ||
- POSTGRES_PASSWORD=mapas | ||
- POSTGRES_USER=mapas | ||
- POSTGRES_DB=mapas | ||
ports: | ||
- "5432:5432" | ||
volumes: | ||
- postgis_data:/var/lib/postgresql/data | ||
- ./dev/db:/docker-entrypoint-initdb.d | ||
|
||
volumes: | ||
postgis_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
**/.classpath | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/charts | ||
**/docker-compose* | ||
**/compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
LICENSE | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
FROM node:18-slim AS base | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
# VOLUME [ "/app" ] | ||
WORKDIR /app | ||
# COPY package.json /app | ||
# COPY pnpm* /app | ||
|
||
# FROM base AS prod-deps | ||
# RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --recursive --prod --frozen-lockfile | ||
|
||
# FROM base AS build | ||
# RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --recursive | ||
# COPY src/ /app | ||
# RUN pnpm run build | ||
|
||
# FROM base | ||
# COPY --from=prod-deps /app/node_modules /app/node_modules | ||
# COPY --from=build /app/dist /app/dist | ||
# EXPOSE 8000 | ||
# CMD [ "pnpm", "run", "watch" ] | ||
|
||
# FROM node:lts-alpine | ||
# ENV NODE_ENV=production | ||
# WORKDIR /usr/src/app | ||
# COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"] | ||
# RUN npm install --production --silent && mv node_modules ../ | ||
# COPY . . | ||
# EXPOSE 3000 | ||
# RUN chown -R node /usr/src/app | ||
# USER node | ||
# CMD ["npm", "start"] |
Oops, something went wrong.