chore: Refactor docker compose (#2531)
* chore: docker compose dev with local build * chore: docker compose with prebuilt image on ghcr * fix: Update readme and by comments
This commit is contained in:
parent
3ecdb81881
commit
e60807f867
@ -240,6 +240,7 @@ This will build the app MacOS m1/m2 for production (with code signing already do
|
|||||||
- If you intend to run Jan in GPU mode, you need to install `nvidia-driver` and `nvidia-docker2`. Follow the instruction [here](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) for installation.
|
- If you intend to run Jan in GPU mode, you need to install `nvidia-driver` and `nvidia-docker2`. Follow the instruction [here](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) for installation.
|
||||||
|
|
||||||
- Run Jan in Docker mode
|
- Run Jan in Docker mode
|
||||||
|
> User can choose between `docker-compose.yml` with latest prebuilt docker image or `docker-compose-dev.yml` with local docker build
|
||||||
|
|
||||||
| Docker compose Profile | Description |
|
| Docker compose Profile | Description |
|
||||||
| ---------------------- | -------------------------------------------- |
|
| ---------------------- | -------------------------------------------- |
|
||||||
|
|||||||
171
docker-compose-dev.yml
Normal file
171
docker-compose-dev.yml
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
# Docker Compose file for setting up Minio, createbuckets, app_cpu, and app_gpu services
|
||||||
|
|
||||||
|
version: '3.7'
|
||||||
|
|
||||||
|
services:
|
||||||
|
# Minio service for object storage
|
||||||
|
minio:
|
||||||
|
image: minio/minio
|
||||||
|
volumes:
|
||||||
|
- minio_data:/data
|
||||||
|
ports:
|
||||||
|
- '9000:9000'
|
||||||
|
- '9001:9001'
|
||||||
|
environment:
|
||||||
|
# Set the root user and password for Minio
|
||||||
|
MINIO_ROOT_USER: minioadmin # This acts as AWS_ACCESS_KEY
|
||||||
|
MINIO_ROOT_PASSWORD: minioadmin # This acts as AWS_SECRET_ACCESS_KEY
|
||||||
|
command: server --console-address ":9001" /data
|
||||||
|
restart: always
|
||||||
|
healthcheck:
|
||||||
|
test: ['CMD', 'curl', '-f', 'http://localhost:9000/minio/health/live']
|
||||||
|
interval: 30s
|
||||||
|
timeout: 20s
|
||||||
|
retries: 3
|
||||||
|
networks:
|
||||||
|
vpcbr:
|
||||||
|
ipv4_address: 10.5.0.2
|
||||||
|
|
||||||
|
# createbuckets service to create a bucket and set its policy
|
||||||
|
createbuckets:
|
||||||
|
image: minio/mc
|
||||||
|
depends_on:
|
||||||
|
- minio
|
||||||
|
entrypoint: >
|
||||||
|
/bin/sh -c "
|
||||||
|
/usr/bin/mc alias set myminio http://minio:9000 minioadmin minioadmin;
|
||||||
|
/usr/bin/mc mb myminio/mybucket;
|
||||||
|
/usr/bin/mc policy set public myminio/mybucket;
|
||||||
|
exit 0;
|
||||||
|
"
|
||||||
|
networks:
|
||||||
|
vpcbr:
|
||||||
|
|
||||||
|
# app_cpu service for running the CPU version of the application
|
||||||
|
app_cpu_s3fs:
|
||||||
|
image: jan:latest
|
||||||
|
volumes:
|
||||||
|
- app_data_cpu_s3fs:/app/server/build/jan
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
environment:
|
||||||
|
# Set the AWS access key, secret access key, bucket name, endpoint, and region for app_cpu
|
||||||
|
AWS_ACCESS_KEY_ID: minioadmin
|
||||||
|
AWS_SECRET_ACCESS_KEY: minioadmin
|
||||||
|
S3_BUCKET_NAME: mybucket
|
||||||
|
AWS_ENDPOINT: http://10.5.0.2:9000
|
||||||
|
AWS_REGION: us-east-1
|
||||||
|
API_BASE_URL: http://localhost:1337
|
||||||
|
restart: always
|
||||||
|
profiles:
|
||||||
|
- cpu-s3fs
|
||||||
|
ports:
|
||||||
|
- '3000:3000'
|
||||||
|
- '1337:1337'
|
||||||
|
- '3928:3928'
|
||||||
|
networks:
|
||||||
|
vpcbr:
|
||||||
|
ipv4_address: 10.5.0.3
|
||||||
|
|
||||||
|
# app_gpu service for running the GPU version of the application
|
||||||
|
app_gpu_s3fs:
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
reservations:
|
||||||
|
devices:
|
||||||
|
- driver: nvidia
|
||||||
|
count: all
|
||||||
|
capabilities: [gpu]
|
||||||
|
image: jan-gpu:latest
|
||||||
|
volumes:
|
||||||
|
- app_data_gpu_s3fs:/app/server/build/jan
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.gpu
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
# Set the AWS access key, secret access key, bucket name, endpoint, and region for app_gpu
|
||||||
|
AWS_ACCESS_KEY_ID: minioadmin
|
||||||
|
AWS_SECRET_ACCESS_KEY: minioadmin
|
||||||
|
S3_BUCKET_NAME: mybucket
|
||||||
|
AWS_ENDPOINT: http://10.5.0.2:9000
|
||||||
|
AWS_REGION: us-east-1
|
||||||
|
API_BASE_URL: http://localhost:1337
|
||||||
|
profiles:
|
||||||
|
- gpu-s3fs
|
||||||
|
ports:
|
||||||
|
- '3000:3000'
|
||||||
|
- '1337:1337'
|
||||||
|
- '3928:3928'
|
||||||
|
networks:
|
||||||
|
vpcbr:
|
||||||
|
ipv4_address: 10.5.0.4
|
||||||
|
|
||||||
|
app_cpu_fs:
|
||||||
|
image: jan:latest
|
||||||
|
volumes:
|
||||||
|
- app_data_cpu_fs:/app/server/build/jan
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
environment:
|
||||||
|
API_BASE_URL: http://localhost:1337
|
||||||
|
restart: always
|
||||||
|
profiles:
|
||||||
|
- cpu-fs
|
||||||
|
ports:
|
||||||
|
- '3000:3000'
|
||||||
|
- '1337:1337'
|
||||||
|
- '3928:3928'
|
||||||
|
networks:
|
||||||
|
vpcbr:
|
||||||
|
ipv4_address: 10.5.0.5
|
||||||
|
|
||||||
|
# app_gpu service for running the GPU version of the application
|
||||||
|
app_gpu_fs:
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
reservations:
|
||||||
|
devices:
|
||||||
|
- driver: nvidia
|
||||||
|
count: all
|
||||||
|
capabilities: [gpu]
|
||||||
|
image: jan-gpu:latest
|
||||||
|
volumes:
|
||||||
|
- app_data_gpu_fs:/app/server/build/jan
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.gpu
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
API_BASE_URL: http://localhost:1337
|
||||||
|
profiles:
|
||||||
|
- gpu-fs
|
||||||
|
ports:
|
||||||
|
- '3000:3000'
|
||||||
|
- '1337:1337'
|
||||||
|
- '3928:3928'
|
||||||
|
networks:
|
||||||
|
vpcbr:
|
||||||
|
ipv4_address: 10.5.0.6
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
minio_data:
|
||||||
|
app_data_cpu_s3fs:
|
||||||
|
app_data_gpu_s3fs:
|
||||||
|
app_data_cpu_fs:
|
||||||
|
app_data_gpu_fs:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
vpcbr:
|
||||||
|
driver: bridge
|
||||||
|
ipam:
|
||||||
|
config:
|
||||||
|
- subnet: 10.5.0.0/16
|
||||||
|
gateway: 10.5.0.1
|
||||||
|
# Usage:
|
||||||
|
# - Run 'docker compose -f docker-compose-dev.yml --profile cpu-s3fs up -d' to start the app_cpu service
|
||||||
|
# - Run 'docker compose -f docker-compose-dev.yml --profile gpu-s3fs up -d' to start the app_gpu service
|
||||||
|
# - Run 'docker compose -f docker-compose-dev.yml --profile cpu-fs up -d' to start the app_cpu service
|
||||||
|
# - Run 'docker compose -f docker-compose-dev.yml --profile gpu-fs up -d' to start the app_gpu service
|
||||||
@ -9,8 +9,8 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- minio_data:/data
|
- minio_data:/data
|
||||||
ports:
|
ports:
|
||||||
- "9000:9000"
|
- '9000:9000'
|
||||||
- "9001:9001"
|
- '9001:9001'
|
||||||
environment:
|
environment:
|
||||||
# Set the root user and password for Minio
|
# Set the root user and password for Minio
|
||||||
MINIO_ROOT_USER: minioadmin # This acts as AWS_ACCESS_KEY
|
MINIO_ROOT_USER: minioadmin # This acts as AWS_ACCESS_KEY
|
||||||
@ -18,7 +18,7 @@ services:
|
|||||||
command: server --console-address ":9001" /data
|
command: server --console-address ":9001" /data
|
||||||
restart: always
|
restart: always
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
test: ['CMD', 'curl', '-f', 'http://localhost:9000/minio/health/live']
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 20s
|
timeout: 20s
|
||||||
retries: 3
|
retries: 3
|
||||||
@ -43,12 +43,9 @@ services:
|
|||||||
|
|
||||||
# app_cpu service for running the CPU version of the application
|
# app_cpu service for running the CPU version of the application
|
||||||
app_cpu_s3fs:
|
app_cpu_s3fs:
|
||||||
image: jan:latest
|
|
||||||
volumes:
|
volumes:
|
||||||
- app_data_cpu_s3fs:/app/server/build/jan
|
- app_data_cpu_s3fs:/app/server/build/jan
|
||||||
build:
|
image: ghcr.io/janhq/jan-server:dev-cpu-latest
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
environment:
|
environment:
|
||||||
# Set the AWS access key, secret access key, bucket name, endpoint, and region for app_cpu
|
# Set the AWS access key, secret access key, bucket name, endpoint, and region for app_cpu
|
||||||
AWS_ACCESS_KEY_ID: minioadmin
|
AWS_ACCESS_KEY_ID: minioadmin
|
||||||
@ -61,9 +58,9 @@ services:
|
|||||||
profiles:
|
profiles:
|
||||||
- cpu-s3fs
|
- cpu-s3fs
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- '3000:3000'
|
||||||
- "1337:1337"
|
- '1337:1337'
|
||||||
- "3928:3928"
|
- '3928:3928'
|
||||||
networks:
|
networks:
|
||||||
vpcbr:
|
vpcbr:
|
||||||
ipv4_address: 10.5.0.3
|
ipv4_address: 10.5.0.3
|
||||||
@ -77,12 +74,9 @@ services:
|
|||||||
- driver: nvidia
|
- driver: nvidia
|
||||||
count: all
|
count: all
|
||||||
capabilities: [gpu]
|
capabilities: [gpu]
|
||||||
image: jan-gpu:latest
|
image: ghcr.io/janhq/jan-server:dev-cuda-12.2-latest
|
||||||
volumes:
|
volumes:
|
||||||
- app_data_gpu_s3fs:/app/server/build/jan
|
- app_data_gpu_s3fs:/app/server/build/jan
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile.gpu
|
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
# Set the AWS access key, secret access key, bucket name, endpoint, and region for app_gpu
|
# Set the AWS access key, secret access key, bucket name, endpoint, and region for app_gpu
|
||||||
@ -95,29 +89,26 @@ services:
|
|||||||
profiles:
|
profiles:
|
||||||
- gpu-s3fs
|
- gpu-s3fs
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- '3000:3000'
|
||||||
- "1337:1337"
|
- '1337:1337'
|
||||||
- "3928:3928"
|
- '3928:3928'
|
||||||
networks:
|
networks:
|
||||||
vpcbr:
|
vpcbr:
|
||||||
ipv4_address: 10.5.0.4
|
ipv4_address: 10.5.0.4
|
||||||
|
|
||||||
app_cpu_fs:
|
app_cpu_fs:
|
||||||
image: jan:latest
|
image: ghcr.io/janhq/jan-server:dev-cpu-latest
|
||||||
volumes:
|
volumes:
|
||||||
- app_data_cpu_fs:/app/server/build/jan
|
- app_data_cpu_fs:/app/server/build/jan
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
environment:
|
environment:
|
||||||
API_BASE_URL: http://localhost:1337
|
API_BASE_URL: http://localhost:1337
|
||||||
restart: always
|
restart: always
|
||||||
profiles:
|
profiles:
|
||||||
- cpu-fs
|
- cpu-fs
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- '3000:3000'
|
||||||
- "1337:1337"
|
- '1337:1337'
|
||||||
- "3928:3928"
|
- '3928:3928'
|
||||||
networks:
|
networks:
|
||||||
vpcbr:
|
vpcbr:
|
||||||
ipv4_address: 10.5.0.5
|
ipv4_address: 10.5.0.5
|
||||||
@ -131,21 +122,18 @@ services:
|
|||||||
- driver: nvidia
|
- driver: nvidia
|
||||||
count: all
|
count: all
|
||||||
capabilities: [gpu]
|
capabilities: [gpu]
|
||||||
image: jan-gpu:latest
|
image: ghcr.io/janhq/jan-server:dev-cuda-12.2-latest
|
||||||
volumes:
|
volumes:
|
||||||
- app_data_gpu_fs:/app/server/build/jan
|
- app_data_gpu_fs:/app/server/build/jan
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile.gpu
|
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
API_BASE_URL: http://localhost:1337
|
API_BASE_URL: http://localhost:1337
|
||||||
profiles:
|
profiles:
|
||||||
- gpu-fs
|
- gpu-fs
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- '3000:3000'
|
||||||
- "1337:1337"
|
- '1337:1337'
|
||||||
- "3928:3928"
|
- '3928:3928'
|
||||||
networks:
|
networks:
|
||||||
vpcbr:
|
vpcbr:
|
||||||
ipv4_address: 10.5.0.6
|
ipv4_address: 10.5.0.6
|
||||||
@ -164,7 +152,6 @@ networks:
|
|||||||
config:
|
config:
|
||||||
- subnet: 10.5.0.0/16
|
- subnet: 10.5.0.0/16
|
||||||
gateway: 10.5.0.1
|
gateway: 10.5.0.1
|
||||||
|
|
||||||
# Usage:
|
# Usage:
|
||||||
# - Run 'docker compose --profile cpu-s3fs up -d' to start the app_cpu service
|
# - Run 'docker compose --profile cpu-s3fs up -d' to start the app_cpu service
|
||||||
# - Run 'docker compose --profile gpu-s3fs up -d' to start the app_gpu service
|
# - Run 'docker compose --profile gpu-s3fs up -d' to start the app_gpu service
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user