Skip to content

Commit

Permalink
Update instructions and Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
meier-rene committed Aug 23, 2024
1 parent 0675f38 commit 13ee8c6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
FROM eclipse-temurin:17-jre
FROM maven:3.9-eclipse-temurin-21
RUN apt-get update && apt-get install -y --no-install-recommends jq && rm -rf /var/lib/apt/lists/*

COPY generate.sh openapi-generator-cli.jar openapi.yaml /usr/src/app/
COPY generate.sh config-openapi.yaml openapi.yaml /usr/src/app/

WORKDIR /usr/src/app
RUN bash generate.sh

FROM python:3.12-slim-bookworm
WORKDIR /usr/src/app
RUN apt-get update && apt-get install -y --no-install-recommends libpq5 && rm -rf /var/lib/apt/lists/*
COPY requirements.txt /usr/src/app/
RUN pip3 install --upgrade pip && pip3 install --no-cache-dir -r requirements.txt
RUN pip3 install --root-user-action=ignore --upgrade pip && pip3 install --root-user-action=ignore --no-cache-dir -r requirements.txt

COPY similarity_service_impl /usr/src/app/cosine_impl
COPY --from=0 /usr/src/app/openapi.yaml /usr/src/app/openapi.yaml
COPY --from=0 /usr/src/app/gen /usr/src/app/gen
COPY similarity_service_impl /usr/src/app/similarity_service_impl

ENV PYTHONPATH=/usr/src/app/gen

EXPOSE 8080/tcp
ENTRYPOINT ["/usr/local/bin/waitress-serve"]
CMD ["--port=8080", "cosine_impl.app:app"]
CMD ["--port=8080", "similarity_service_impl.app:app"]
32 changes: 18 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,39 @@ the [Connexion](https://github.com/zalando/connexion) library on top of Flask.
Tested on Python 3.12

## Configuration
This microservice is configured with environment variables. The following variables and
default values are used:
```
DB_PORT = 5432
DB_USER = "massbank3"
DB_PASSWORD = "massbank3password"
DB_NAME = "massbank3"
DB_HOST = "localhost"
This microservice is configured with environment variables. The reference
spectra are initialized from a local file. The file location needs to be
configured in the environment variable `MSP`. For MassBank we configure the
service with the latest MassBank-data release in msp format.
```bash
wget https://github.com/MassBank/MassBank-data/releases/latest/download/MassBank_NIST.msp
export MSP="./MassBank_NIST.msp"
```

## Usage
To run the server, please generate the server code, install the requirements
To run the server, install the requirements, generate the server code
and start the server like this:
```bash
bash generate.sh
pip3 install -r requirements.txt
bash generate.sh
PYTHONPATH=gen python3 -m similarity_service_impl
```
You can find the swagger ui at http://localhost:8080/ui/ and the
OpenAPI definition at http://localhost:8080/openapi.json in your browser.

## Running with Docker

To run the server on a Docker container, please execute the following from the root directory:
To run the server in a Docker container, execute the following commands:

```bash
# building the image
docker build -t openapi_server .
docker build -t massbank3-similarity-service .

# download reference data
wget https://github.com/MassBank/MassBank-data/releases/latest/download/MassBank_NIST.msp

# starting up a container
docker run -p 8080:8080 openapi_server
docker run -p 8080:8080 \
-v $(pwd)/MassBank_NIST.msp:/MassBank_NIST.msp \
-e MSP='/MassBank_NIST.msp' \
massbank3-similarity-service
```
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ Flask < 2.3
waitress >= 3.0.0

matchms >= 0.27.0
psycopg[pool] >= 3.0.0
numpy
watchdog

0 comments on commit 13ee8c6

Please sign in to comment.