Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +3 -5
Dockerfile
CHANGED
|
@@ -6,7 +6,7 @@ RUN apk add --no-cache git
|
|
| 6 |
WORKDIR /app
|
| 7 |
# Buat direktori api dan direktori publik untuk struktur awal
|
| 8 |
RUN mkdir -p /app/api
|
| 9 |
-
# Salin script server utama yang akan memindai folder api secara dinamis
|
| 10 |
RUN cat << 'EOF' > server.js
|
| 11 |
const express = require('express');
|
| 12 |
const fs = require('fs');
|
|
@@ -96,13 +96,11 @@ const routePath = /api/${fileNameWithoutExt};
|
|
| 96 |
const filePath = path.join(API_DIR, file);
|
| 97 |
// Gunakan dynamic import agar support ESM maupun CJS
|
| 98 |
try {
|
| 99 |
-
// Clear cache jika dimuat ulang (untuk mendukung hot-reload sederhana jika diperlukan)
|
| 100 |
-
delete require.cache[require.resolve(filePath)];
|
| 101 |
// Buat handler router universal untuk metode GET, POST, PUT, DELETE, dll.
|
| 102 |
app.all(routePath, async (req, res) => {
|
| 103 |
try {
|
| 104 |
-
// Import file secara dinamis
|
| 105 |
-
const fileUrl = require('url').pathToFileURL(filePath).href;
|
| 106 |
const importedModule = await import(fileUrl);
|
| 107 |
const handler = importedModule.default || importedModule;
|
| 108 |
if (typeof handler === 'function') {
|
|
|
|
| 6 |
WORKDIR /app
|
| 7 |
# Buat direktori api dan direktori publik untuk struktur awal
|
| 8 |
RUN mkdir -p /app/api
|
| 9 |
+
# Salin script server utama yang akan memindai folder api secara dinamis dengan escape '$' yang benar
|
| 10 |
RUN cat << 'EOF' > server.js
|
| 11 |
const express = require('express');
|
| 12 |
const fs = require('fs');
|
|
|
|
| 96 |
const filePath = path.join(API_DIR, file);
|
| 97 |
// Gunakan dynamic import agar support ESM maupun CJS
|
| 98 |
try {
|
|
|
|
|
|
|
| 99 |
// Buat handler router universal untuk metode GET, POST, PUT, DELETE, dll.
|
| 100 |
app.all(routePath, async (req, res) => {
|
| 101 |
try {
|
| 102 |
+
// Import file secara dinamis dengan cache-busting timestamp
|
| 103 |
+
const fileUrl = require('url').pathToFileURL(filePath).href + ?update=${Date.now()};
|
| 104 |
const importedModule = await import(fileUrl);
|
| 105 |
const handler = importedModule.default || importedModule;
|
| 106 |
if (typeof handler === 'function') {
|