From 103080ba1b06e1904b88cbdf4d3a4e34ff89d380 Mon Sep 17 00:00:00 2001 From: giteaadmin Date: Mon, 11 Aug 2025 10:50:12 -0400 Subject: [PATCH] update Docker and VS Code configurations for improved debugging --- .dockerignore | 7 +++---- .gitignore | 4 +++- .vscode/launch.json | 26 +++++++++++++++----------- .vscode/tasks.json | 44 ++++++++++++++++++++++++++++++-------------- Dockerfile | 4 ++-- docker-compose.yml | 13 ++----------- package.json | 15 ++++++--------- 7 files changed, 61 insertions(+), 52 deletions(-) diff --git a/.dockerignore b/.dockerignore index e4a8411..3e6990e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,12 +1,11 @@ -# Ignore the node_modules directory, as it will be installed inside the container node_modules -# Ignore Eleventy's default output directory _site -# Ignore npm debug logs npm-debug.log -# Ignore Docker files Dockerfile docker-compose.yml + +.git +.gitignore \ No newline at end of file diff --git a/.gitignore b/.gitignore index 72a5c3b..72fdab9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -_site/ \ No newline at end of file +node_modules +_site +.DS_Store \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 74a3690..834f8c0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,12 +1,16 @@ { - "version": "0.2.0", - "configurations": [ - { - "name": "Docker: Attach to Node", - "type": "docker", - "request": "attach", - "platform": "node", - "containerName": "eleventy" - } - ] -} \ No newline at end of file + "version": "0.2.0", + "configurations": [ + { + "name": "Docker: Attach to Node", + "type": "node", + "request": "attach", + "port": 9229, + "address": "localhost", + "localRoot": "${workspaceFolder}", + "remoteRoot": "/usr/src/app", + "restart": true, + "preLaunchTask": "docker-compose-up" + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index dd8a159..805d0eb 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,17 +1,33 @@ { - "version": "2.0.0", - "tasks": [ + "version": "2.0.0", + "tasks": [ + { + "label": "docker-compose-up", + "type": "shell", + "command": "docker-compose up --build", + "isBackground": true, + "problemMatcher": [ { - "label": "docker-build", - "type": "shell", - "command": "docker build -t eleventy .", - "problemMatcher": [] - }, - { - "label": "docker-run", - "type": "shell", - "command": "docker run -d --name eleventy -p 8080:8080 eleventy", - "problemMatcher": [] + "pattern": [ + { + "regexp": ".", + "file": 1, + "location": 2, + "message": 3 + } + ], + "background": { + "activeOnStart": true, + "beginsPattern": "Attaching to", + "endsPattern": "Server at" + } } - ] -} \ No newline at end of file + ] + }, + { + "label": "docker-compose-down", + "type": "shell", + "command": "docker-compose down" + } + ] +} diff --git a/Dockerfile b/Dockerfile index 993c21d..1124f5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,5 +4,5 @@ WORKDIR /app COPY package*.json ./ RUN npm install COPY . . -EXPOSE 8080 -CMD [ "npx", "@11ty/eleventy", "--serve" ] \ No newline at end of file +EXPOSE 8080 9229 +CMD [ "npm", "start" ] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 1e3701c..8b10783 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,19 +1,10 @@ services: eleventy: - # Build the Docker image from the Dockerfile in the current directory build: . - # Name the container for easier reference container_name: eleventy_dev - # Map port 8080 on the host to port 8080 in the container ports: - 8080:8080 - # Mount the current directory on the host to /app in the container - # This allows for live-reloading as you edit your files locally + - 9229:9229 volumes: - .:/app - - /app/node_modules - labels: - diun.enable: false - homepage.group: Tools - homepage.name: Eleventy - homepage.icon: eleventy + - /app/node_modules \ No newline at end of file diff --git a/package.json b/package.json index 171ffff..a86d672 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,15 @@ { - "name": "eleventy", + "name": "eleventy-docker-debug", "version": "1.0.0", - "description": "A basic Eleventy project.", + "description": "An Eleventy project with Docker and VS Code debugging.", "scripts": { - "start": "npx @11ty/eleventy --serve", - "build": "npx @11ty/eleventy" + "start": "eleventy --serve --watch", + "debug": "node --inspect=0.0.0.0:9229 ./node_modules/.bin/eleventy --serve --watch" }, - "keywords": [ - "eleventy", - "static-site-generator" - ], + "keywords": [], "author": "", "license": "ISC", - "devDependencies": { + "dependencies": { "@11ty/eleventy": "^2.0.1" } }