Skip to content

Commit

Permalink
Support facets with intermediate arrays and improve fixtures (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito authored Aug 7, 2024
1 parent f7864dc commit 2a8c48a
Show file tree
Hide file tree
Showing 20 changed files with 528 additions and 293 deletions.
2 changes: 1 addition & 1 deletion .pyproject_generation/pyproject_custom.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "mass"
version = "3.0.1"
version = "3.0.2"
description = "Metadata Artifact Search Service - A service for searching metadata artifacts and filtering results."
dependencies = [
"typer>=0.12",
Expand Down
1 change: 1 addition & 0 deletions .template/mandatory_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ lock/requirements-dev.txt
lock/requirements.txt

Dockerfile
Dockerfile.debian
config_schema.json
example_config.yaml
LICENSE
Expand Down
38 changes: 21 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,39 @@
# See the License for the specific language governing permissions and
# limitations under the License.

## creating building container
FROM python:3.12-slim-bookworm AS builder
# update and install dependencies
RUN apt update
RUN apt upgrade -y
# BASE: a base image with updated packages
FROM python:3.12-alpine AS base
#RUN apk update
#RUN apk upgrade --available
RUN apk upgrade --no-cache --available

# BUILDER: a container to build the service wheel
FROM base as builder
RUN pip install build
# copy code
COPY . /service
WORKDIR /service
# build wheel
RUN python -m build

# creating running container
FROM python:3.12-slim-bookworm
# update and install dependencies
RUN apt update
RUN apt upgrade -y
# copy and install requirements and wheel
# DEP-BUILDER: a container to (build and) install dependencies
FROM base AS dep-builder
RUN apk update
RUN apk add build-base gcc g++ libffi-dev zlib-dev
RUN apk upgrade --available
WORKDIR /service
COPY --from=builder /service/lock/requirements.txt /service
RUN pip install --no-deps -r requirements.txt
RUN rm requirements.txt

# RUNNER: a container to run the service
FROM base as runner
WORKDIR /service
RUN rm -rf /usr/local/lib/python3.12 && mkdir /usr/local/lib/python3.12
COPY --from=dep-builder /usr/local/lib/python3.12 /usr/local/lib/python3.12
COPY --from=builder /service/dist/ /service
RUN pip install --no-deps *.whl
RUN rm *.whl
# create new user and execute as that user
RUN useradd --create-home appuser
RUN adduser -D appuser
WORKDIR /home/appuser
USER appuser
# set environment
ENV PYTHONUNBUFFERED=1

ENTRYPOINT ["mass"]
48 changes: 48 additions & 0 deletions Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2021 - 2024 Universität Tübingen, DKFZ, EMBL, and Universität zu Köln
# for the German Human Genome-Phenome Archive (GHGA)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

## creating building container
FROM python:3.12-slim-bookworm AS builder
# update and install dependencies
RUN apt update
RUN apt upgrade -y
RUN pip install build
# copy code
COPY . /service
WORKDIR /service
# build wheel
RUN python -m build

# creating running container
FROM python:3.12-slim-bookworm
# update and install dependencies
RUN apt update
RUN apt upgrade -y
# copy and install requirements and wheel
WORKDIR /service
COPY --from=builder /service/lock/requirements.txt /service
RUN pip install --no-deps -r requirements.txt
RUN rm requirements.txt
COPY --from=builder /service/dist/ /service
RUN pip install --no-deps *.whl
RUN rm *.whl
# create new user and execute as that user
RUN useradd --create-home appuser
WORKDIR /home/appuser
USER appuser
# set environment
ENV PYTHONUNBUFFERED=1

ENTRYPOINT ["mass"]
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ We recommend using the provided Docker container.

A pre-build version is available at [docker hub](https://hub.docker.com/repository/docker/ghga/mass):
```bash
docker pull ghga/mass:3.0.1
docker pull ghga/mass:3.0.2
```

Or you can build the container yourself from the [`./Dockerfile`](./Dockerfile):
```bash
# Execute in the repo's root dir:
docker build -t ghga/mass:3.0.1 .
docker build -t ghga/mass:3.0.2 .
```

For production-ready deployment, we recommend using Kubernetes, however,
for simple use cases, you could execute the service using docker
on a single server:
```bash
# The entrypoint is preconfigured:
docker run -p 8080:8080 ghga/mass:3.0.1 --help
docker run -p 8080:8080 ghga/mass:3.0.2 --help
```

If you prefer not to use containers, you may install the service from source:
Expand All @@ -72,7 +72,7 @@ The service requires the following configuration parameters:

- **`service_name`** *(string)*: Default: `"mass"`.

- **`service_instance_id`** *(string)*: A string that uniquely identifies this instance across all instances of this service. A globally unique Kafka client ID will be created by concatenating the service_name and the service_instance_id.
- **`service_instance_id`** *(string, required)*: A string that uniquely identifies this instance across all instances of this service. A globally unique Kafka client ID will be created by concatenating the service_name and the service_instance_id.


Examples:
Expand Down Expand Up @@ -105,11 +105,11 @@ The service requires the following configuration parameters:

- **`log_traceback`** *(boolean)*: Whether to include exception tracebacks in log messages. Default: `true`.

- **`searchable_classes`** *(object)*: A collection of searchable_classes with facetable and selected fields. Can contain additional properties.
- **`searchable_classes`** *(object, required)*: A collection of searchable_classes with facetable and selected fields. Can contain additional properties.

- **Additional properties**: Refer to *[#/$defs/SearchableClass](#%24defs/SearchableClass)*.

- **`resource_change_event_topic`** *(string)*: Name of the event topic used to track resource deletion and upsertion events.
- **`resource_change_event_topic`** *(string, required)*: Name of the event topic used to track resource deletion and upsertion events.


Examples:
Expand All @@ -119,7 +119,7 @@ The service requires the following configuration parameters:
```


- **`resource_deletion_event_type`** *(string)*: The type to use for events with deletion instructions.
- **`resource_deletion_event_type`** *(string, required)*: The type to use for events with deletion instructions.


Examples:
Expand All @@ -129,7 +129,7 @@ The service requires the following configuration parameters:
```


- **`resource_upsertion_event_type`** *(string)*: The type to use for events with upsert instructions.
- **`resource_upsertion_event_type`** *(string, required)*: The type to use for events with upsert instructions.


Examples:
Expand All @@ -139,7 +139,7 @@ The service requires the following configuration parameters:
```


- **`kafka_servers`** *(array)*: A list of connection strings to connect to Kafka bootstrap servers.
- **`kafka_servers`** *(array, required)*: A list of connection strings to connect to Kafka bootstrap servers.

- **Items** *(string)*

Expand Down Expand Up @@ -193,7 +193,7 @@ The service requires the following configuration parameters:
```


- **`db_connection_str`** *(string, format: password)*: MongoDB connection string. Might include credentials. For more information see: https://naiveskill.com/mongodb-connection-string/.
- **`db_connection_str`** *(string, format: password, required)*: MongoDB connection string. Might include credentials. For more information see: https://naiveskill.com/mongodb-connection-string/.


Examples:
Expand All @@ -203,7 +203,7 @@ The service requires the following configuration parameters:
```


- **`db_name`** *(string)*: Name of the database located on the MongoDB server.
- **`db_name`** *(string, required)*: Name of the database located on the MongoDB server.


Examples:
Expand Down
Loading

0 comments on commit 2a8c48a

Please sign in to comment.