diff --git a/my-favorites-app/.dockerignore b/my-favorites-app/.dockerignore index 1418ed8..a40ea34 100644 --- a/my-favorites-app/.dockerignore +++ b/my-favorites-app/.dockerignore @@ -1,33 +1,6 @@ -# Versioning and metadata -.git -.gitignore -.dockerignore +# Ignore everything +* +**/* -# Build dependencies -node_modules -npm-debug.log - -# Environment (contains sensitive data) -.env -.env.* -!.env.example - -# Files not required for production -README.md -Dockerfile -docker-compose.yml -*.log -.next -.vscode -.idea -*.md -*.log -*.lock - -# Testing -coverage -.nyc_output -test - -# Misc -.DS_Store +# Except the Dockerfile itself +!Dockerfile diff --git a/my-favorites-app/Dockerfile b/my-favorites-app/Dockerfile index c09d140..1ffe8e0 100644 --- a/my-favorites-app/Dockerfile +++ b/my-favorites-app/Dockerfile @@ -1,69 +1,48 @@ -# Self-contained Dockerfile that creates all necessary files +# Minimal self-contained Dockerfile - no external files needed FROM node:16-alpine # Create app directory WORKDIR /app -# Create server.js file directly in the Dockerfile -RUN echo 'const http = require("http");\n\ +# 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 the src/app directory if it doesn\'t exist\n\ -fs.mkdirSync(path.join(__dirname, "src", "app"), { recursive: true });\n\ +// Create directory for HTML file\n\ +fs.mkdirSync(path.join(__dirname, "public"), { recursive: true });\n\ \n\ -// Create a simple HTML file\n\ -const htmlContent = `\n\ -\n\ +// Create HTML content\n\ +const html = `\n\ +\n\ \n\ + My Favorites - Maintenance\n\ \n\ \n\ - My Favorites - Maintenance\n\ \n\ \n\ \n\
\n\

My Favorites

\n\ -

Our application is currently undergoing maintenance. We\'ll be back shortly with a collection of books, movies, series, and more that have made an impression.

\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\ -fs.writeFileSync(path.join(__dirname, "src", "app", "index.html"), htmlContent);\n\ +// Write HTML to file\n\ +fs.writeFileSync(path.join(__dirname, "public", "index.html"), html);\n\ \n\ -// Create HTTP server\n\ +// Create server\n\ const server = http.createServer((req, res) => {\n\ - console.log(`Request received: ${req.method} ${req.url}`);\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\ @@ -72,13 +51,12 @@ const server = http.createServer((req, res) => {\n\ return;\n\ }\n\ \n\ - // Serve static HTML for all other routes\n\ - const indexPath = path.join(__dirname, "src", "app", "index.html");\n\ - fs.readFile(indexPath, (err, content) => {\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 index.html");\n\ - console.error("Error serving index.html:", err);\n\ + res.end("Error loading page");\n\ + console.error("Error:", err);\n\ return;\n\ }\n\ \n\ @@ -87,34 +65,17 @@ const server = http.createServer((req, res) => {\n\ });\n\ });\n\ \n\ -// Start the server\n\ +// Start server\n\ const PORT = process.env.PORT || 3000;\n\ -server.listen(PORT, () => {\n\ +server.listen(PORT, "0.0.0.0", () => {\n\ console.log(`Server running on port ${PORT}`);\n\ - console.log(`Environment: ${process.env.NODE_ENV || "development"}`);\n\ });\n\ \n\ // Handle errors\n\ -server.on("error", (err) => {\n\ - console.error("Server error:", err);\n\ -});\n\ -\n\ -// Handle process termination\n\ -process.on("SIGTERM", () => {\n\ - console.log("SIGTERM received, shutting down gracefully");\n\ - server.close(() => {\n\ - console.log("Server closed");\n\ - process.exit(0);\n\ - });\n\ -});\n\ -\n\ process.on("uncaughtException", (err) => {\n\ console.error("Uncaught exception:", err);\n\ });\n\ -\n\ -process.on("unhandledRejection", (reason) => {\n\ - console.error("Unhandled rejection:", reason);\n\ -});' > server.js +' > server.js # Set environment variables ENV NODE_ENV=production