Spaces:
Sleeping
Sleeping
Updated Dockerfile for Hugging Face Spaces deployment
Browse files- Dockerfile +2 -3
- app/server.js +8 -2
Dockerfile
CHANGED
@@ -48,9 +48,7 @@ ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
|
|
48 |
RUN mkdir -p /app/cache/huggingface && \
|
49 |
mkdir -p /app/cache/triton && \
|
50 |
mkdir -p /app/cache/torch_extensions && \
|
51 |
-
|
52 |
-
chmod -R 777 /app/cache && \
|
53 |
-
chmod -R 777 /app/public/audio
|
54 |
|
55 |
# Set environment variables for cache directories
|
56 |
ENV HF_HOME=/app/cache/huggingface
|
@@ -73,6 +71,7 @@ COPY . /app
|
|
73 |
|
74 |
# Create necessary directories for Node.js uploads with proper permissions
|
75 |
RUN mkdir -p /app/app/uploads && chmod -R 777 /app/app/uploads
|
|
|
76 |
|
77 |
# Copy wait-for-it script
|
78 |
COPY wait-for-it.sh /app/wait-for-it.sh
|
|
|
48 |
RUN mkdir -p /app/cache/huggingface && \
|
49 |
mkdir -p /app/cache/triton && \
|
50 |
mkdir -p /app/cache/torch_extensions && \
|
51 |
+
chmod -R 777 /app/cache
|
|
|
|
|
52 |
|
53 |
# Set environment variables for cache directories
|
54 |
ENV HF_HOME=/app/cache/huggingface
|
|
|
71 |
|
72 |
# Create necessary directories for Node.js uploads with proper permissions
|
73 |
RUN mkdir -p /app/app/uploads && chmod -R 777 /app/app/uploads
|
74 |
+
RUN mkdir -p /app/app/public && chmod -R 777 /app/app/public
|
75 |
|
76 |
# Copy wait-for-it script
|
77 |
COPY wait-for-it.sh /app/wait-for-it.sh
|
app/server.js
CHANGED
@@ -10,14 +10,20 @@ const app = express();
|
|
10 |
const port = 3000;
|
11 |
|
12 |
const uploadsDir = path.join(__dirname, 'uploads');
|
|
|
|
|
13 |
if (!fs.existsSync(uploadsDir)) {
|
14 |
fs.mkdirSync(uploadsDir, { recursive: true });
|
15 |
}
|
16 |
|
|
|
|
|
|
|
|
|
17 |
const storage = multer.memoryStorage();
|
18 |
const upload = multer({ storage: storage });
|
19 |
|
20 |
-
app.use(express.static(
|
21 |
app.use(express.json());
|
22 |
|
23 |
const getNextFolderNumber = () => {
|
@@ -71,7 +77,7 @@ app.post('/save-audio', upload.single('audio'), async (req, res) => {
|
|
71 |
audioPaths.push(result.audio_path);
|
72 |
sentenceIndex++;
|
73 |
// Serve the audio file from the public directory
|
74 |
-
const publicAudioPath = path.join(
|
75 |
fs.copyFileSync(result.audio_path, publicAudioPath);
|
76 |
res.status(200).json({ audio_path: `/public/${path.basename(result.audio_path)}`, translation: result.translation });
|
77 |
} else {
|
|
|
10 |
const port = 3000;
|
11 |
|
12 |
const uploadsDir = path.join(__dirname, 'uploads');
|
13 |
+
const publicDir = path.join(__dirname, 'public');
|
14 |
+
|
15 |
if (!fs.existsSync(uploadsDir)) {
|
16 |
fs.mkdirSync(uploadsDir, { recursive: true });
|
17 |
}
|
18 |
|
19 |
+
if (!fs.existsSync(publicDir)) {
|
20 |
+
fs.mkdirSync(publicDir, { recursive: true });
|
21 |
+
}
|
22 |
+
|
23 |
const storage = multer.memoryStorage();
|
24 |
const upload = multer({ storage: storage });
|
25 |
|
26 |
+
app.use(express.static(publicDir));
|
27 |
app.use(express.json());
|
28 |
|
29 |
const getNextFolderNumber = () => {
|
|
|
77 |
audioPaths.push(result.audio_path);
|
78 |
sentenceIndex++;
|
79 |
// Serve the audio file from the public directory
|
80 |
+
const publicAudioPath = path.join(publicDir, path.basename(result.audio_path));
|
81 |
fs.copyFileSync(result.audio_path, publicAudioPath);
|
82 |
res.status(200).json({ audio_path: `/public/${path.basename(result.audio_path)}`, translation: result.translation });
|
83 |
} else {
|