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

fix; update docker installation #63

Merged
merged 4 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM continuumio/miniconda3 AS nmrkit-ms

ENV PYTHON_VERSION=3.10
ENV RDKIT_VERSION=2023.03.1
ENV OPENBABEL_VERSION=v3.1

ARG RELEASE_VERSION
Expand All @@ -15,10 +14,13 @@ RUN apt-get update && \
apt-get install -y curl && \
conda update -n base -c defaults conda

RUN apt-get update && apt-get -y install docker.io

RUN conda install -c conda-forge python>=PYTHON_VERSION
RUN conda install -c conda-forge rdkit>=RDKIT_VERSION
RUN conda install -c conda-forge openbabel>=OPENBABEL_VERSION

RUN pip3 install rdkit

RUN python3 -m pip install -U pip

ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64/
Expand Down
3 changes: 2 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from .routers import registration
from .routers import chem
from .routers import spectra
from .routers import spectra, converter
from fastapi.middleware.cors import CORSMiddleware

from app.core import config, tasks
Expand All @@ -31,6 +31,7 @@
app.include_router(registration.router)
app.include_router(chem.router)
app.include_router(spectra.router)
app.include_router(converter.router)

app.add_event_handler("startup", tasks.create_start_app_handler(app))
app.add_event_handler("shutdown", tasks.create_stop_app_handler(app))
Expand Down
63 changes: 63 additions & 0 deletions app/routers/converter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import subprocess
from fastapi import APIRouter, HTTPException, status, Response
from app.schemas import HealthCheck
from urllib.parse import unquote
import json

router = APIRouter(
prefix="/convert",
tags=["converter"],
dependencies=[],
responses={404: {"description": "Not Found"}},
)


@router.get("/", include_in_schema=False)
@router.get(
"/health",
tags=["healthcheck"],
summary="Perform a Health Check on Converter Module",
response_description="Return HTTP Status Code 200 (OK)",
status_code=status.HTTP_200_OK,
include_in_schema=False,
response_model=HealthCheck,
)
def get_health() -> HealthCheck:
"""
## Perform a Health Check
Endpoint to perform a healthcheck on. This endpoint can primarily be used by Docker
to ensure a robust container orchestration and management are in place. Other
services that rely on the proper functioning of the API service will not deploy if this
endpoint returns any other HTTP status code except 200 (OK).
Returns:
HealthCheck: Returns a JSON response with the health status
"""
return HealthCheck(status="OK")


@router.get(
"/spectra",
tags=["converter"],
summary="Load and convert NMR raw data",
#response_model=List[int],
response_description="Load and convert NMR raw data",
status_code=status.HTTP_200_OK,
)
async def nmr_load_save(url: str):
"""
## Return nmrium json

Returns:
Return nmrium json
"""
process = subprocess.Popen(
["docker exec nmr-converter nmr-cli -u " + url],
stdout=subprocess.PIPE,
shell=True,
)
(output, err) = process.communicate()
process.wait()
if err:
raise HTTPException(status_code=500, detail=err)
else:
return Response(content=output, media_type="application/json")
2 changes: 0 additions & 2 deletions app/scripts/nmr-cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ COPY package.json ./
COPY package-lock.json ./
RUN npm install

RUN apk add docker

COPY . ./

#install the nmr-cli as a global package
Expand Down
2 changes: 0 additions & 2 deletions app/scripts/nmr-respredict/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM continuumio/miniconda3 AS nmr-respredict-ms

ENV PYTHON_VERSION=3.10
ENV RDKIT_VERSION=2023.09.1

# Install runtime dependencies
RUN apt-get update && \
Expand All @@ -11,7 +10,6 @@ RUN apt-get update && \
conda update -n base -c defaults conda

RUN conda install -c conda-forge python>=PYTHON_VERSION
# RUN conda install -c conda-forge rdkit>=RDKIT_VERSION
RUN python3 -m pip install -U pip

RUN pip3 install rdkit
Expand Down
7 changes: 3 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ services:
build:
context: ./
dockerfile: Dockerfile
# image: nfdi4chem/nmrkit:dev-latest
container_name: nmrkit-api
volumes:
- ./app:/code/app
- "/var/run/docker.sock:/var/run/docker.sock"
ports:
- "80:80"
healthcheck:
Expand All @@ -29,15 +31,12 @@ services:
entrypoint: /bin/sh
stdin_open: true
tty: true
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
container_name: nmr-converter
nmr-respredict:
build: ./app/scripts/nmr-respredict
entrypoint: /bin/sh
stdin_open: true
tty: true
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
prometheus:
image: prom/prometheus
container_name: nmrkit_prometheus
Expand Down