generated from pagopa/pagopa-functions-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from pagopa/PAYOPS-2347-layer-db
add db layer
- Loading branch information
Showing
7 changed files
with
605 additions
and
283 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
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 |
---|---|---|
@@ -1,54 +1,15 @@ | ||
FROM php:8.2-fpm | ||
|
||
|
||
RUN apt -y update -y && apt -y upgrade && apt -y install git libpq-dev libzip-dev zip libmemcached-dev && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql && docker-php-ext-install pdo pdo_pgsql pgsql && docker-php-ext-install zip | ||
RUN cd /tmp && curl -k https://getcomposer.org/installer -o composer-setup.php && php composer-setup.php && mv composer.phar /usr/local/bin/composer && rm -f composer-setup.php | ||
|
||
RUN pecl install memcached && docker-php-ext-enable memcached && mv /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini | ||
|
||
USER root:root | ||
FROM composer:latest as composer | ||
RUN mkdir -p /tmp/repo | ||
COPY . /tmp/repo/ | ||
WORKDIR /tmp/repo | ||
RUN composer install --no-dev | ||
|
||
# git clone del progetto che deve andare a finire in /var/www/html/crawler | ||
# run del comando composer install dalla directory /var/www/html/crawler | ||
|
||
# from https://getcomposer.org/doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md | ||
# remove all .git directory from installed dependencies | ||
# find vendor/ -type d -name ".git" -exec rm -rf {} \; | ||
# | ||
# Add a .gitignore rule (/vendor/**/.git) | ||
|
||
|
||
# valutare questo dockerfile | ||
## Uso una build per effettuare il clone del repository. Il comando git non mi servirà più quindi è inutile installarlo nella build finale | ||
## FROM alpine:latest as git_repo | ||
## RUN apk upgrade && apk update && apk add git | ||
## WORKDIR /tmp | ||
## RUN git clone https://github.com/pagopa/pagopa-qi-log-crawler | ||
## | ||
## | ||
## | ||
## | ||
## Uso la build di composer nella quale copio il repository precedentemente clonato, e lancio il composer install | ||
## Anche in questo caso composer serve solo per effettuare il download delle dipendenze, quindi è inutile installarlo nella build finale | ||
## FROM composer:latest as composer | ||
## RUN mkdir -p /tmp/repo | ||
## COPY --from=git_repo /tmp/pagopa-qi-log-crawler/src /tmp/repo/ | ||
## WORKDIR /tmp/repo | ||
## RUN composer install | ||
## | ||
## Uso php-fpm ed installo alcuni modulo (forse libzip si può eliminare , serviva a composer) | ||
## FROM php:8.2-fpm | ||
## RUN apt -y update && \ | ||
## apt -y upgrade && \ | ||
## apt -y install libpq-dev libzip-dev zip libmemcached-dev cron && \ | ||
## docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql && \ | ||
## docker-php-ext-install pdo pdo_pgsql pgsql zip && \ | ||
## pecl install memcached && \ | ||
## docker-php-ext-enable memcached && \ | ||
## /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini && \ | ||
## mkdir -p /var/www/html/sherlock | ||
## COPY --from=composer /tmp/repo/ /var/www/html/sherlock | ||
## | ||
## | ||
## valutare https://packagist.org/packages/predis/predis per la connessione a Redis. | ||
## se si usa redis eliminare dalla build le dipendenze di memcache | ||
FROM php:8.2-fpm | ||
COPY --from=composer /tmp/repo /var/www/html | ||
RUN apt -y update && \ | ||
apt -y upgrade && \ | ||
apt -y install curl libpq-dev libzip-dev zip && \ | ||
docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql && \ | ||
docker-php-ext-install pdo pdo_pgsql pgsql && \ | ||
docker-php-ext-install zip && \ | ||
mv /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini |
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,54 @@ | ||
<?php | ||
|
||
require './vendor/autoload.php'; | ||
|
||
/* load environment config */ | ||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__); | ||
$dotenv->load(); | ||
|
||
use Illuminate\Database\Capsule\Manager as Capsule; | ||
|
||
$data = [ | ||
'config_instance' => | ||
[ | ||
'driver' => $_ENV['DB_CONFIG_INSTANCE_DRIVER'], | ||
'host' => $_ENV['DB_CONFIG_INSTANCE_HOST'], | ||
'port' => $_ENV['DB_CONFIG_INSTANCE_PORT'], | ||
'database' => $_ENV['DB_CONFIG_INSTANCE_DATABASE'], | ||
'username' => $_ENV['DB_CONFIG_INSTANCE_USERNAME'], | ||
'password' => $_ENV['DB_CONFIG_INSTANCE_PASSWORD'], | ||
'charset' => $_ENV['DB_CONFIG_INSTANCE_CHARSET'], | ||
'collation' => $_ENV['DB_CONFIG_INSTANCE_COLLATION'], | ||
], | ||
'data_instance' => | ||
[ | ||
'driver' => $_ENV['DB_DATA_INSTANCE_DRIVER'], | ||
'host' => $_ENV['DB_DATA_INSTANCE_HOST'], | ||
'port' => $_ENV['DB_DATA_INSTANCE_PORT'], | ||
'database' => $_ENV['DB_DATA_INSTANCE_DATABASE'], | ||
'username' => $_ENV['DB_DATA_INSTANCE_USERNAME'], | ||
'password' => $_ENV['DB_DATA_INSTANCE_PASSWORD'], | ||
'charset' => $_ENV['DB_DATA_INSTANCE_CHARSET'], | ||
'collation' => $_ENV['DB_DATA_INSTANCE_COLLATION'], | ||
], | ||
'history_instance' => | ||
[ | ||
'driver' => $_ENV['DB_HISTORY_INSTANCE_DRIVER'], | ||
'host' => $_ENV['DB_HISTORY_INSTANCE_HOST'], | ||
'port' => $_ENV['DB_HISTORY_INSTANCE_PORT'], | ||
'database' => $_ENV['DB_HISTORY_INSTANCE_DATABASE'], | ||
'username' => $_ENV['DB_HISTORY_INSTANCE_USERNAME'], | ||
'password' => $_ENV['DB_HISTORY_INSTANCE_PASSWORD'], | ||
'charset' => $_ENV['DB_HISTORY_INSTANCE_CHARSET'], | ||
'collation' => $_ENV['DB_HISTORY_INSTANCE_COLLATION'], | ||
] | ||
]; | ||
|
||
$capsule = new Capsule; | ||
foreach($data as $name => $config) | ||
{ | ||
$capsule->addConnection($config, $name); | ||
} | ||
|
||
$capsule->setAsGlobal(); | ||
$capsule->bootEloquent(); |
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 |
---|---|---|
@@ -1,15 +1,21 @@ | ||
{ | ||
"name": "$vendor_name$/$package_name$", | ||
"description": "$description$", | ||
"minimum-stability": "$stability$", | ||
"license": "$license$", | ||
"authors": [ | ||
{ | ||
"name": "$author$", | ||
"email": "$email$" | ||
"name" : "pagopa/crawler", | ||
"author": "Simone Esposito", | ||
"autoload": { | ||
"psr-4": { | ||
"pagopa\\sert\\": "src/" | ||
} | ||
], | ||
}, | ||
"require": { | ||
$END$ | ||
"illuminate/database": "10.39.0", | ||
"predis/predis": "v2.2.2", | ||
"vlucas/phpdotenv": "v5.6.1", | ||
"ext-xmlreader": "*", | ||
"ext-simplexml": "*", | ||
"ext-libxml": "*", | ||
"ext-pdo": "*" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "11.0.1" | ||
} | ||
} |
Oops, something went wrong.