Skip to content

Commit edca07a

Browse files
authored
Merge pull request #74 from MannLabs/add_dockerfile
Add dockerfile
2 parents d4e6395 + ac74bbc commit edca07a

File tree

5 files changed

+110
-14
lines changed

5 files changed

+110
-14
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Build and publish Docker image
2+
name: Publish Docker image
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
tag_to_release:
8+
description: 'Enter tag to release (example: v1.5.5). A tag with this name must exist in the repository.'
9+
type: string
10+
required: true
11+
12+
jobs:
13+
publish_on_pypi:
14+
uses: MannLabs/alphashared/.github/workflows/publish_docker.yml@v1
15+
secrets:
16+
docker_access_token: ${{ secrets.DOCKER_ACCESS_TOKEN }}
17+
docker_username: ${{ secrets.DOCKER_USERNAME }}
18+
with:
19+
package_name: directlfq
20+
tag_to_release: ${{ inputs.tag_to_release }}

Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM python:3.10-bookworm
4+
5+
# Prevents Python from writing pyc files.
6+
ENV PYTHONDONTWRITEBYTECODE=1
7+
# Keeps Python from buffering stdout and stderr to avoid situations where
8+
# the application crashes without emitting any logs due to buffering.
9+
ENV PYTHONUNBUFFERED=1
10+
11+
WORKDIR /app
12+
13+
COPY requirements requirements
14+
RUN pip install --no-cache-dir -r requirements/requirements.txt
15+
RUN pip install --no-cache-dir -r requirements/requirements_gui.txt
16+
17+
COPY directlfq directlfq
18+
COPY MANIFEST.in MANIFEST.in
19+
COPY LICENSE LICENSE
20+
COPY README.md README.md
21+
COPY pyproject.toml pyproject.toml
22+
23+
RUN pip install --no-cache-dir ".[stable,gui-stable]"
24+
25+
ENV PORT=41215
26+
EXPOSE 41215
27+
28+
# to allow other host ports than 41215
29+
ENV BOKEH_ALLOW_WS_ORIGIN=localhost
30+
31+
CMD ["/usr/local/bin/directlfq", "gui", "--port", "41215"]
32+
33+
# build & run:
34+
# docker build --progress=plain -t directlfq .
35+
# DATA_FOLDER=/path/to/local/data
36+
# docker run -p 41215:41215 -v $DATA_FOLDER:/app/data/ -t directlfq

README.md

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,18 @@ With directLFQ, we provide a novel algorithm for addressing these challenges in
5252
directLFQ can be installed and used on all major operating systems (Windows, macOS and Linux).
5353
There are currently two different types of installation possible:
5454

55-
* [**One-click GUI installer:**](#one-click-gui) Choose this installation if you only want the GUI and/or keep things as simple as possible.
56-
<!---
57-
* [**Pip installer:**](#pip) Choose this installation if you want to use directlfq as a Python package in an existing Python 3.9 environment (e.g. a Jupyter notebook). If needed, the GUI and CLI can be installed with pip as well.
58-
-->
59-
* [**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 directlfq and even allows to modify its source code directly. Generally, the developer version of directlfq outperforms the precompiled versions which makes this the installation of choice for high-throughput experiments.
55+
* [**One-click GUI installation:**](#one-click-gui-installation) Choose this installation if you only want the GUI and/or keep things as simple as possible.
56+
* [**Pip installation:**](#pip-installation) Choose this installation if you want to use directlfq as a Python package in an existing Python 3.9 environment (e.g. a Jupyter notebook). If needed, the GUI and CLI can be installed with pip as well.
57+
* [**Developer installation:**](#developer-installation) 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 directlfq and even allows to modify its source code directly. Generally, the developer version of directlfq outperforms the precompiled versions which makes this the installation of choice for high-throughput experiments.
58+
- [**Docker installation:**](#docker-installation) Choose this installation if you want to use directlfq without any changes to your system.
6059

61-
### One-click GUI
60+
### One-click GUI installation
6261

6362
The GUI of directlfq is a completely stand-alone tool that requires no knowledge of Python or CLI tools. Click [**here**](https://github.com/MannLabs/directlfq/releases/latest/) to download the latest release for either Windows, macOS or Linux.
6463

6564
Older releases remain available on the [release page](https://github.com/MannLabs/directlfq/releases), but no backwards compatibility is guaranteed.
6665

67-
### Pip
66+
### Pip installation
6867

6968
directLFQ can be installed in an existing Python 3.9 environment with a single `bash` command.
7069

@@ -93,7 +92,7 @@ For those who are really adventurous, it is also possible to directly install an
9392
pip install "git+https://github.com/MannLabs/directlfq.git@development#egg=directlfq[stable,development]"
9493
```
9594

96-
### Developer
95+
### Developer installation
9796

9897
directlfq can also be installed in editable (i.e. developer) mode with a few `bash` commands. This allows to fully customize the software and even modify the source code to your specific needs. When an editable Python package is installed, its source code is stored in a transparent location of your choice. While optional, it is advised to first (create and) navigate to e.g. a general software folder:
9998

@@ -127,7 +126,42 @@ By default this installs loose dependencies (no explicit versioning), although i
127126

128127
***By using the editable flag `-e`, all modifications to the [directlfq source code folder](directlfq) are directly reflected when running directlfq. Note that the directlfq folder cannot be moved and/or renamed if an editable version is installed. In case of confusion, you can always retrieve the location of any Python module with e.g. the command `import module` followed by `module.__file__`.***
129128

129+
130+
### Docker installation
131+
The containerized version can be used to run directlfq without any installation to your system.
132+
133+
#### 1. Setting up Docker
134+
Install the latest version of docker (https://docs.docker.com/engine/install/).
135+
136+
#### 2. Prepare folder structure
137+
Set up your data to match the expected folder structure:
138+
create a folder and store its name in a variable, and specify a port
139+
```
140+
DATA_FOLDER=/home/username/data; mkdir -p $DATA_FOLDER
141+
PORT=41215
142+
```
143+
144+
#### 3. Start the container
145+
```bash
146+
docker run -v $DATA_FOLDER:/app/data -p $PORT:41215 mannlabs/directlfq:latest
147+
```
148+
After initial download of the container, directlfq will start running immediately,
149+
and can be accessed under [localhost:$PORT](http://localhost:41215).
150+
151+
Note: in the app, the local `$DATA_FOLDER` needs to be referred to as "`/app/data`".
152+
153+
#### Alternatively: Build the image yourself
154+
If you want to build the image yourself, you can do so by
155+
```bash
156+
docker build -t directlfq .
157+
```
158+
and run it with
159+
```bash
160+
docker run -p $PORT:8501 -v $DATA_FOLDER:/app/data -t directlfq
161+
```
162+
130163
---
164+
131165
## Running directLFQ
132166

133167
There are three ways to use directlfq:

directlfq/cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,10 @@ def run(ctx, **kwargs):
177177
click.echo(run.get_help(ctx))
178178

179179
@run.command("gui", help="Start graphical user interface.")
180-
def gui():
180+
@click.option("--port", "-p", type=int, default=None, help="Port to run the GUI server on (default: 41215 or PORT environment variable)")
181+
def gui(port):
181182
import directlfq.gui
182-
directlfq.gui.run()
183+
directlfq.gui.run(port=port)
183184

184185
list_of_format_names = ["alphapept_peptides","fragpipe_precursors","maxquant_evidence","maxquant_peptides","diann_fragion_isotopes","diann_precursors","spectronaut_fragion_isotopes","spectronaut_precursor"]
185186

directlfq/gui.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def __init__(
4343
github_url,
4444
run_in_background=False,
4545
automatic_close=True,
46+
port=None,
4647
):
4748
self.name = name
4849
self.tab_counter = 0
@@ -61,6 +62,7 @@ def __init__(
6162
)
6263
self.run_in_background = run_in_background
6364
self.automatic_close = automatic_close
65+
self.port = int(port) if port else port
6466

6567
def start_server(self, run_in_background=False):
6668
if self.automatic_close:
@@ -73,7 +75,9 @@ def start_server(self, run_in_background=False):
7375
bokeh_ws_handler.on_close = self.__close_browser_tab(
7476
self.bokeh_server_on_close
7577
)
76-
self.server = self.layout.show(threaded=True, title=self.name)
78+
79+
port_param = {} if self.port is None else {"port": self.port}
80+
self.server = self.layout.show(threaded=True, title=self.name, **port_param)
7781
if not run_in_background:
7882
self.server.join()
7983
elif not self.run_in_background:
@@ -105,10 +109,11 @@ def stop_server(self):
105109

106110
class AlphaQuantGUI(GUI):
107111
# TODO: docstring
108-
def __init__(self, start_server=False):
112+
def __init__(self, start_server=False, port=None):
109113
super().__init__(
110114
name="directLFQ",
111115
github_url='https://github.com/MannLabs/directLFQ',
116+
port=port,
112117
)
113118
self.project_description = """### directLFQ provides ratio-based normalization and protein intensity estimation for small and very large numbers of proteomes."""
114119
self.manual_path = os.path.join(
@@ -136,8 +141,8 @@ def __init__(self, start_server=False):
136141
self.start_server()
137142

138143

139-
def run():
140-
AlphaQuantGUI(start_server=True)
144+
def run(port=None):
145+
AlphaQuantGUI(start_server=True, port=port)
141146

142147

143148
if __name__ == '__main__':

0 commit comments

Comments
 (0)