From a63931cf63f73251667ebf61128808f42fe0e489 Mon Sep 17 00:00:00 2001 From: Venkata Chandra Sekhar Nainala Date: Wed, 11 Dec 2024 22:25:06 +0100 Subject: [PATCH] fix: updated cm public api key and other minor updates --- app/Console/Kernel.php | 3 +- .../EntriesRelationManager.php | 8 +- .../Dashboard/Resources/MoleculeResource.php | 2 +- .../MoleculesRelationManager.php | 2 +- .../RelatedRelationManager.php | 2 +- .../MoleculesRelationManager.php | 2 +- .../MoleculesRelationManager.php | 2 +- app/Livewire/MoleculeDepict2d.php | 4 +- app/Livewire/MoleculeDepict3d.php | 2 +- docker-compose.dev.yml | 97 +++++++++++++++++++ docker-compose.prod.yml | 10 +- resources/ops/docker/app/app.dockerfile | 70 ------------- resources/ops/docker/nginx/nginx.dockerfile | 66 ------------- resources/ops/docker/nginx/vhost.conf | 47 --------- resources/views/molecule.blade.php | 4 +- 15 files changed, 114 insertions(+), 207 deletions(-) create mode 100644 docker-compose.dev.yml delete mode 100644 resources/ops/docker/app/app.dockerfile delete mode 100644 resources/ops/docker/nginx/nginx.dockerfile delete mode 100644 resources/ops/docker/nginx/vhost.conf diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index ef0800d4..46d51090 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -12,10 +12,9 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule): void { - // $schedule->command('inspire')->hourly(); $schedule->command('coconut:entries-process')->everyMinute()->withoutOverlapping(); $schedule->command('coconut:entries-import')->everyMinute()->withoutOverlapping(); - $schedule->command('app:dash-widgets-refresh')->everyFifteenMinutes()->withoutOverlapping(); + $schedule->command('coconut:cache')->everyFifteenMinutes()->withoutOverlapping(); } /** diff --git a/app/Filament/Dashboard/Resources/CollectionResource/RelationManagers/EntriesRelationManager.php b/app/Filament/Dashboard/Resources/CollectionResource/RelationManagers/EntriesRelationManager.php index 5f410eb5..9cef396f 100644 --- a/app/Filament/Dashboard/Resources/CollectionResource/RelationManagers/EntriesRelationManager.php +++ b/app/Filament/Dashboard/Resources/CollectionResource/RelationManagers/EntriesRelationManager.php @@ -99,21 +99,21 @@ public function infolist(Infolist $infolist): Infolist ]) ->schema([ ImageEntry::make('parent_canonical_smiles')->state(function ($record) { - return env('CM_API', 'https://api.cheminf.studio/latest/').'depict/2D?smiles='.urlencode($record->parent_canonical_smiles).'&height=300&width=300&CIP=true&toolkit=cdk'; + return env('CM_PUBLIC_API', 'https://api.cheminf.studio/latest/').'depict/2D?smiles='.urlencode($record->parent_canonical_smiles).'&height=300&width=300&CIP=true&toolkit=cdk'; }) ->width(200) ->height(200) ->ring(5) ->defaultImageUrl(url('/images/placeholder.png')), ImageEntry::make('canonical_smiles')->state(function ($record) { - return env('CM_API', 'https://api.cheminf.studio/latest/').'depict/2D?smiles='.urlencode($record->canonical_smiles).'&height=300&width=300&CIP=true&toolkit=cdk'; + return env('CM_PUBLIC_API', 'https://api.cheminf.studio/latest/').'depict/2D?smiles='.urlencode($record->canonical_smiles).'&height=300&width=300&CIP=true&toolkit=cdk'; }) ->width(200) ->height(200) ->ring(5) ->defaultImageUrl(url('/images/placeholder.png')), ImageEntry::make('standardized_canonical_smiles')->state(function ($record) { - return env('CM_API', 'https://api.cheminf.studio/latest/').'depict/2D?smiles='.urlencode($record->standardized_canonical_smiles).'&height=300&width=300&CIP=true&toolkit=cdk'; + return env('CM_PUBLIC_API', 'https://api.cheminf.studio/latest/').'depict/2D?smiles='.urlencode($record->standardized_canonical_smiles).'&height=300&width=300&CIP=true&toolkit=cdk'; }) ->width(200) ->height(200) @@ -133,7 +133,7 @@ public function table(Table $table): Table ImageColumn::make('structure')->square() ->label('Structure') ->state(function ($record) { - return env('CM_API', 'https://api.cheminf.studio/latest/').'depict/2D?smiles='.urlencode($record->canonical_smiles).'&height=300&width=300&CIP=true&toolkit=cdk'; + return env('CM_PUBLIC_API', 'https://api.cheminf.studio/latest/').'depict/2D?smiles='.urlencode($record->canonical_smiles).'&height=300&width=300&CIP=true&toolkit=cdk'; }) ->width(200) ->height(200) diff --git a/app/Filament/Dashboard/Resources/MoleculeResource.php b/app/Filament/Dashboard/Resources/MoleculeResource.php index 1770282d..96711eaf 100644 --- a/app/Filament/Dashboard/Resources/MoleculeResource.php +++ b/app/Filament/Dashboard/Resources/MoleculeResource.php @@ -78,7 +78,7 @@ public static function table(Table $table): Table ImageColumn::make('structure')->square() ->label('Structure') ->state(function ($record) { - return env('CM_API', 'https://api.cheminf.studio/latest/').'depict/2D?smiles='.urlencode($record->canonical_smiles).'&height=300&width=300&CIP=true&toolkit=cdk'; + return env('CM_PUBLIC_API', 'https://api.cheminf.studio/latest/').'depict/2D?smiles='.urlencode($record->canonical_smiles).'&height=300&width=300&CIP=true&toolkit=cdk'; }) ->width(200) ->height(200) diff --git a/app/Filament/Dashboard/Resources/MoleculeResource/RelationManagers/MoleculesRelationManager.php b/app/Filament/Dashboard/Resources/MoleculeResource/RelationManagers/MoleculesRelationManager.php index 588cd0a7..b297563e 100644 --- a/app/Filament/Dashboard/Resources/MoleculeResource/RelationManagers/MoleculesRelationManager.php +++ b/app/Filament/Dashboard/Resources/MoleculeResource/RelationManagers/MoleculesRelationManager.php @@ -26,7 +26,7 @@ public function table(Table $table): Table ImageColumn::make('structure')->square() ->label('Structure') ->state(function ($record) { - return env('CM_API', 'https://api.cheminf.studio/latest/').'depict/2D?smiles='.urlencode($record->canonical_smiles).'&height=300&width=300&CIP=true&toolkit=cdk'; + return env('CM_PUBLIC_API', 'https://api.cheminf.studio/latest/').'depict/2D?smiles='.urlencode($record->canonical_smiles).'&height=300&width=300&CIP=true&toolkit=cdk'; }) ->width(200) ->height(200) diff --git a/app/Filament/Dashboard/Resources/MoleculeResource/RelationManagers/RelatedRelationManager.php b/app/Filament/Dashboard/Resources/MoleculeResource/RelationManagers/RelatedRelationManager.php index e4c2a13f..c890aa7d 100644 --- a/app/Filament/Dashboard/Resources/MoleculeResource/RelationManagers/RelatedRelationManager.php +++ b/app/Filament/Dashboard/Resources/MoleculeResource/RelationManagers/RelatedRelationManager.php @@ -26,7 +26,7 @@ public function table(Table $table): Table ImageColumn::make('structure')->square() ->label('Structure') ->state(function ($record) { - return env('CM_API', 'https://api.cheminf.studio/latest/').'depict/2D?smiles='.urlencode($record->canonical_smiles).'&height=300&width=300&CIP=true&toolkit=cdk'; + return env('CM_PUBLIC_API', 'https://api.cheminf.studio/latest/').'depict/2D?smiles='.urlencode($record->canonical_smiles).'&height=300&width=300&CIP=true&toolkit=cdk'; }) ->width(200) ->height(200) diff --git a/app/Filament/Dashboard/Resources/OrganismResource/RelationManagers/MoleculesRelationManager.php b/app/Filament/Dashboard/Resources/OrganismResource/RelationManagers/MoleculesRelationManager.php index c897b900..2052b6c5 100644 --- a/app/Filament/Dashboard/Resources/OrganismResource/RelationManagers/MoleculesRelationManager.php +++ b/app/Filament/Dashboard/Resources/OrganismResource/RelationManagers/MoleculesRelationManager.php @@ -40,7 +40,7 @@ public function table(Table $table): Table ImageColumn::make('structure')->square() ->label('Structure') ->state(function ($record) { - return env('CM_API', 'https://api.cheminf.studio/latest/').'depict/2D?smiles='.urlencode($record->canonical_smiles).'&height=300&width=300&CIP=true&toolkit=cdk'; + return env('CM_PUBLIC_API', 'https://api.cheminf.studio/latest/').'depict/2D?smiles='.urlencode($record->canonical_smiles).'&height=300&width=300&CIP=true&toolkit=cdk'; }) ->width(200) ->height(200) diff --git a/app/Filament/Dashboard/Resources/ReportResource/RelationManagers/MoleculesRelationManager.php b/app/Filament/Dashboard/Resources/ReportResource/RelationManagers/MoleculesRelationManager.php index e75751fb..27247b19 100644 --- a/app/Filament/Dashboard/Resources/ReportResource/RelationManagers/MoleculesRelationManager.php +++ b/app/Filament/Dashboard/Resources/ReportResource/RelationManagers/MoleculesRelationManager.php @@ -35,7 +35,7 @@ public function table(Table $table): Table ImageColumn::make('structure')->square() ->label('Structure') ->state(function ($record) { - return env('CM_API', 'https://api.cheminf.studio/latest/').'depict/2D?smiles='.urlencode($record->canonical_smiles).'&height=300&width=300&CIP=true&toolkit=cdk'; + return env('CM_PUBLIC_API', 'https://api.cheminf.studio/latest/').'depict/2D?smiles='.urlencode($record->canonical_smiles).'&height=300&width=300&CIP=true&toolkit=cdk'; }) ->width(200) ->height(200) diff --git a/app/Livewire/MoleculeDepict2d.php b/app/Livewire/MoleculeDepict2d.php index fe14a2f1..c986b1b5 100644 --- a/app/Livewire/MoleculeDepict2d.php +++ b/app/Livewire/MoleculeDepict2d.php @@ -28,13 +28,13 @@ class MoleculeDepict2d extends Component #[Computed] public function source() { - return env('CM_API').'depict/2D?smiles='.urlencode($this->smiles).'&height='.$this->height.'&width='.$this->width; + return env('CM_PUBLIC_API').'depict/2D?smiles='.urlencode($this->smiles).'&height='.$this->height.'&width='.$this->width; } #[Computed] public function preview() { - return env('CM_API').'depict/2D?smiles='.urlencode($this->smiles); + return env('CM_PUBLIC_API').'depict/2D?smiles='.urlencode($this->smiles); } public function downloadMolFile($toolkit) diff --git a/app/Livewire/MoleculeDepict3d.php b/app/Livewire/MoleculeDepict3d.php index c5d57095..a51833b2 100644 --- a/app/Livewire/MoleculeDepict3d.php +++ b/app/Livewire/MoleculeDepict3d.php @@ -20,7 +20,7 @@ class MoleculeDepict3d extends Component #[Computed] public function source() { - return env('CM_API').'depict/3D?smiles='.urlencode($this->smiles).'&height='.$this->height.'&width='.$this->width.'&CIP='.$this->CIP.'&toolkit=rdkit'; + return env('CM_PUBLIC_API').'depict/3D?smiles='.urlencode($this->smiles).'&height='.$this->height.'&width='.$this->width.'&CIP='.$this->CIP.'&toolkit=rdkit'; } public function downloadSDFFile() diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 00000000..e787411c --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,97 @@ +services: + app: + build: + context: . + dockerfile: ./FrankenPHP.Dockerfile + image: coconut-8.3/app + container_name: coconut_app + env_file: + - .env + networks: + - coconut + ports: + - '${APP_PORT:-8000}:8000' + depends_on: + - pgsql + - redis + - cm + worker: + build: + context: . + dockerfile: ./FrankenPHP.Dockerfile + image: coconut-8.3/app + container_name: coconut_worker + env_file: + - .env + networks: + - coconut + depends_on: + - app + - pgsql + - redis + - cm + environment: + WITH_SCHEDULER: true + WITH_HORIZON: true + pgsql: + image: "informaticsmatters/rdkit-cartridge-debian:latest" + ports: + - '${FORWARD_DB_PORT:-5432}:5432' + environment: + PGPASSWORD: '${DB_PASSWORD:-secret}' + POSTGRES_DB: '${DB_DATABASE}' + POSTGRES_USER: '${DB_USERNAME}' + POSTGRES_PASSWORD: '${DB_PASSWORD:-secret}' + volumes: + - 'coconut-pgsql:/var/lib/postgresql/data' + - './docker/pgsql/create-testing-database.sql:/docker-entrypoint-initdb.d/10-create-testing-database.sql' + networks: + - coconut + healthcheck: + test: + - CMD + - pg_isready + - '-q' + - '-d' + - '${DB_DATABASE}' + - '-U' + - '${DB_USERNAME}' + retries: 3 + timeout: 5s + redis: + image: 'redis:alpine' + ports: + - '${FORWARD_REDIS_PORT:-6379}:6379' + volumes: + - 'coconut-redis:/data' + networks: + - coconut + healthcheck: + test: + - CMD + - redis-cli + - ping + retries: 3 + timeout: 5s + cm: + image: "nfdi4chem/cheminformatics-microservice:latest-lite" + environment: + HOMEPAGE_URL: "https://docs.api.naturalproducts.net" + ports: + - '${APP_PORT:-8001}:80' + healthcheck: + test: ["CMD", "curl", "-f", "http://cm:80/latest/chem/health"] + interval: 1m30s + timeout: 10s + retries: 20 + start_period: 60s + networks: + - coconut +networks: + coconut: + driver: bridge +volumes: + coconut-pgsql: + driver: local + coconut-redis: + driver: local \ No newline at end of file diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index e787411c..3790db71 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -1,9 +1,6 @@ services: app: - build: - context: . - dockerfile: ./FrankenPHP.Dockerfile - image: coconut-8.3/app + image: nfdi4chem/coconut:latest container_name: coconut_app env_file: - .env @@ -16,10 +13,7 @@ services: - redis - cm worker: - build: - context: . - dockerfile: ./FrankenPHP.Dockerfile - image: coconut-8.3/app + image: nfdi4chem/coconut:latest container_name: coconut_worker env_file: - .env diff --git a/resources/ops/docker/app/app.dockerfile b/resources/ops/docker/app/app.dockerfile deleted file mode 100644 index 92b8a98d..00000000 --- a/resources/ops/docker/app/app.dockerfile +++ /dev/null @@ -1,70 +0,0 @@ -FROM php:8.3-fpm-alpine3.19 AS base - -RUN apk add --update linux-headers zlib-dev libpng-dev libzip-dev icu-dev $PHPIZE_DEPS -RUN apk add git - -RUN docker-php-ext-install exif -RUN docker-php-ext-install gd -RUN docker-php-ext-install zip -RUN docker-php-ext-install sockets -RUN pecl install apcu -RUN docker-php-ext-enable apcu -RUN docker-php-ext-install pcntl -RUN docker-php-ext-configure intl -RUN docker-php-ext-install intl -RUN docker-php-ext-install bcmath - -RUN apk --update add postgresql15-client --repository=https://dl-cdn.alpinelinux.org/alpine/edge/main - -RUN set -ex \ - && apk --no-cache add \ - postgresql-dev -RUN docker-php-ext-install pdo pdo_pgsql - -# OVERRIDE DEFAULT VALUES FROM THE PHP INI FILE ON THE DOCKER CONTAINER -RUN echo 'max_execution_time = 3600' >> /usr/local/etc/php/conf.d/docker-php-maxexectime.ini; -RUN echo 'memory_limit = 512M' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini; -RUN echo 'upload_max_filesize = 100M' >> /usr/local/etc/php/conf.d/docker-php-uploadmaxfilesize.ini; -RUN echo 'post_max_size = 100M' >> /usr/local/etc/php/conf.d/docker-php-postmaxsize.ini; - -FROM base AS dev - -COPY /composer.json composer.json -COPY /composer.lock composer.lock -COPY /app app -COPY /bootstrap bootstrap -COPY /config config -COPY /artisan artisan - -FROM base AS build-fpm -WORKDIR /var/www/html -COPY --from=composer:latest /usr/bin/composer /usr/bin/composer -# TODO: REMOVE REDUNDANT STEPS -COPY /artisan artisan -COPY /composer.json composer.json -COPY /bootstrap bootstrap -COPY /app app -COPY /config config -COPY /routes routes -COPY . /var/www/html - -ARG COMPOSER_AUTH -ENV COMPOSER_AUTH=$COMPOSER_AUTH - -RUN COMPOSER_AUTH="$COMPOSER_AUTH" composer install --no-dev --no-interaction --no-progress --no-ansi --no-scripts -RUN composer dump-autoload -o - -# VITE BUILD -FROM node:18-alpine AS assets-build -WORKDIR /var/www/html -COPY . /var/www/html/ -COPY --from=build-fpm /var/www/html/vendor /var/www/html/vendor - -RUN npm ci -RUN npm run build - -# MERGING VITE ASSETS WITH APP CODE -FROM build-fpm AS fpm -COPY --from=build-fpm /var/www/html /var/www/html -RUN true -COPY --from=assets-build /var/www/html/public/build /var/www/html/public/build \ No newline at end of file diff --git a/resources/ops/docker/nginx/nginx.dockerfile b/resources/ops/docker/nginx/nginx.dockerfile deleted file mode 100644 index ecab0968..00000000 --- a/resources/ops/docker/nginx/nginx.dockerfile +++ /dev/null @@ -1,66 +0,0 @@ -FROM php:8.3-fpm-alpine3.19 AS base - -RUN apk add --update linux-headers zlib-dev libpng-dev libzip-dev icu-dev $PHPIZE_DEPS -RUN apk add git - -RUN docker-php-ext-install exif -RUN docker-php-ext-install gd -RUN docker-php-ext-install zip -RUN docker-php-ext-install sockets -RUN pecl install apcu -RUN docker-php-ext-enable apcu -RUN docker-php-ext-install pcntl -RUN docker-php-ext-configure intl -RUN docker-php-ext-install intl -RUN docker-php-ext-install bcmath - -RUN set -ex \ - && apk --no-cache add \ - postgresql-dev -RUN docker-php-ext-install pdo pdo_pgsql - -# OVERRIDE DEFAULT VALUES FROM THE PHP INI FILE ON THE DOCKER CONTAINER -RUN echo 'max_execution_time = 3600' >> /usr/local/etc/php/conf.d/docker-php-maxexectime.ini; -RUN echo 'memory_limit = 512M' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini; -RUN echo 'upload_max_filesize = 100M' >> /usr/local/etc/php/conf.d/docker-php-uploadmaxfilesize.ini; -RUN echo 'post_max_size = 100M' >> /usr/local/etc/php/conf.d/docker-php-postmaxsize.ini; - -FROM base AS dev - -COPY /composer.json composer.json -COPY /composer.lock composer.lock -COPY /app app -COPY /bootstrap bootstrap -COPY /config config -COPY /artisan artisan - -FROM base AS build-fpm -WORKDIR /var/www/html -COPY --from=composer:latest /usr/bin/composer /usr/bin/composer -# TODO: REMOVE REDUNDANT STEPS -COPY /artisan artisan -COPY /composer.json composer.json -COPY /bootstrap bootstrap -COPY /app app -COPY /config config -COPY /routes routes -COPY . /var/www/html - -ARG COMPOSER_AUTH -ENV COMPOSER_AUTH=$COMPOSER_AUTH - -RUN COMPOSER_AUTH="$COMPOSER_AUTH" composer install --no-dev --no-interaction --no-progress --no-ansi --no-scripts -RUN composer dump-autoload -o - -FROM node:18-alpine AS assets-build -WORKDIR /var/www/html -COPY . /var/www/html/ - -COPY --from=build-fpm /var/www/html/vendor /var/www/html/vendor - -RUN npm ci -RUN npm run build - -FROM nginx:1.19-alpine AS nginx -COPY /resources/ops/docker/nginx/vhost.conf /etc/nginx/conf.d/default.conf -COPY --from=assets-build /var/www/html/public /var/www/html \ No newline at end of file diff --git a/resources/ops/docker/nginx/vhost.conf b/resources/ops/docker/nginx/vhost.conf deleted file mode 100644 index cb2413de..00000000 --- a/resources/ops/docker/nginx/vhost.conf +++ /dev/null @@ -1,47 +0,0 @@ -server { - listen 80 default_server; - listen [::]:80 default_server; - server_name coconut.naturalproducts.net; - server_tokens off; - - root /var/www/html; - - client_max_body_size 200m; - - add_header X-Frame-Options "SAMEORIGIN"; - add_header X-XSS-Protection "1; mode=block"; - add_header X-Content-Type-Options "nosniff"; - - charset utf-8; - - gzip on; - gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; - gzip_proxied no-cache no-store private expired auth; - gzip_vary on; - gzip_min_length 1000; - - location / { - try_files $uri $uri/ /public/index.php?$query_string; - } - - index /public/index.html /public/index.htm /public/index.php; - error_page 404 /public/index.php; - - location ~ \.php$ { - include fastcgi_params; - fastcgi_pass localhost:9000; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param SCRIPT_NAME $fastcgi_script_name; - fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_index index.php; - } - - location ~* \.(png|jpg|jpeg|gif|svg|ico|woff2|woff)$ { - expires 1M; - add_header Cache-Control "max-age=2629746, public"; - } - - location ~ /\.(?!well-known).* { - deny all; - } -} \ No newline at end of file diff --git a/resources/views/molecule.blade.php b/resources/views/molecule.blade.php index a6f845e4..058806a6 100644 --- a/resources/views/molecule.blade.php +++ b/resources/views/molecule.blade.php @@ -34,7 +34,7 @@ + content="{{ env('CM_PUBLIC_API') . 'depict/2D?smiles=' . urlencode($molecule->canonical_smiles) . '&height=630&width=1200&toolkit=cdk' ?? asset('img/coconut-og-image.png') }}"> @@ -56,7 +56,7 @@ and found in the collection{{ $molecule->collections->count() > 1 ? 's' : '' }}: {{ implode(', ', $molecule->collections->pluck('title')->toArray()) }} @endif"> + content="{{ env('CM_PUBLIC_API') . 'depict/2D?smiles=' . urlencode($molecule->canonical_smiles) . '&height=630&width=1200&toolkit=cdk' ?? asset('img/coconut-og-image.png') }}">