Skip to content

Commit

Permalink
Merge pull request #268 from jspaezp/feature/dockerfile
Browse files Browse the repository at this point in the history
(wip) added dockerfile and cicd to publish the image
  • Loading branch information
sander-willems-bruker authored Jul 18, 2023
2 parents 48d2c27 + b640ca0 commit ea5de7d
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 1 deletion.
47 changes: 47 additions & 0 deletions .github/workflows/publish_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:

name: Publish on PyPi and release on GitHub

env:
REGISTRY: ghcr.io
IMAGE_NAME: MannLabs/alphatims

jobs:
Version_Bumped:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -193,6 +197,49 @@ jobs:
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}

Create_Docker_Release:
# Adapted from wfondrie/mokapot's docker actions
runs-on: ubuntu-latest
needs: [Create_Linux_Release]
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Build Wheel
run: |
python setup.py bdist_wheel
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to the GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Push the Docker image to the GHCR
uses: docker/build-push-action@v3
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

Test_PyPi_Release:
name: Test_PyPi_version_on_${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand Down
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

# FROM python:3.9-slim
FROM --platform=linux/amd64 python:3.9-bullseye

RUN apt-get update && apt-get install -y build-essential gcc python3-dev

RUN adduser worker
USER worker
WORKDIR /home/worker

COPY --chown=worker:worker dist/*.whl /home/worker

# RUN python3 -m pip install ".[plotting-stable]" # Image is 1.6gb with plotting
# The size is reduced to 847 mb without it.
RUN python3 -m pip install --disable-pip-version-check --no-cache-dir --user /home/worker/*.whl
RUN ls /home/worker/.local/lib/python3.9/site-packages/alphatims/ext/timsdata.so
RUN chmod 777 /home/worker/.local/lib/python3.9/site-packages/alphatims/ext/timsdata.so

RUN python3 -m pip cache purge
ENV PATH="/home/worker/.local/bin:${PATH}"

ENTRYPOINT [ "alphatims" ]
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ There are three different types of installation possible:
* [**One-click GUI installer:**](#one-click-gui) Choose this installation if you only want the GUI and/or keep things as simple as possible.
* [**Pip installer:**](#pip) Choose this installation if you want to use AlphaTims as a Python package in an existing Python 3.8 environment (e.g. a Jupyter notebook). If needed, the GUI and CLI can be installed with pip as well.
* [**Developer installer:**](#developer) Choose this installation if you are familiar with CLI tools, [conda](https://docs.conda.io/en/latest/) and Python. This installation allows access to all available features of AlphaTims and even allows to modify its source code directly. Generally, the developer version of AlphaTims outperforms the precompiled versions which makes this the installation of choice for high-throughput experiments.
* [**Docker:**](#docker) Use this installation if you want to use a container based workflow. This is usefull to preserve a clean environment or when running multiple tools that might have conflicting dependencies.

***IMPORTANT: While AlphaTims is mostly platform independent, some calibration functions require [Bruker libraries](alphatims/ext) which are only available on Windows and Linux.***

Expand Down Expand Up @@ -179,6 +180,14 @@ The following steps are optional, but make working with AlphaTims slightly more
When `zsh` is the default terminal instead of `bash`, replace `~/.bashrc` with `~/.zshrc`. On Windows, the command `where alphatims` can be used to find the location of the binary executable. This path can then be (permanently) added to Windows' path variable.
* When using Jupyter notebooks and multiple conda environments direcly from the terminal, it is recommended to `conda install nb_conda_kernels` in the conda base environment. Hereafter, running a `jupyter notebook` from the conda base environment should have a `python [conda env: alphatims]` kernel available, in addition to all other conda kernels in which the command `conda install ipykernel` was run.
### Docker
(WIP)
```shell
docker pull ghcr://MannLabs/alphatims:latest
```
### Installation issues
See the general [troubleshooting](#troubleshooting) section.
Expand Down
4 changes: 3 additions & 1 deletion alphatims/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ def show_platform_info() -> None:
)

# check if architecture is arm64 as psutil.cpu_freq() is not yet supported on apple silicon
if platform.machine() != 'arm64':
try:
logging.info(f"cpu frequency - {psutil.cpu_freq().current:.2f} Mhz")
except AttributeError:
logging.info("Unable to log cpu frequency")
logging.info(
f"ram - "
f"{psutil.virtual_memory().available/1024**3:.1f}/"
Expand Down

0 comments on commit ea5de7d

Please sign in to comment.