-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Alan Stanley <astanley@upei.ca> Co-authored-by: ajstanley <vagrant@claw> Co-authored-by: Alan Stanley <alanjarlathstanley@gmail.com> Co-authored-by: Nigel Banks <nigel.g.banks@gmail.com> Co-authored-by: Alexander O'Neill <aloneill@gmail.com>
- Loading branch information
1 parent
ac8752a
commit 6ba190c
Showing
22 changed files
with
737 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,34 @@ | ||
# In all environments, the following files are loaded if they exist, | ||
# the later taking precedence over the former: | ||
# | ||
# * .env contains default values for the environment variables needed by the app | ||
# * .env.local uncommitted file with local overrides | ||
# * .env.$APP_ENV committed environment-specific defaults | ||
# * .env.$APP_ENV.local uncommitted environment-specific overrides | ||
# | ||
# Real environment variables win over .env files. | ||
# | ||
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES. | ||
# | ||
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2). | ||
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration | ||
|
||
###> symfony/framework-bundle ### | ||
APP_ENV=dev | ||
APP_SECRET=5273c9fd27359cc05a2f653521d8add0 | ||
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2 | ||
#TRUSTED_HOSTS='^localhost|example\.com$' | ||
###< symfony/framework-bundle ### | ||
|
||
###> doctrine/doctrine-bundle ### | ||
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url | ||
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db" | ||
# Configure your db driver and server_version in config/packages/doctrine.yaml | ||
DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name | ||
###< doctrine/doctrine-bundle ### | ||
FITS_WEBSERVICE_URI=http://localhost:8080/fits/ | ||
|
||
|
||
###> nelmio/cors-bundle ### | ||
CORS_ALLOW_ORIGIN=^https?://localhost(:[0-9]+)?$ | ||
###< nelmio/cors-bundle ### |
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,66 @@ | ||
# CrayFits | ||
|
||
## Introduction | ||
|
||
[FITS][1] as a microservice. | ||
|
||
## Requirements | ||
|
||
* Tomcat | ||
* [Composer][2] | ||
|
||
## Installation | ||
|
||
### Install FITS webservice | ||
|
||
* Download the latest `fits.zip` and `fits.war` from | ||
[https://projects.iq.harvard.edu/fits/downloads](https://projects.iq.harvard.edu/fits/downloads). | ||
You may need to install a zip library to unzip the file. | ||
* Copy the `.war` file to your Tomcat webapps directory and test. | ||
* Edit the Tomcat `conf/catalina.properties` file by adding the | ||
following two lines to the bottom of the file: | ||
```properties | ||
fits.home=/\<path-to-fits>/fits | ||
shared.loader=/\<path-to-fits>/fits/lib/*.jar | ||
``` | ||
* Restart Tomcat. | ||
* Test the webservice with: | ||
```bash | ||
curl -k -F datafile="@/path/to/myfile.jpg" http://[tomcat_domain]:[tomcat_port]/fits/examine | ||
``` | ||
(note: the ‘@’ is required.) | ||
|
||
### Install CrayFITS microservice | ||
|
||
* Clone this repository somewhere in your web root. | ||
* `$ cd /path/to/CrayFits` and run `$ composer install` | ||
* For production, configure your web server appropriately (e.g. add a VirtualHost for CrayFits in Apache) | ||
|
||
To run the microservice on the Symfony Console, enter: | ||
```bash | ||
php bin/console server:start *:8050 | ||
``` | ||
in the microservice root folder. | ||
|
||
The server is stopped with: | ||
```bash | ||
php bin/console server:stop | ||
``` | ||
On a production machine you'd probably want to configure an additional | ||
port in Apache. | ||
|
||
Note: The location of the FITS webserver is stored in the `.env` file in the | ||
root dir of the Symfony app. This will have to be reconfigured if the FITS | ||
server is anywhere other than `localhost:8080/fits` | ||
|
||
|
||
#### Optional: Configure Alpaca to accept derivative requests from Islandora. | ||
|
||
To use Alpaca as an interface to this microservice, configure | ||
an [`islandora-connector-derivative`](https://github.com/Islandora/Alpaca#islandora-connector-derivative) | ||
appropriate to your installation of CrayFits. | ||
|
||
[1]: https://projects.iq.harvard.edu/fits | ||
[2]: https://getcomposer.org/download/ | ||
|
||
|
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,42 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
use App\Kernel; | ||
use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
use Symfony\Component\Console\Input\ArgvInput; | ||
use Symfony\Component\Debug\Debug; | ||
|
||
if (false === in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) { | ||
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.\PHP_SAPI.' SAPI'.\PHP_EOL; | ||
} | ||
|
||
set_time_limit(0); | ||
|
||
require dirname(__DIR__).'/vendor/autoload.php'; | ||
|
||
if (!class_exists(Application::class)) { | ||
throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.'); | ||
} | ||
|
||
$input = new ArgvInput(); | ||
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) { | ||
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); | ||
} | ||
|
||
if ($input->hasParameterOption('--no-debug', true)) { | ||
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); | ||
} | ||
|
||
require dirname(__DIR__).'/config/bootstrap.php'; | ||
|
||
if ($_SERVER['APP_DEBUG']) { | ||
umask(0000); | ||
|
||
if (class_exists(Debug::class)) { | ||
Debug::enable(); | ||
} | ||
} | ||
|
||
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); | ||
$application = new Application($kernel); | ||
$application->run($input); |
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,67 @@ | ||
{ | ||
"type": "project", | ||
"license": "proprietary", | ||
"require": { | ||
"ext-ctype": "*", | ||
"ext-iconv": "*", | ||
"guzzlehttp/guzzle": "^6.3", | ||
"monolog/monolog": "^1.24", | ||
"symfony/console": "^4.4", | ||
"symfony/dotenv": "^4.4", | ||
"symfony/flex": "^1.1", | ||
"symfony/framework-bundle": "^4.4", | ||
"symfony/monolog-bundle": "^3.3", | ||
"symfony/yaml": "^4.4" | ||
}, | ||
"config": { | ||
"preferred-install": { | ||
"*": "dist" | ||
}, | ||
"sort-packages": true, | ||
"allow-plugins": { | ||
"symfony/flex": true | ||
} | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"App\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"App\\Tests\\": "tests/" | ||
} | ||
}, | ||
"replace": { | ||
"paragonie/random_compat": "2.*", | ||
"symfony/polyfill-ctype": "*", | ||
"symfony/polyfill-iconv": "*", | ||
"symfony/polyfill-php71": "*", | ||
"symfony/polyfill-php70": "*", | ||
"symfony/polyfill-php56": "*" | ||
}, | ||
"scripts": { | ||
"auto-scripts": { | ||
"cache:clear": "symfony-cmd", | ||
"assets:install %PUBLIC_DIR%": "symfony-cmd" | ||
}, | ||
"post-install-cmd": [ | ||
"@auto-scripts" | ||
], | ||
"post-update-cmd": [ | ||
"@auto-scripts" | ||
], | ||
"test": [ | ||
"@check" | ||
] | ||
}, | ||
"conflict": { | ||
"symfony/symfony": "*" | ||
}, | ||
"extra": { | ||
"symfony": { | ||
"allow-contrib": false, | ||
"require": "^4.4" | ||
} | ||
} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
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; | ||
} elseif (!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'); | ||
} | ||
|
||
$_SERVER += $_ENV; | ||
$_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'; |
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 [ | ||
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], | ||
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], | ||
]; |
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,19 @@ | ||
framework: | ||
cache: | ||
# Put the unique name of your app here: the prefix seed | ||
# is used to compute stable namespaces for cache keys. | ||
#prefix_seed: your_vendor_name/app_name | ||
|
||
# The app cache caches to the filesystem by default. | ||
# Other options include: | ||
|
||
# Redis | ||
#app: cache.adapter.redis | ||
#default_redis_provider: redis://localhost | ||
|
||
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues) | ||
#app: cache.adapter.apcu | ||
|
||
# Namespaced pools use the above "app" backend by default | ||
#pools: | ||
#my.dedicated.cache: ~ |
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 @@ | ||
framework: | ||
router: | ||
strict_requirements: true |
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,17 @@ | ||
framework: | ||
secret: '%env(APP_SECRET)%' | ||
#default_locale: en | ||
#csrf_protection: true | ||
#http_method_override: true | ||
|
||
# Enables session support. Note that the session will ONLY be started if you read or write from it. | ||
# Remove or comment this section to explicitly disable session support. | ||
session: | ||
handler_id: ~ | ||
cookie_secure: auto | ||
cookie_samesite: lax | ||
|
||
#esi: true | ||
#fragments: true | ||
php_errors: | ||
log: true |
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,4 @@ | ||
framework: | ||
router: | ||
strict_requirements: ~ | ||
utf8: true |
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,4 @@ | ||
framework: | ||
test: true | ||
session: | ||
storage_id: session.storage.mock_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,3 @@ | ||
framework: | ||
router: | ||
strict_requirements: true |
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,5 @@ | ||
# config/routes.yaml | ||
|
||
app_fits_exec: | ||
path: / | ||
controller: App\Controller\FitsController::generate_fits |
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,27 @@ | ||
# This file is the entry point to configure your own services. | ||
# Files in the packages/ subdirectory configure your dependencies. | ||
|
||
# Put parameters here that don't need to change on each machine where the app is deployed | ||
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration | ||
parameters: | ||
|
||
services: | ||
# default configuration for services in *this* file | ||
_defaults: | ||
autowire: true # Automatically injects dependencies in your services. | ||
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. | ||
|
||
# makes classes in src/ available to be used as services | ||
# this creates a service per class whose id is the fully-qualified class name | ||
App\: | ||
resource: '../src/*' | ||
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}' | ||
|
||
# controllers are imported separately to make sure services can be injected | ||
# as action arguments even if you don't extend any base controller class | ||
App\Controller\: | ||
resource: '../src/Controller' | ||
tags: ['controller.service_arguments'] | ||
|
||
# add more service definitions when explicit configuration is needed | ||
# please note that last definitions always *replace* previous ones |
Oops, something went wrong.