Skip to content

Commit 184197b

Browse files
committed
build: docker compose
1 parent 1bb9554 commit 184197b

File tree

6 files changed

+70
-12
lines changed

6 files changed

+70
-12
lines changed

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@ git submodule update --init --recursive
3232

3333
**Docker deployment**
3434
```sh
35-
# build docker image
36-
docker build -t lires:latest .
37-
38-
# create a conainer and start the servers
39-
docker run -d -p 8080:8080 -p 8081:8081 -v $HOME/.Lires:/root/.Lires --name lrs lires:latest
35+
docker compose up
4036

4137
# register a user and download pdf.js viewer on the first run
4238
# (no need to run again if the container is re-created / re-started)
@@ -45,7 +41,6 @@ docker exec lrs lrs-utils download_pdfjs
4541
```
4642
Now open the browser and visit the WebUI on `http://localhost:8081`.
4743

48-
Docker deployment is a quick way to deploy the server, but it has some limitations.
4944
**Please refer to the documents for more details on [getting started](docs/gettingStarted.md).**
5045

5146
# Manuals and documentations

compose.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
services:
3+
4+
web:
5+
container_name: lrs_web
6+
build:
7+
context: .
8+
dockerfile: ./docker/web.Dockerfile
9+
ports:
10+
- "8081:80"
11+
networks:
12+
- lires_net
13+
14+
server:
15+
container_name: lrs
16+
build:
17+
context: .
18+
dockerfile: ./docker/server.Dockerfile
19+
ports:
20+
- "8080:8080"
21+
# - "8731:8731"
22+
volumes:
23+
- "$HOME/.Lires:/root/.Lires"
24+
networks:
25+
- lires_net
26+
27+
ai:
28+
container_name: lrs_ai
29+
build:
30+
context: .
31+
dockerfile: ./docker/iserver.Dockerfile
32+
# ports:
33+
# - "8731:8731"
34+
volumes:
35+
- "$HOME/.Lires:/root/.Lires"
36+
environment:
37+
- OPENAI_API_KEY=sk-1234567890abcdef1234567890abcdef
38+
- OPENAI_API_BASE=https://api.openai.com/v1
39+
deploy:
40+
resources:
41+
reservations:
42+
devices:
43+
- driver: "nvidia"
44+
count: "all"
45+
capabilities: [gpu]
46+
networks:
47+
- lires_net
48+
49+
networks:
50+
lires_net:
51+
driver: bridge
File renamed without changes.

docker/iserver.Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
FROM python:3.11-bookworm as iserver-build
1+
FROM nvcr.io/nvidia/driver:535.104.12-ubuntu22.04
22
WORKDIR /
33
COPY . /Lires
44

5-
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources
5+
RUN apt-get update && apt-get install -y python3 python3-pip
66
RUN pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
77

88
# Install rust and make sure it's up to date and using stable channel
99
# RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
1010
# RUN rustup update
1111

12-
RUN python3 -m pip install --upgrade pip --break-system-packages
13-
RUN pip3 install -e /Lires[ai] --break-system-packages
12+
RUN python3 -m pip install --upgrade pip
13+
RUN pip3 install -e /Lires[ai]
1414

1515
EXPOSE 8731
1616

docs/gettingStarted.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,17 @@ lrs-index build
149149
## Docker deployment
150150
Instead of installing the server, you can also deploy the server using docker.
151151
Which adds additional security and building efficiency.
152+
153+
### Method 1 - Use docker compose (recommended)
154+
**Nvidia container toolkit should be installed**
155+
```sh
156+
docker compose up
157+
```
158+
159+
### Method 2 - Use the cluster image
152160
```sh
153161
# creates a docker image named lires
154-
docker build -t lires:latest .
162+
docker build -f ./docker/cluster.Dockerfile -t lires:latest .
155163

156164
# create the container named 'lrs',
157165
# please change the port mapping and volume mapping as needed
@@ -171,6 +179,7 @@ Instead, we can set the server settings pointing to the shared LiresAI server ou
171179
>
172180
> For example, if the LiresAI server is running on the host machine with IP address `192.168.3.6:8731`, then we can set the `iserver_host` to `192.168.3.6` and `iserver_port` to `8731`.
173181
182+
### On the first run
174183
**On the first run** you need to generate the user key, which can be done by running the `lrs-keyman` command in the container.
175184
and you also need to download the pdf.js viewer to serve pdf with the viewer in LiresWeb.
176185
The user information and pdf.js viewer will be stored in the volume mapping directory, so that they will not be lost when the container is removed.

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,17 @@ dependencies = [
4040
"pyyaml",
4141
"requests",
4242
"deprecated",
43+
44+
# used by both core and ai, may be removed in the future
45+
"markdown",
46+
"pyperclip",
4347
]
4448

4549
[project.optional-dependencies]
4650
core = [
4751
"pybtex",
4852
"pylatexenc",
4953
"tornado",
50-
"pyperclip",
5154
"PyMuPDF",
5255
"markdown",
5356
"nest_asyncio",

0 commit comments

Comments
 (0)