Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CrayFits as part of Crayfish #178

Merged
merged 49 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
f9ce5a6
first commit
Apr 15, 2019
797ab1e
Accepts header
Apr 17, 2019
1a25f35
Changed Content-type
Apr 17, 2019
55bc029
Add .htaccess file
Apr 26, 2019
dd993c0
Added environmental variable
Apr 26, 2019
d0f24a4
Added dependencies
Apr 26, 2019
ba0dfc2
Refactor pre migration
Apr 26, 2019
f08ca8b
Added vendor and packages to git files
Apr 26, 2019
a1f9c95
added vendor
Apr 26, 2019
68ddb2f
Cleaned cruft
Apr 26, 2019
b2b0cf3
removed unused dependencies
Apr 29, 2019
caff345
cleared cruft
Apr 29, 2019
a14606a
reverted ignore
Apr 29, 2019
a6eaadb
cleared vendor files
Apr 29, 2019
dbec22c
Added logger
May 2, 2019
5c5ddcb
Force UTF 8
May 17, 2019
ab4e8fe
added monolog
Jul 2, 2019
a07b847
Changed path
Jul 3, 2019
92fb1b2
changed path
Jul 3, 2019
3364f03
merged conflicts
Jul 3, 2019
8f280a9
Added health message.
Oct 24, 2019
2172871
Adjusted phpdocs
Oct 25, 2019
8331758
Bump symfony/cache from 4.2.11 to 4.3.9
dependabot[bot] Dec 2, 2019
e7dac57
Bump symfony/http-foundation from 4.2.11 to 4.4.1
dependabot[bot] Dec 3, 2019
4578f04
Merge pull request #1 from roblib/dependabot/composer/symfony/cache-4…
ajstanley Dec 3, 2019
6c19ec2
Merge pull request #2 from roblib/dependabot/composer/symfony/http-fo…
ajstanley Dec 3, 2019
2e3fe2e
added logging
Jan 29, 2020
8bbe270
Update FitsController.php
ajstanley Jan 29, 2020
2a8965d
Moved authorization
ajstanley Jan 30, 2020
ad2d772
cleanup
Feb 12, 2020
88da26c
Bump symfony/http-foundation from 4.4.1 to 4.4.7
dependabot[bot] Mar 31, 2020
70fb12c
Merge pull request #3 from roblib/dependabot/composer/symfony/http-fo…
ajstanley Apr 1, 2020
4e0faeb
Create LICENSE
ajstanley Apr 22, 2020
6e95f2f
Update dependencies to support using Composer 2.0 for installation.
nigelgbanks Nov 2, 2020
c81bf83
Merge pull request #4 from nigelgbanks/composer-2-support
ajstanley Nov 9, 2020
b903d11
Bump guzzlehttp/psr7 from 1.7.0 to 1.8.5
dependabot[bot] Mar 29, 2022
eaaa104
Merge pull request #6 from roblib/dependabot/composer/guzzlehttp/psr7…
rosiel Apr 5, 2022
61e89b2
Bump guzzlehttp/guzzle from 6.5.5 to 6.5.8
dependabot[bot] Jun 21, 2022
5d9f5f0
Update composer.json
rosiel Jul 11, 2022
b37e711
Merge pull request #9 from roblib/dependabot/composer/guzzlehttp/guzz…
rosiel Jul 11, 2022
4c37211
Attempt to get working under PHP 8.1
nigelgbanks Nov 6, 2022
314dfde
Add README.
rosiel Nov 10, 2022
89f8229
Merge pull request #10 from nigelgbanks/upgrade-php
alxp Nov 16, 2022
2a14ebf
Merge pull request #11 from roblib/README
rosiel Sep 25, 2023
63abd9d
Prepare for merge with Crayfish.
rosiel Oct 19, 2023
8da7fca
Merge CrayFits into Crayfish.
rosiel Oct 19, 2023
fa38ca5
Add test script.
rosiel Oct 20, 2023
97714e2
Remove until Crayfits has tests
rosiel Oct 20, 2023
d1170e4
Add CrayFits to readme.
rosiel Oct 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions CrayFits/.env
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 ###
66 changes: 66 additions & 0 deletions CrayFits/README.md
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/


42 changes: 42 additions & 0 deletions CrayFits/bin/console
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);
67 changes: 67 additions & 0 deletions CrayFits/composer.json
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"
}
}
}
21 changes: 21 additions & 0 deletions CrayFits/config/bootstrap.php
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';
6 changes: 6 additions & 0 deletions CrayFits/config/bundles.php
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],
];
19 changes: 19 additions & 0 deletions CrayFits/config/packages/cache.yaml
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: ~
3 changes: 3 additions & 0 deletions CrayFits/config/packages/dev/routing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
framework:
router:
strict_requirements: true
17 changes: 17 additions & 0 deletions CrayFits/config/packages/framework.yaml
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
4 changes: 4 additions & 0 deletions CrayFits/config/packages/routing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
framework:
router:
strict_requirements: ~
utf8: true
4 changes: 4 additions & 0 deletions CrayFits/config/packages/test/framework.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
framework:
test: true
session:
storage_id: session.storage.mock_file
3 changes: 3 additions & 0 deletions CrayFits/config/packages/test/routing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
framework:
router:
strict_requirements: true
5 changes: 5 additions & 0 deletions CrayFits/config/routes.yaml
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
27 changes: 27 additions & 0 deletions CrayFits/config/services.yaml
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
Loading