fix: Resolve mc config permission error and add MinIO setup documentation
- Replace read-only host mount with dedicated Docker volume for mc config - Add init-mc-config.sh to initialize mc configuration with proper permissions - Create setup-mc-alias.sh script to configure MinIO connection - Add comprehensive MINIO_SETUP.md documentation - Update docker-compose.dev.yml to use mc-config volume - Update Dockerfile to run mc config initialization - Document bcrypt architecture workaround in FIX_ENV_TRUNCATION.md The mc client can now write to its configuration directory, resolving the "permission denied" error when connecting to MinIO servers. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Executable
+29
@@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Initialize mc config if needed
|
||||||
|
|
||||||
|
MC_CONFIG_DIR="/home/node/.mc"
|
||||||
|
MC_CONFIG_FILE="$MC_CONFIG_DIR/config.json"
|
||||||
|
|
||||||
|
# Create directory if it doesn't exist
|
||||||
|
if [ ! -d "$MC_CONFIG_DIR" ]; then
|
||||||
|
echo "Creating mc config directory..."
|
||||||
|
mkdir -p "$MC_CONFIG_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If config doesn't exist, create a basic one
|
||||||
|
if [ ! -f "$MC_CONFIG_FILE" ]; then
|
||||||
|
echo "Creating initial mc config..."
|
||||||
|
cat > "$MC_CONFIG_FILE" << 'EOF'
|
||||||
|
{
|
||||||
|
"version": "10",
|
||||||
|
"aliases": {}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure proper ownership
|
||||||
|
chown -R node:node "$MC_CONFIG_DIR"
|
||||||
|
chmod 755 "$MC_CONFIG_DIR"
|
||||||
|
chmod 644 "$MC_CONFIG_FILE"
|
||||||
|
|
||||||
|
echo "MC config initialized successfully"
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
version: '3.8'
|
|
||||||
|
|
||||||
# Development docker-compose file
|
# Development docker-compose file
|
||||||
# This configuration runs frontend and backend on custom ports without SSL/nginx proxy
|
# This configuration runs frontend and backend on custom ports without SSL/nginx proxy
|
||||||
# Usage: docker compose -f docker-compose.dev.yml up
|
# Usage: docker compose -f docker-compose.dev.yml up
|
||||||
@@ -27,8 +25,7 @@ services:
|
|||||||
- ./backend/package-lock.json:/app/package-lock.json
|
- ./backend/package-lock.json:/app/package-lock.json
|
||||||
- backend-logs:/app/logs
|
- backend-logs:/app/logs
|
||||||
- backend-temp:/app/temp
|
- backend-temp:/app/temp
|
||||||
- backend-node-modules:/app/node_modules
|
- mc-config:/home/node/.mc
|
||||||
- ~/.mc:/home/node/.mc:ro
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
networks:
|
networks:
|
||||||
@@ -78,7 +75,7 @@ volumes:
|
|||||||
driver: local
|
driver: local
|
||||||
backend-temp:
|
backend-temp:
|
||||||
driver: local
|
driver: local
|
||||||
backend-node-modules:
|
mc-config:
|
||||||
driver: local
|
driver: local
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
FROM node:20-alpine
|
FROM node:20-alpine
|
||||||
|
|
||||||
# Install MinIO client
|
# Install MinIO client (detect architecture)
|
||||||
RUN wget https://dl.min.io/client/mc/release/linux-amd64/mc && \
|
RUN ARCH=$(uname -m | sed 's/x86_64/amd64/g' | sed 's/aarch64/arm64/g') && \
|
||||||
|
wget https://dl.min.io/client/mc/release/linux-${ARCH}/mc && \
|
||||||
chmod +x mc && \
|
chmod +x mc && \
|
||||||
mv mc /usr/local/bin/
|
mv mc /usr/local/bin/
|
||||||
|
|
||||||
@@ -14,9 +15,13 @@ WORKDIR /app
|
|||||||
# Copy package files
|
# Copy package files
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
|
# Install build tools for compilation (keep them in dev environment)
|
||||||
|
RUN apk add --no-cache python3 make g++
|
||||||
|
|
||||||
# Install all dependencies (including devDependencies for development)
|
# Install all dependencies (including devDependencies for development)
|
||||||
# Make sure NODE_ENV is not set to production during install
|
# Make sure NODE_ENV is not set to production during install
|
||||||
RUN NODE_ENV=development npm install
|
RUN NODE_ENV=development npm install && \
|
||||||
|
npm rebuild bcrypt --build-from-source
|
||||||
|
|
||||||
# Create necessary directories
|
# Create necessary directories
|
||||||
RUN mkdir -p logs temp && \
|
RUN mkdir -p logs temp && \
|
||||||
@@ -25,6 +30,10 @@ RUN mkdir -p logs temp && \
|
|||||||
# Copy application files
|
# Copy application files
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# Copy and run mc config initialization script
|
||||||
|
COPY init-mc-config.sh /tmp/init-mc-config.sh
|
||||||
|
RUN chmod +x /tmp/init-mc-config.sh && /tmp/init-mc-config.sh && rm /tmp/init-mc-config.sh
|
||||||
|
|
||||||
# Change ownership of everything to node user (built-in)
|
# Change ownership of everything to node user (built-in)
|
||||||
RUN chown -R node:node /app
|
RUN chown -R node:node /app
|
||||||
|
|
||||||
|
|||||||
@@ -38,10 +38,20 @@ This script will:
|
|||||||
2. Use password: `admin123`
|
2. Use password: `admin123`
|
||||||
3. You should be able to log in successfully
|
3. You should be able to log in successfully
|
||||||
|
|
||||||
|
## Known Issue: bcrypt Architecture
|
||||||
|
|
||||||
|
Due to architecture differences (ARM vs x86), bcrypt may need to be rebuilt after container restart:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Fix bcrypt after container restart
|
||||||
|
docker exec minio-webui-backend-dev sh -c 'rm -rf /app/node_modules/bcrypt && cd /app && npm install bcrypt' && docker restart minio-webui-backend-dev
|
||||||
|
```
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
If issues persist:
|
If issues persist:
|
||||||
1. Check that .env file exists and has proper quotes around values with special characters
|
1. Check that .env file exists and has double dollar signs ($$) for escaping
|
||||||
2. Ensure Docker containers were rebuilt: `docker compose -f docker-compose.dev.yml up -d --build`
|
2. Ensure Docker containers were rebuilt: `docker compose -f docker-compose.dev.yml up -d --build`
|
||||||
3. Check logs: `docker logs minio-webui-backend-dev`
|
3. Check logs: `docker logs minio-webui-backend-dev`
|
||||||
4. Run debug script: `./scripts/debug-auth.sh`
|
4. Run debug script: `./scripts/debug-auth.sh`
|
||||||
|
5. If bcrypt error occurs, run the fix command above
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
# MinIO Configuration for MinIO WebUI
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
The MinIO WebUI requires access to a MinIO server to manage buckets and objects. You need to configure the MinIO connection details in the `.env` file.
|
||||||
|
|
||||||
|
## Configuration Steps
|
||||||
|
|
||||||
|
### 1. Update MinIO Connection Details
|
||||||
|
|
||||||
|
Edit your `.env` file and update the MinIO configuration:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# MinIO Configuration
|
||||||
|
DEFAULT_MINIO_ALIAS=kopiaminio # Alias name for the MinIO server
|
||||||
|
MINIO_ENDPOINT=https://your-minio.com # Your MinIO server URL
|
||||||
|
MINIO_ACCESS_KEY=your-access-key # MinIO access key
|
||||||
|
MINIO_SECRET_KEY=your-secret-key # MinIO secret key
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Common MinIO Endpoints
|
||||||
|
|
||||||
|
- **Local MinIO**: `http://localhost:9000` or `http://host.docker.internal:9000` (from Docker)
|
||||||
|
- **MinIO Docker**: `http://minio:9000` (if MinIO is in the same Docker network)
|
||||||
|
- **Remote MinIO**: `https://your-minio-server.com`
|
||||||
|
|
||||||
|
### 3. Set Up the MinIO Alias
|
||||||
|
|
||||||
|
After updating the `.env` file, restart the containers and run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./scripts/setup-mc-alias.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
This script will:
|
||||||
|
- Configure the MinIO client (mc) with your connection details
|
||||||
|
- Test the connection
|
||||||
|
- Show any connection errors
|
||||||
|
|
||||||
|
### 4. Troubleshooting
|
||||||
|
|
||||||
|
#### Permission Denied Error
|
||||||
|
If you see "permission denied" errors, the mc config has been fixed with a dedicated volume.
|
||||||
|
|
||||||
|
#### Connection Refused
|
||||||
|
- Ensure your MinIO server is running
|
||||||
|
- Check the endpoint URL is correct
|
||||||
|
- Verify network connectivity from the Docker container
|
||||||
|
|
||||||
|
#### Invalid Credentials
|
||||||
|
- Double-check your access key and secret key
|
||||||
|
- Ensure they match your MinIO server configuration
|
||||||
|
|
||||||
|
### 5. Testing the Connection
|
||||||
|
|
||||||
|
You can manually test the connection:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# List buckets
|
||||||
|
docker exec minio-webui-backend-dev mc ls kopiaminio
|
||||||
|
|
||||||
|
# Create a test bucket
|
||||||
|
docker exec minio-webui-backend-dev mc mb kopiaminio/test-bucket
|
||||||
|
|
||||||
|
# Remove test bucket
|
||||||
|
docker exec minio-webui-backend-dev mc rb kopiaminio/test-bucket
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example: Local MinIO Setup
|
||||||
|
|
||||||
|
If you're running MinIO locally:
|
||||||
|
|
||||||
|
1. Start MinIO:
|
||||||
|
```bash
|
||||||
|
docker run -p 9000:9000 -p 9001:9001 \
|
||||||
|
-e MINIO_ROOT_USER=minioadmin \
|
||||||
|
-e MINIO_ROOT_PASSWORD=minioadmin \
|
||||||
|
minio/minio server /data --console-address ":9001"
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Update `.env`:
|
||||||
|
```bash
|
||||||
|
DEFAULT_MINIO_ALIAS=local-minio
|
||||||
|
MINIO_ENDPOINT=http://host.docker.internal:9000
|
||||||
|
MINIO_ACCESS_KEY=minioadmin
|
||||||
|
MINIO_SECRET_KEY=minioadmin
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Run setup:
|
||||||
|
```bash
|
||||||
|
docker compose -f docker-compose.dev.yml restart backend
|
||||||
|
./scripts/setup-mc-alias.sh
|
||||||
|
```
|
||||||
Executable
+50
@@ -0,0 +1,50 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "========================================"
|
||||||
|
echo "MinIO WebUI - Setup MC Alias"
|
||||||
|
echo "========================================"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Check if .env exists
|
||||||
|
if [ ! -f .env ]; then
|
||||||
|
echo "Error: .env file not found"
|
||||||
|
echo "Please create .env file from .env.example"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Source the .env file
|
||||||
|
export $(cat .env | grep -v '^#' | xargs)
|
||||||
|
|
||||||
|
# Check required variables
|
||||||
|
if [ -z "$MINIO_ENDPOINT" ] || [ -z "$MINIO_ACCESS_KEY" ] || [ -z "$MINIO_SECRET_KEY" ] || [ -z "$DEFAULT_MINIO_ALIAS" ]; then
|
||||||
|
echo "Error: Missing required MinIO configuration in .env"
|
||||||
|
echo "Please ensure the following are set:"
|
||||||
|
echo " - MINIO_ENDPOINT"
|
||||||
|
echo " - MINIO_ACCESS_KEY"
|
||||||
|
echo " - MINIO_SECRET_KEY"
|
||||||
|
echo " - DEFAULT_MINIO_ALIAS"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Setting up MinIO alias: $DEFAULT_MINIO_ALIAS"
|
||||||
|
echo "Endpoint: $MINIO_ENDPOINT"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Set up the alias in the container
|
||||||
|
docker exec minio-webui-backend-dev sh -c "mc alias set $DEFAULT_MINIO_ALIAS $MINIO_ENDPOINT $MINIO_ACCESS_KEY $MINIO_SECRET_KEY"
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo ""
|
||||||
|
echo "✅ MinIO alias configured successfully!"
|
||||||
|
echo ""
|
||||||
|
echo "Testing connection..."
|
||||||
|
docker exec minio-webui-backend-dev sh -c "mc ls $DEFAULT_MINIO_ALIAS" 2>&1 | head -5
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
echo "❌ Failed to configure MinIO alias"
|
||||||
|
echo ""
|
||||||
|
echo "Please check:"
|
||||||
|
echo "1. MinIO endpoint is accessible: $MINIO_ENDPOINT"
|
||||||
|
echo "2. Access credentials are correct"
|
||||||
|
echo "3. Backend container is running"
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user