From 46e624c055f4b3e7afe71484d3be70b1ff53ebb2 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 9 Mar 2025 14:09:20 -0600 Subject: [PATCH] Remove Docker and GitHub Actions configuration for templates server --- .github/workflows/deploy.yml | 29 --------- Dockerfile | 15 ----- app/Dockerfile | 22 ------- app/package.json | 9 --- app/server.js | 116 ----------------------------------- 5 files changed, 191 deletions(-) delete mode 100644 .github/workflows/deploy.yml delete mode 100644 Dockerfile delete mode 100644 app/Dockerfile delete mode 100644 app/package.json delete mode 100644 app/server.js diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 37e6888..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Build Docker image - -on: - push: - branches: ["canary", "main", "feat/monitoring"] - -jobs: - build-and-push-templates-image: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Log in to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push Docker image - uses: docker/build-push-action@v4 - with: - context: . - file: ./Dockerfile - push: true - tags: | - dokploy/templates:latest - platforms: linux/amd64 diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index f076380..0000000 --- a/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM node:20.9-slim - -WORKDIR /app - -# Instalar serve globalmente -RUN npm install -g serve - -# Copiar la carpeta templates -COPY ./templates ./public/templates - -# Exponer el puerto -EXPOSE 3000 - -# Servir los archivos estáticos con listado de directorios -CMD ["serve", "--no-clipboard", "--cors", "-l", "3000", "public/templates"] \ No newline at end of file diff --git a/app/Dockerfile b/app/Dockerfile deleted file mode 100644 index cd73115..0000000 --- a/app/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -FROM node:20.9-slim - -WORKDIR /app - -# Crear la estructura de directorios -RUN mkdir -p public/templates - -# Copiar package.json y server.js -COPY ./app/package.json ./ -COPY ./app/server.js ./ - -# Copiar la carpeta templates -COPY ./templates ./public/templates/ - -# Instalar dependencias -RUN npm install express cors - -# Exponer el puerto -EXPOSE 4000 - -# Iniciar el servidor -CMD ["node", "server.js"] \ No newline at end of file diff --git a/app/package.json b/app/package.json deleted file mode 100644 index 9758476..0000000 --- a/app/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "templates-server", - "version": "1.0.0", - "main": "server.js", - "dependencies": { - "express": "^4.18.2", - "cors": "^2.8.5" - } -} \ No newline at end of file diff --git a/app/server.js b/app/server.js deleted file mode 100644 index 4e516ce..0000000 --- a/app/server.js +++ /dev/null @@ -1,116 +0,0 @@ -const express = require("express"); -const fs = require("fs").promises; -const path = require("path"); -const cors = require("cors"); - -const app = express(); -app.use(cors()); - -// Servir archivos estáticos desde la carpeta templates -app.use("/templates", express.static(path.join(__dirname, "public/templates"))); - -// Ruta para listar directorios en formato JSON -app.get("/api/templates", async (req, res) => { - try { - const templatesPath = path.join(__dirname, "public/templates"); - console.log("Buscando templates en:", templatesPath); // Para debug - - // Verificar si el directorio existe - try { - await fs.access(templatesPath); - } catch (e) { - console.error("El directorio no existe:", templatesPath); - return res.status(500).json({ error: "Directory not found" }); - } - - const dirs = await fs.readdir(templatesPath); - console.log("Directorios encontrados:", dirs); // Para debug - - const templates = await Promise.all( - dirs.map(async (dir) => { - const dirPath = path.join(templatesPath, dir); - const stat = await fs.stat(dirPath); - - if (stat.isDirectory()) { - const files = await fs.readdir(dirPath); - const filesInfo = await Promise.all( - files.map(async (file) => { - const filePath = path.join(dirPath, file); - const fileStat = await fs.stat(filePath); - return { - name: file, - path: `/templates/${dir}/${file}`, - size: fileStat.size, - modified: fileStat.mtime, - }; - }) - ); - - return { - name: dir, - path: `/templates/${dir}`, - files: filesInfo, - }; - } - return null; - }) - ); - - res.json({ - templates: templates.filter((t) => t !== null), - }); - } catch (error) { - console.error("Error:", error); // Para debug - res.status(500).json({ error: error.message }); - } -}); - -// Ruta para obtener información de un template específico -app.get("/api/templates/:template", async (req, res) => { - try { - const templatePath = path.join( - __dirname, - "public/templates", - req.params.template - ); - const files = await fs.readdir(templatePath); - - const filesInfo = await Promise.all( - files.map(async (file) => { - const filePath = path.join(templatePath, file); - const stat = await fs.stat(filePath); - return { - name: file, - path: `/templates/${req.params.template}/${file}`, - size: stat.size, - modified: stat.mtime, - }; - }) - ); - - res.json({ - name: req.params.template, - path: `/templates/${req.params.template}`, - files: filesInfo, - }); - } catch (error) { - res.status(500).json({ error: error.message }); - } -}); - -// Ruta para debug - muestra la estructura de directorios -app.get("/debug", (req, res) => { - const debugInfo = { - currentDir: __dirname, - publicTemplatesPath: path.join(__dirname, "public/templates"), - exists: fs.existsSync(path.join(__dirname, "public/templates")), - }; - res.json(debugInfo); -}); - -const PORT = 4000; -app.listen(PORT, () => { - console.log(`Server running on port ${PORT}`); - console.log("Directorio actual:", __dirname); - console.log("Ruta a templates:", path.join(__dirname, "public/templates")); -});