diff --git a/.github/workflows/publish_docker.yml b/.github/workflows/publish_docker.yml new file mode 100644 index 00000000..f2436d4b --- /dev/null +++ b/.github/workflows/publish_docker.yml @@ -0,0 +1,66 @@ +#https://docs.github.com/en/actions/publishing-packages/publishing-docker-images +name: Publish Docker image + +on: + workflow_dispatch: + inputs: + tag_to_release: + description: 'Enter tag to release (example: v1.5.5)' + required: true + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + attestations: write + steps: + - name: Check out the repo + uses: actions/checkout@v4 + with: + ref: ${{ inputs.tag_to_release }} + - name: Get current version + id: get_current_version + shell: bash -l {0} + run: | + CURRENT_VERSION=$(./misc/get_current_version.sh) + echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT + - name: Log in to Docker Hub + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: mannlabs/alphadia + + - name: show metadata + run: | + echo "${{ steps.meta.outputs.tags }}" + echo "${{ steps.meta.outputs.labels }}" + echo "${{ steps.meta.outputs }}" + + - name: Build and push Docker image + id: push + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: . + file: ./Dockerfile + push: true + tags: | + ${{ secrets.DOCKER_USERNAME }}/alphadia:latest, + ${{ secrets.DOCKER_USERNAME }}/alphadia:${{ steps.get_current_version.outputs.current_version }} + labels: ${{ steps.meta.outputs.labels }} + + +# - name: Generate artifact attestation +# uses: actions/attest-build-provenance@v1 +# with: +# subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} +# subject-digest: ${{ steps.push.outputs.digest }} +# push-to-registry: true diff --git a/Dockerfile b/Dockerfile index 8427edfc..3f8c39c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,17 +23,22 @@ RUN adduser \ --uid "${UID}" \ alphadiauser +# handy for development: # Download dependencies as a separate step to take advantage of Docker's caching. # Leverage a cache mount to /root/.cache/pip to speed up subsequent builds. # Leverage a bind mount to requirements.txt to avoid having to copy them into # into this layer. -RUN --mount=type=cache,target=/root/.cache/pip \ - --mount=type=bind,source=requirements/requirements.txt,target=requirements/requirements.txt \ - python -m pip install -r requirements/requirements.txt +# RUN --mount=type=cache,target=/root/.cache/pip \ +# --mount=type=bind,source=requirements/requirements.txt,target=requirements/requirements.txt \ +# python -m pip install -r requirements/requirements.txt -COPY . . +COPY pyproject.toml pyproject.toml +COPY docs docs +COPY gui gui +COPY requirements requirements +COPY alphadia alphadia -RUN pip install ".[stable]" +RUN pip install --no-cache-dir ".[stable]" USER alphadiauser diff --git a/docs/installation.md b/docs/installation.md index ac843eb0..5f86f887 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -55,16 +55,12 @@ The containerized version can be used to run alphaDIA e.g. on cloud platforms. It can be used to run alphaDIA for multiple input files, as well as for single files only (trivial parallelization on computing clusters). -Note that this container is not optimized for performance yet, and does not run on Apple Silicone chips +Note that this container is not optimized neither for performance nor size yet, and does not run on Apple Silicone chips (M1/M2/M3) due to problems with mono. Also, it currently relies on the input files being organized in a specific folder structure. 1) Install the latest version of docker (https://docs.docker.com/engine/install/). -2) Build the image (this step is obsolete once the container is available on Docker hub) -```bash -docker build -t alphadia-docker . -``` -3) Set up your data to match the expected folder structure: +2) Set up your data to match the expected folder structure: - Create a folder and store its name in a variable, e.g. `DATA_FOLDER=/home/username/data; mkdir -p $DATA_FOLDER` - In this folder, create 4 subfolders: - `library`: put your library file here, make it writeable for any user (`chmod o+rw *`) @@ -83,12 +79,22 @@ output_directory: /app/data/output The rest of the config values are taken from `default.yaml`, unless you overwrite any value from there in your `config.yaml`. -4) Start the container (this command will change once the container is available on Docker hub) +3) Start the container +```bash +docker run -v $DATA_FOLDER:/app/data/ mannlabs/alphadia:latest +``` +After initial download of the container, alphaDIA will start running immediately. Alternatively, you can run an interactive session with +`docker run -v $DATA_FOLDER:/app/data/ -it mannlabs/alphadia:latest bash` + +### Build the image yourself (advanced users) +If you want to build the image yourself, you can do so by +```bash +docker build -t alphadia-docker . +``` +and run it with ```bash docker run -v $DATA_FOLDER:/app/data/ --rm alphadia-docker ``` -AlphaDIA will start running immediately. Alternatively, you can run an interactive session with -`docker run -v $DATA_FOLDER:/app/data/ --rm -it alphadia-docker bash` ## Installing alphaDIA on a SLURM cluster diff --git a/misc/get_current_version.sh b/misc/get_current_version.sh new file mode 100755 index 00000000..527e3442 --- /dev/null +++ b/misc/get_current_version.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# extract the current version from the code and print, e.g. 1.5.5 + +grep "__version__" alphadia/__init__.py | cut -f3 -d ' ' | sed 's/"//g'