diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index e982da92..d002ce3a 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -28,4 +28,4 @@ jobs: uses: pypa/gh-action-pypi-publish@v1.2.2 with: user: __token__ - password: ${{ secrets.KGX_PYPI }} + password: ${{ secrets.KGX_PYPI_TOKEN }} diff --git a/Dockerfile b/Dockerfile index 564b2bdf..9383e696 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,38 @@ -FROM python:3.9 -MAINTAINER Sierra Moxon "smoxon@lbl.gov" +FROM python:3.9-bullseye as builder -# Clone repository -RUN git clone https://github.com/biolink/kgx +# https://stackoverflow.com/questions/53835198/integrating-python-poetry-with-docker +ENV PYTHONFAULTHANDLER=1 \ + PYTHONUNBUFFERED=1 \ + PYTHONHASHSEED=random \ + PIP_NO_CACHE_DIR=off \ + PIP_DISABLE_PIP_VERSION_CHECK=on \ + PIP_DEFAULT_TIMEOUT=100 \ + POETRY_VERSION=1.2.1 -# Setup -RUN cd kgx && git checkout tags/2.0.0 && poetry install +# Install Poetry +RUN pip install "poetry==$POETRY_VERSION" +RUN poetry self add "poetry-dynamic-versioning[plugin]" -# Make data directory -RUN mkdir data +WORKDIR /code + +# Build project. The .git directory is needed for poetry-dynamic-versioning +COPY ./.git ./.git +COPY pyproject.toml poetry.lock README.md . +COPY kgx kgx/ +RUN poetry build + +####################################### +FROM python:3.9-slim-bullseye as runner +RUN useradd --create-home kgxuser WORKDIR /kgx +RUN mkdir data +USER kgxuser +ENV PATH="${PATH}:/home/kgxuser/.local/bin" + +COPY --from=builder /code/dist/*.whl /tmp +RUN pip install --user /tmp/*.whl + +# command to run on container start CMD ["/bin/bash"] diff --git a/pyproject.toml b/pyproject.toml index f3e6478b..ab22e779 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,10 +53,16 @@ tox = "^3.28.0" tox-docker = "*" bmt = "^1.0.0" +[tool.poetry-dynamic-versioning] +enable = true +vcs = "git" +style = "pep440" [build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" + +requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"] +build-backend = "poetry_dynamic_versioning.backend" [tool.poetry.scripts] kgx = "kgx.cli:cli" +