Spaces:
Sleeping
Sleeping
Commit
·
cc771fe
1
Parent(s):
4d356ec
fix for permission denied
Browse files- Dockerfile +7 -2
- docker-entrypoint.sh +11 -5
- init-data.bat +6 -0
- init-data.sh +5 -0
- scripts/init_data_files.js +32 -0
Dockerfile
CHANGED
|
@@ -15,12 +15,17 @@ RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
|
| 15 |
# Copy application code
|
| 16 |
COPY . .
|
| 17 |
|
| 18 |
-
# Create data directory
|
| 19 |
-
RUN mkdir -p /app/data
|
|
|
|
|
|
|
| 20 |
|
| 21 |
# Expose ports
|
| 22 |
EXPOSE 3000 6969
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
# Set entrypoint
|
| 25 |
ENTRYPOINT ["docker-entrypoint.sh"]
|
| 26 |
|
|
|
|
| 15 |
# Copy application code
|
| 16 |
COPY . .
|
| 17 |
|
| 18 |
+
# Create data directory with proper permissions
|
| 19 |
+
RUN mkdir -p /app/data && \
|
| 20 |
+
chown -R node:node /app && \
|
| 21 |
+
chmod -R 755 /app
|
| 22 |
|
| 23 |
# Expose ports
|
| 24 |
EXPOSE 3000 6969
|
| 25 |
|
| 26 |
+
# Set user to node (non-root user that comes with the node image)
|
| 27 |
+
USER node
|
| 28 |
+
|
| 29 |
# Set entrypoint
|
| 30 |
ENTRYPOINT ["docker-entrypoint.sh"]
|
| 31 |
|
docker-entrypoint.sh
CHANGED
|
@@ -4,19 +4,25 @@ set -e
|
|
| 4 |
echo "Starting GPU Leaderboard application..."
|
| 5 |
|
| 6 |
# Create data directory if it doesn't exist
|
| 7 |
-
mkdir -p /app/data
|
| 8 |
echo "Ensuring data directory exists: /app/data"
|
| 9 |
|
| 10 |
# Initialize data.json if it doesn't exist
|
| 11 |
if [ ! -f /app/data/data.json ]; then
|
| 12 |
-
|
| 13 |
-
echo "
|
|
|
|
|
|
|
|
|
|
| 14 |
fi
|
| 15 |
|
| 16 |
# Initialize ips.json if it doesn't exist
|
| 17 |
if [ ! -f /app/data/ips.json ]; then
|
| 18 |
-
|
| 19 |
-
echo "
|
|
|
|
|
|
|
|
|
|
| 20 |
fi
|
| 21 |
|
| 22 |
echo "Data files initialized successfully"
|
|
|
|
| 4 |
echo "Starting GPU Leaderboard application..."
|
| 5 |
|
| 6 |
# Create data directory if it doesn't exist
|
| 7 |
+
mkdir -p /app/data || true
|
| 8 |
echo "Ensuring data directory exists: /app/data"
|
| 9 |
|
| 10 |
# Initialize data.json if it doesn't exist
|
| 11 |
if [ ! -f /app/data/data.json ]; then
|
| 12 |
+
# Try to create the file, but don't fail if we can't
|
| 13 |
+
echo '{}' > /app/data/data.json 2>/dev/null || echo "Warning: Could not create data.json, will use existing file if available"
|
| 14 |
+
if [ -f /app/data/data.json ]; then
|
| 15 |
+
echo "Initialized empty data.json file"
|
| 16 |
+
fi
|
| 17 |
fi
|
| 18 |
|
| 19 |
# Initialize ips.json if it doesn't exist
|
| 20 |
if [ ! -f /app/data/ips.json ]; then
|
| 21 |
+
# Try to create the file, but don't fail if we can't
|
| 22 |
+
echo '{}' > /app/data/ips.json 2>/dev/null || echo "Warning: Could not create ips.json, will use existing file if available"
|
| 23 |
+
if [ -f /app/data/ips.json ]; then
|
| 24 |
+
echo "Initialized empty ips.json file"
|
| 25 |
+
fi
|
| 26 |
fi
|
| 27 |
|
| 28 |
echo "Data files initialized successfully"
|
init-data.bat
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@echo off
|
| 2 |
+
echo Initializing data files for GPU Leaderboard...
|
| 3 |
+
node scripts/init_data_files.js
|
| 4 |
+
echo.
|
| 5 |
+
echo If successful, you can now run the Docker container.
|
| 6 |
+
pause
|
init-data.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
echo "Initializing data files for GPU Leaderboard..."
|
| 3 |
+
node scripts/init_data_files.js
|
| 4 |
+
echo ""
|
| 5 |
+
echo "If successful, you can now run the Docker container."
|
scripts/init_data_files.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* This script initializes the data directory and required JSON files
|
| 3 |
+
* Run this before starting the Docker container to ensure proper file permissions
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
const fs = require('fs');
|
| 7 |
+
const path = require('path');
|
| 8 |
+
|
| 9 |
+
// Define the data directory path
|
| 10 |
+
const dataDir = path.join(__dirname, '..', 'data');
|
| 11 |
+
|
| 12 |
+
// Create the data directory if it doesn't exist
|
| 13 |
+
if (!fs.existsSync(dataDir)) {
|
| 14 |
+
console.log(`Creating data directory: ${dataDir}`);
|
| 15 |
+
fs.mkdirSync(dataDir, { recursive: true });
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
// Initialize data.json if it doesn't exist
|
| 19 |
+
const dataJsonPath = path.join(dataDir, 'data.json');
|
| 20 |
+
if (!fs.existsSync(dataJsonPath)) {
|
| 21 |
+
console.log(`Creating empty data.json file: ${dataJsonPath}`);
|
| 22 |
+
fs.writeFileSync(dataJsonPath, '{}', 'utf8');
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
// Initialize ips.json if it doesn't exist
|
| 26 |
+
const ipsJsonPath = path.join(dataDir, 'ips.json');
|
| 27 |
+
if (!fs.existsSync(ipsJsonPath)) {
|
| 28 |
+
console.log(`Creating empty ips.json file: ${ipsJsonPath}`);
|
| 29 |
+
fs.writeFileSync(ipsJsonPath, '{}', 'utf8');
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
console.log('Data files initialized successfully');
|