# Minimal self-contained Dockerfile - no external files needed
FROM node:16-alpine
# Create app directory
WORKDIR /app
# Create a simple server.js file directly in the container
RUN echo '// Simple HTTP server\n\
const http = require("http");\n\
const fs = require("fs");\n\
const path = require("path");\n\
\n\
// Create directory for HTML file\n\
fs.mkdirSync(path.join(__dirname, "public"), { recursive: true });\n\
\n\
// Create HTML content\n\
const html = `\n\
\n\
\n\
My Favorites - Maintenance\n\
\n\
\n\
\n\
\n\
\n\
\n\
My Favorites
\n\
Our application is currently undergoing maintenance.
\n\
We will be back shortly with a collection of books, movies, series, and more that have made an impression.
\n\
Thank you for your patience!
\n\
\n\
\n\
`;\n\
\n\
// Write HTML to file\n\
fs.writeFileSync(path.join(__dirname, "public", "index.html"), html);\n\
\n\
// Create server\n\
const server = http.createServer((req, res) => {\n\
// Log request\n\
console.log(`${new Date().toISOString()} - ${req.method} ${req.url}`);\n\
\n\
// Health check endpoint\n\
if (req.url === "/health" || req.url === "/api/health") {\n\
res.writeHead(200, { "Content-Type": "application/json" });\n\
res.end(JSON.stringify({ status: "ok", timestamp: new Date().toISOString() }));\n\
return;\n\
}\n\
\n\
// Serve HTML for all other routes\n\
fs.readFile(path.join(__dirname, "public", "index.html"), (err, content) => {\n\
if (err) {\n\
res.writeHead(500);\n\
res.end("Error loading page");\n\
console.error("Error:", err);\n\
return;\n\
}\n\
\n\
res.writeHead(200, { "Content-Type": "text/html" });\n\
res.end(content);\n\
});\n\
});\n\
\n\
// Start server\n\
const PORT = process.env.PORT || 3000;\n\
server.listen(PORT, "0.0.0.0", () => {\n\
console.log(`Server running on port ${PORT}`);\n\
});\n\
\n\
// Handle errors\n\
process.on("uncaughtException", (err) => {\n\
console.error("Uncaught exception:", err);\n\
});\n\
' > server.js
# Set environment variables
ENV NODE_ENV=production
ENV PORT=3000
# Expose the port
EXPOSE 3000
# Start the server
CMD ["node", "server.js"]