diff --git a/.release-version b/.release-version index 17e51c3..d917d3e 100644 --- a/.release-version +++ b/.release-version @@ -1 +1 @@ -0.1.1 +0.1.2 diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 1fbf30f..0000000 --- a/Dockerfile +++ /dev/null @@ -1,44 +0,0 @@ -# Use alpine for a smaller image size and install only the required packages -FROM python:3.8-slim-buster - -# > Setting PYTHONUNBUFFERED to a non empty value ensures that the python output is sent straight to -# > terminal (e.g. your container log) without being first buffered and that you can see the output -# > of your application (e.g. django logs) in real time. -# https://stackoverflow.com/a/59812588 -ENV PYTHONUNBUFFERED 1 - -# Install required libs -RUN apt-get update && \ - apt-get install -y \ - build-essential \ - curl \ - netcat \ - unixodbc-dev - -# Install the package manager - pipenv -RUN pip install --upgrade pip && \ - pip install --no-cache-dir pipenv - -# Change the working directory for all proceeding operations -# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#workdir -WORKDIR /code - -# "items (files, directories) that do not require ADD’s tar auto-extraction capability, you should always use COPY." -# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#add-or-copy -COPY Pipfile . -COPY Pipfile.lock . - -# Install both default and dev packages so that we can run the tests against this image -RUN pipenv sync --dev --system && \ - pipenv --clear - -# Copy all the source to the image -COPY . . - -# "The best use for ENTRYPOINT is to set the image’s main command, allowing that image to be run as though it was that -# command (and then use CMD as the default flags)." -# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#entrypoint - -# https://docs.docker.com/engine/reference/builder/#healthcheck -#HEALTHCHECK --interval=1m --timeout=3s \ -# CMD curl -f http://localhost:8000/health || exit 1 diff --git a/README.md b/README.md index 4697679..d2868ca 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ -# tol-lab-share - -Rabbitmq consumer for TOL data input +# lab-share-lib +Library to build consumers for the lab-share framework ## Getting Started @@ -23,24 +22,12 @@ Use pipenv to install the required python packages for the application and devel pipenv install --dev ``` +## Configuring -### Setting up with Docker - -If you want to setup a local development environment with Docker please check -the instructions in [SETUP_DOCKER.md](SETUP_DOCKER.md) - - -## Running - -1. Enter the python virtual environment using: -```bash - pipenv shell -``` - -1. Run the app using: +Run this command inside the project you want to add this library: ```bash - python tol-lab-share + pipenv install lab-share-lib ``` ## Testing @@ -50,9 +37,3 @@ Run the tests using pytest (flags are for verbose and exit early): ```bash python -m pytest -vx ``` - -## Deployment - -This project uses a Docker image as the unit of deployment. Update `.release-version` with -major/minor/patch. On merging a pull request into *develop* or *master*, a release will be created -along with the Docker image associated to that release. diff --git a/docker-compose-standalone.yml b/docker-compose-standalone.yml deleted file mode 100644 index 809ce80..0000000 --- a/docker-compose-standalone.yml +++ /dev/null @@ -1,9 +0,0 @@ -# -# Basic version of stack, for Github -# -version: "3.3" -services: - lab-share-lib: - build: . - image: lab-share-lib - entrypoint: "bash -c ./entrypoint.sh" \ No newline at end of file diff --git a/docker-compose.override.yml b/docker-compose.override.yml deleted file mode 100644 index 4ef075e..0000000 --- a/docker-compose.override.yml +++ /dev/null @@ -1,9 +0,0 @@ -# -# Extension of the stack for Local Dev environment running. -# Provides mounting code from the current folder path and -# connect to web and rabbitmq UI -version: "3.3" -services: - lab-share-lib: - volumes: - - ".:/code" diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index b6f701b..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,57 +0,0 @@ -# -# Basic version of stack, for Github -# -version: "3.3" -services: - lab-share-lib: - build: . - image: lab-share-lib - depends_on: - - rabbitmq - - schema_registry - environment: - REDPANDA_HOST: host.docker.internal - REDPANDA_PORT: 8081 - RABBITMQ_HOST: host.docker.internal - RABBITMQ_PORT: 5672 - - entrypoint: "bash -c ./entrypoint.sh" - - # An instance of RedPanda Schema Registry - # To run it as a standalone container: - # docker network create redpanda-network - # docker volume create redpanda-volume - # docker run --name=schema_registry --net=redpanda-network -v "redpanda-volume:/var/lib/redpanda/data" -p 8081:8081 \ - # docker.vectorized.io/vectorized/redpanda start --overprovisioned --smp 1 --memory 250M - schema_registry: - image: docker.vectorized.io/vectorized/redpanda - networks: - - redpanda-network - ports: - - "8081:8081" - volumes: - - redpanda-volume:/var/lib/redpanda/data - #mem_limit: 250m - command: - - start - - --overprovisioned - - --smp 1 - - --memory 250M - - rabbitmq: - image: rabbitmq:3-management - hostname: heron-rabbitmq - ports: - - "5672:5672" - - "8080:15672" - volumes: - - ./rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf:ro - - rabbitmq-volume:/var/lib/rabbitmq/mnesia - -volumes: - redpanda-volume: - rabbitmq-volume: - -networks: - external: - redpanda-network: diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100755 index ea72943..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -# -# This script waits 15 seconds for connection with the database, -# then it will reset the database if RESET_DATABASE is "true" -# and after that will start the we server -set -o errexit -set -o pipefail -set -o nounset - -TIMEOUT=120 - -./wait_for_connection.sh "${REDPANDA_HOST}" "${REDPANDA_PORT}" "${TIMEOUT}" -./wait_for_connection.sh "${RABBITMQ_HOST}" "${RABBITMQ_PORT}" "${TIMEOUT}" - -echo "Starting service" -exec python tol-lab-share diff --git a/pyproject.toml b/pyproject.toml index 87e9a51..858d819 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "lab-share-lib" -version = "0.0.1" +dynamic = ['version'] authors = [ { name="Stuart McHattie", email="sm49@sanger.ac.uk" }, ] @@ -26,6 +26,10 @@ classifiers = [ requires = ["hatchling"] build-backend = "hatchling.build" +[tool.hatch.version] +path = ".release-version" +pattern = "(?P\\d+\\.\\d+\\.\\d+)" + [tool.black] line-length = 120 diff --git a/wait_for_connection.sh b/wait_for_connection.sh deleted file mode 100755 index 211a42f..0000000 --- a/wait_for_connection.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -# -# This script waits TIMEOUT seconds for connection to HOST:PORT -# to be stablished and exit with 0 if success or 1 if error -set -o pipefail -set -o nounset - -HOST=$1 -PORT=$2 -TIMEOUT=$3 - -TIMEOUT_END=$(($(date +%s) + TIMEOUT)) -result=1 -while [ $result -ne 0 ]; do - echo "Waiting for connection to ${HOST}:${PORT}..." - nc -w 1 -z "${HOST}" "${PORT}" > /dev/null 2>&1 - result=$? - if [ $result -eq 0 ]; then - echo "Connected to ${HOST}:${PORT}." - exit 0 - else - if [ $(date +%s) -ge $TIMEOUT_END ]; then - echo "Operation timed out" >&2 - exit 1 - fi - sleep 1 - fi -done \ No newline at end of file