Skip to content

Commit a301e1a

Browse files
authored
chore: make docker compose work (#707)
1 parent 29fc11d commit a301e1a

File tree

11 files changed

+333
-257
lines changed

11 files changed

+333
-257
lines changed

Dockerfile

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,46 @@
1+
# Build stage for dlptool
12
FROM curlimages/curl:8.4.0 AS downloader
3+
RUN curl -sL http://kubeblocks.oss-cn-hangzhou.aliyuncs.com/dlptool -o /tmp/dlptool
24

3-
RUN curl -sL http://kubeblocks.oss-cn-hangzhou.aliyuncs.com/dlptool -o /tmp/dlptool
5+
# Build stage for dependencies
6+
FROM python:3.11.1-slim AS builder
47

8+
# Install system dependencies
9+
RUN apt update && \
10+
apt install --no-install-recommends -y build-essential git curl && \
11+
apt clean && \
12+
rm -rf /var/lib/apt/lists/*
513

6-
FROM python:3.11.1-slim
14+
# Install Poetry
15+
RUN curl -sSL https://install.python-poetry.org | python3 - && \
16+
cd /usr/local/bin && \
17+
ln -s /root/.local/bin/poetry && \
18+
poetry config virtualenvs.create false
719

8-
RUN apt update && \
9-
apt install --no-install-recommends -y build-essential git
20+
# Copy poetry files
21+
COPY pyproject.toml poetry.lock* ./
1022

11-
COPY requirements.txt /requirements.txt
23+
# Install dependencies
24+
RUN poetry install --no-interaction --no-ansi --no-root
1225

13-
RUN pip install -r /requirements.txt && pip cache purge
26+
# Final stage
27+
FROM python:3.11.1-slim
1428

15-
COPY . /app
29+
# Install minimal system dependencies
30+
RUN apt update && \
31+
apt install --no-install-recommends -y curl && \
32+
apt clean && \
33+
rm -rf /var/lib/apt/lists/*
1634

35+
# Copy only necessary files from builder
36+
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
37+
COPY --from=builder /usr/local/bin /usr/local/bin
1738
COPY --from=downloader /tmp/dlptool /bin/dlptool
18-
1939
RUN chmod +x /bin/dlptool
2040

41+
# Copy application code
42+
COPY . /app
43+
2144
WORKDIR /app
2245

2346
ENTRYPOINT ["/app/scripts/entrypoint.sh"]

Makefile

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,31 @@ BUILDX_PLATFORM ?= linux/amd64
55
BUILDX_ARGS ?= --sbom=false --provenance=false
66
REGISTRY ?= registry.cn-hangzhou.aliyuncs.com
77

8-
init:
9-
cp envs/.env.template .env
10-
cp envs/.env.frontend.template .env.frontend
11-
128
.PHONY: version
139
version:
1410
@git rev-parse HEAD | cut -c1-7 > commit_id.txt
1511
@echo "VERSION = '$(VERSION)'" > $(VERSION_FILE)
1612
@echo "GIT_COMMIT_ID = '$$(cat commit_id.txt)'" >> $(VERSION_FILE)
1713
@rm commit_id.txt
1814

19-
build-requirements:
20-
sh scripts/export-requirements.sh
15+
.PHONY: image
16+
17+
# Create a new builder instance for multi-platform builds
18+
setup-builder:
19+
@if ! docker buildx inspect multi-platform >/dev/null 2>&1; then \
20+
docker buildx create --name multi-platform --use --driver docker-container; \
21+
else \
22+
docker buildx use multi-platform; \
23+
fi
24+
25+
# Build and push multi-platform image
26+
image: setup-builder
27+
docker buildx build -t $(REGISTRY)/apecloud/aperag:$(VERSION) --platform $(BUILDX_PLATFORM) $(BUILDX_ARGS) --push -f ./Dockerfile .
28+
cd web && docker buildx build -t $(REGISTRY)/apecloud/aperag-frontend:$(VERSION) --platform $(BUILDX_PLATFORM) $(BUILDX_ARGS) --push -f ./Dockerfile .
2129

22-
image: build-requirements version
23-
docker buildx build -t $(REGISTRY)/apecloud/aperag:$(VERSION) --platform $(BUILDX_PLATFORM) $(BUILDX_ARGS) --push -f ./Dockerfile .
30+
# Clean up builder instance
31+
clean-builder:
32+
docker buildx rm multi-platform
2433

2534
diff:
2635
@python manage.py diffsettings

README.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,38 @@
22

33
ApeRAG is a powerful RAG system that deeply analyzes documents and multimedia content while building vector indexes in parallel and measuring retrieval quality. It streamlines workflows with integrated LLM management, data source handling, automatic syncing, and seamless office tool compatibility.
44

5+
## User Guide
6+
7+
### Prerequisites
8+
9+
- Docker
10+
- Docker Compose
11+
- Git
12+
13+
### Quick Start
14+
15+
1. Configure environment variables:
16+
```bash
17+
cp envs/docker.env.template .docker.env
18+
cp web/deploy/env.local.template web/.env
19+
```
20+
21+
2. (Optional) use aliyun image registry if you are in China:
22+
```bash
23+
export REGISTRY=apecloud-registry.cn-zhangjiakou.cr.aliyuncs.com
24+
```
25+
26+
3. Start the services:
27+
```bash
28+
docker compose up -d
29+
```
30+
31+
4. Access the services: http://localhost:80
32+
33+
## License
34+
35+
[Your License Here]
36+
537
# Development Guide
638

739
You should install Python 3.11 first.
@@ -24,7 +56,7 @@ poetry install --with model
2456
* prepare configs
2557

2658
```bash
27-
cp envs/.env.template .env
59+
cp envs/env.template .env
2860
```
2961

3062
* prepare postgres/redis/qdrant/elasticsearch
@@ -63,5 +95,4 @@ To debug celery service, see [HOW-TO-DEBUG.md](docs%2FHOW-TO-DEBUG.md)
6395
make run-frontend
6496
```
6597

66-
6798
then open the aperag frontend console: http://localhost:8001

docker-compose.yml

Lines changed: 96 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,135 @@
1-
version: '3'
2-
31
volumes:
4-
aperag_postgres_data: {}
5-
aperag_qdrant_data: {}
2+
aperag-postgres-data: {}
3+
aperag-qdrant-data: {}
4+
aperag-redis-data: {}
5+
aperag-es-data: {}
66

77
services:
88
django: &django
99
build:
1010
context: .
1111
dockerfile: ./Dockerfile
12-
image: aperag_django
13-
container_name: aperag_django
12+
image: ${REGISTRY:-docker.io}/apecloud/aperag:${VERSION:-v0.1.2}
13+
container_name: aperag-django
1414
depends_on:
1515
- postgres
1616
- redis
1717
- qdrant
18+
- es
1819
volumes:
1920
- .:/app:z
2021
- ~/.cache:/root/.cache
2122
env_file:
22-
- .docker-env
23+
- .docker.env
2324
ports:
2425
- "8000:8000"
25-
command: /app/scripts/start-django.sh
26+
entrypoint: /app/scripts/start-django.sh
2627

27-
postgres:
28-
image: postgres:14
29-
container_name: aperag_postgres
30-
volumes:
31-
- aperag_postgres_data:/var/lib/postgresql/data
28+
frontend:
29+
build:
30+
context: ./web
31+
dockerfile: ./Dockerfile
32+
image: ${REGISTRY:-docker.io}/apecloud/aperag-frontend:${VERSION:-v0.1.2}
33+
container_name: aperag-frontend
34+
depends_on:
35+
- django
3236
env_file:
33-
- .docker-env
34-
35-
redis:
36-
image: redis:6
37-
container_name: aperag_redis
38-
39-
qdrant:
40-
image: qdrant/qdrant
41-
container_name: aperag_qdrant
42-
volumes:
43-
- aperag_qdrant_data:/qdrant/storage
37+
- web/.env
38+
environment:
39+
- APERAG_CONSOLE_SERVICE_HOST=aperag-django
40+
- APERAG_CONSOLE_SERVICE_PORT=8000
41+
ports:
42+
- "8001:80"
4443

4544
celeryworker:
46-
<<: *django
47-
image: aperag_django
48-
container_name: aperag_celeryworker
45+
image: ${REGISTRY:-docker.io}/apecloud/aperag:${VERSION:-v0.1.2}
46+
build:
47+
context: .
48+
dockerfile: ./Dockerfile
49+
container_name: aperag-celeryworker
4950
depends_on:
5051
- redis
5152
- postgres
5253
- qdrant
54+
- es
5355
volumes:
5456
- .:/app:z
5557
- ~/.cache:/root/.cache
5658
- ./resources:/Users/ziang/git/ApeRAG/resources
57-
ports: []
58-
command: /app/scripts/start-celery-worker.sh
59+
env_file:
60+
- .docker.env
61+
environment:
62+
- NODE_IP=aperag-celeryworker
63+
entrypoint: /app/scripts/start-celery-worker.sh
5964

6065
celerybeat:
61-
<<: *django
62-
image: aperag_django
63-
container_name: aperag_celerybeat
66+
image: ${REGISTRY:-docker.io}/apecloud/aperag:${VERSION:-v0.1.2}
67+
build:
68+
context: .
69+
dockerfile: ./Dockerfile
70+
container_name: aperag-celerybeat
71+
env_file:
72+
- .docker.env
6473
depends_on:
6574
- redis
6675
- postgres
67-
ports: []
68-
command: /app/scripts/start-celery-beat.sh
76+
environment:
77+
- NODE_IP=aperag-celerybeat
78+
entrypoint: /app/scripts/start-celery-beat.sh
6979

7080
flower:
7181
<<: *django
72-
image: aperag_django
73-
container_name: aperag_flower
82+
image: ${REGISTRY:-docker.io}/apecloud/aperag:${VERSION:-v0.1.2}
83+
build:
84+
context: .
85+
dockerfile: ./Dockerfile
86+
container_name: aperag-flower
87+
env_file:
88+
- .docker.env
7489
ports:
7590
- "5555:5555"
76-
command: /app/scripts/start-celery-flower.sh
91+
environment:
92+
- NODE_IP=aperag-flower
93+
entrypoint: /app/scripts/start-celery-flower.sh
94+
95+
postgres:
96+
image: postgres:14
97+
container_name: aperag-postgres
98+
volumes:
99+
- aperag-postgres-data:/var/lib/postgresql/data
100+
ports:
101+
- "5432:5432"
102+
environment:
103+
- POSTGRES_PASSWORD=postgres
104+
- POSTGRES_USER=postgres
105+
- POSTGRES_DB=aperag
106+
107+
redis:
108+
image: redis:6
109+
container_name: aperag-redis
110+
volumes:
111+
- aperag-redis-data:/data
112+
ports:
113+
- "6379:6379"
114+
115+
qdrant:
116+
image: qdrant/qdrant:v1.13.4
117+
container_name: aperag-qdrant
118+
volumes:
119+
- aperag-qdrant-data:/qdrant/storage
120+
ports:
121+
- "6333:6333"
122+
123+
es:
124+
image: elasticsearch:8.8.2
125+
container_name: aperag-es
126+
ports:
127+
- "9200:9200"
128+
environment:
129+
- "discovery.type=single-node"
130+
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
131+
- "xpack.security.enabled=false"
132+
volumes:
133+
- aperag-es-data:/usr/share/elasticsearch/data
134+
- ./scripts/init-es.sh:/usr/share/elasticsearch/bin/init-es.sh
135+
command: bash /usr/share/elasticsearch/bin/init-es.sh

0 commit comments

Comments
 (0)