Skip to content

Commit

Permalink
Feat configure MinIO for file storage and update environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
minai621 authored and devleejb committed Nov 26, 2024
1 parent 81244e4 commit 424170d
Show file tree
Hide file tree
Showing 6 changed files with 1,922 additions and 1,877 deletions.
41 changes: 20 additions & 21 deletions backend/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,26 @@ LANGCHAIN_API_KEY=your_langsmith_api_key_here
# To create a LangSmith project, visit LangSmith: https://www.langchain.com/langsmith
LANGCHAIN_PROJECT=your_langsmith_project_name_here

# FILE_UPLOAD: Whether to enable file upload to storage
# Available options: false, s3, minio
# If set to false, AWS_S3_BUCKET_NAME is not required.
# Set to true if file upload is required.
# FILE_UPLOAD: Whether to enable file upload to storage.
# Available options: false, s3, minio.
# Set to "false" if file upload is not required.
# Set to "s3" or "minio" to enable file uploads.
FILE_UPLOAD=minio
# Storage configuration for either AWS S3 or MinIO
# This is the name of the S3 Bucket or MinIO Bucket
# BUCKET_NAME: The name of the S3 or MinIO bucket to use.
# Required only if FILE_UPLOAD is set to "s3" or "minio".
BUCKET_NAME="default-storage"
# MINIO_ENDPOINT: The endpoint URL for the MinIO server
# Format: http(s)://<host>:<port>
# Example: http://localhost:9000 (For development mode)
MINIO_ENDPOINT="http://minio:9000"
# Common access keys for both S3 and MinIO
# MINIO_ACCESS_KEY: Access key for authentication
# Warning: Use a strong, unique value in production
# Default: minioadmin (for development only)
MINIO_ACCESS_KEY="minioadmin"
# MINIO_SECRET_KEY: Secret key for authentication
# Warning: Keep this value secret and never commit to version control
# Default: minioadmin (for development only)
MINIO_SECRET_KEY="minioadmin"
# AWS Region, only required for AWS S3
# Example: us-east-1 (for development only)
# MINIO_ENDPOINT: The endpoint URL for the MinIO server.
# Format: http(s)://<host>:<port>.
# Example: http://localhost:9000 (For development mode).
MINIO_ENDPOINT="http://localhost:9000"
# MINIO_ACCESS_KEY: Access key for authentication.
# Default: minioadmin (for development only).
# Warning: Use a strong, unique value in production.
MINIO_ACCESS_KEY="minioadmin"
# MINIO_SECRET_KEY: Secret key for authentication.
# Default: minioadmin (for development only).
# Warning: Keep this value secret and never commit to version control.
MINIO_SECRET_KEY="minioadmin"
# AWS Region: only required for AWS S3
# Example: us-east-1
AWS_REGION="your_aws_region_here"
27 changes: 13 additions & 14 deletions backend/docker/docker-compose-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ services:
LANGCHAIN_PROJECT: "your_langsmith_project_name_here"
FILE_UPLOAD: minio
AWS_REGION: "your_aws_region_here"
# Default configuration values for using Minio
BUCKET_NAME: "default-storage"
MINIO_ENDPOINT: "http://minio:9000"
STORAGE_ACCESS_KEY: "minioadmin"
STORAGE_SECRET_KEY: "minioadmin"
MINIO_ENDPOINT: "http://localhost:9000"
MINIO_ACCESS_KEY: "minioadmin"
MINIO_SECRET_KEY: "minioadmin"
ports:
- "3000:3000"
depends_on:
Expand Down Expand Up @@ -84,23 +83,23 @@ services:
ports:
- "9000:9000"
- "9001:9001"
volumes:
- minio_data:/data
environment:
MINIO_ROOT_USER: "minioadmin"
MINIO_ROOT_PASSWORD: "minioadmin"
entrypoint: /bin/sh -c "
/usr/bin/docker-entrypoint.sh server --console-address ':9001' --address ':9000' /data &
sleep 1 &&
mc alias set myminio http://localhost:9000 minioadmin minioadmin &&
if ! mc ls myminio/default-storage; then mc mb myminio/default-storage; fi &&
wait"
command: server --console-address ":9001" --address ":9000" /data
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3

volumes:
minio_data:
init_minio:
image: minio/mc
depends_on:
- minio
entrypoint: >
/bin/sh -c "
mc alias set codepair http://minio:9000 minioadmin minioadmin --api S3v4;
mc mb codepair/default-storage;
exit 0;
"
26 changes: 26 additions & 0 deletions backend/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,29 @@ services:
interval: 5s
timeout: 2s
retries: 20

minio:
image: minio/minio
ports:
- "9000:9000"
- "9001:9001"
environment:
MINIO_ROOT_USER: "minioadmin"
MINIO_ROOT_PASSWORD: "minioadmin"
command: server --console-address ":9001" --address ":9000" /data
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3

init_minio:
image: minio/mc
depends_on:
- minio
entrypoint: >
/bin/sh -c "
mc alias set codepair http://minio:9000 minioadmin minioadmin --api S3v4;
mc mb codepair/default-storage;
exit 0;
"
5 changes: 3 additions & 2 deletions backend/src/storage/storage.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ const s3ClientFactory = {
if (fileUpload === "false") {
return null;
}

const region = configService.get<string>("AWS_REGION");
const endpoint = configService.get<string>("MINIO_ENDPOINT");
const accessKeyId = configService.get<string>("STORAGE_ACCESS_KEY");
const secretAccessKey = configService.get<string>("STORAGE_SECRET_KEY");
const accessKeyId = configService.get<string>("MINIO_ACCESS_KEY");
const secretAccessKey = configService.get<string>("MINIO_SECRET_KEY");

const config: S3ClientConfig = {
region,
Expand Down
4 changes: 2 additions & 2 deletions backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"noImplicitAny": false,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false
}
"noFallthroughCasesInSwitch": false,
},
}
Loading

0 comments on commit 424170d

Please sign in to comment.