From 840cd1e70b0f1827437834c7b91feb8a201c3094 Mon Sep 17 00:00:00 2001 From: cfngc4594 Date: Sat, 22 Feb 2025 00:10:47 +0800 Subject: [PATCH] feat(docker): update docker-compose commands and add health checks for services --- README.md | 4 ++-- compose.yml | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1723d46..c889d7f 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ git clone https://github.com/cfngc4594/monaco-editor-lsp-next cd monaco-editor-lsp-next # Start containers in detached mode -docker compose up -d +docker compose up -d --build ``` ### 🔧 Manual Setup @@ -46,7 +46,7 @@ git clone https://github.com/cfngc4594/monaco-editor-lsp-next cd monaco-editor-lsp-next # Start specific containers (lsp-c and lsp-cpp) in detached mode -docker compose up -d lsp-c lsp-cpp +docker compose up -d --build lsp-c lsp-cpp # Install project dependencies using Bun package manager bun install diff --git a/compose.yml b/compose.yml index d8bbead..9c3f74e 100644 --- a/compose.yml +++ b/compose.yml @@ -3,25 +3,58 @@ services: build: context: ./ dockerfile: Dockerfile + image: monaco-editor-lsp-next:latest container_name: monaco-editor-lsp-next restart: always ports: - "3000:3000" + networks: + - monaco-editor-lsp-next + depends_on: + - lsp-c + - lsp-cpp + healthcheck: + test: ["CMD-SHELL", "curl --fail http://localhost:3000 || exit 1"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 10s lsp-c: build: context: ./docker/lsp/clangd dockerfile: Dockerfile + image: lsp-c:latest container_name: lsp-c restart: always ports: - "4594:3000" + networks: + - monaco-editor-lsp-next + healthcheck: + test: ["CMD-SHELL", "nc -zv localhost 3000"] + interval: 10s + timeout: 5s + retries: 5 lsp-cpp: build: context: ./docker/lsp/clangd dockerfile: Dockerfile + image: lsp-cpp:latest container_name: lsp-cpp restart: always ports: - "4595:3000" + networks: + - monaco-editor-lsp-next + healthcheck: + test: ["CMD-SHELL", "nc -zv localhost 3000"] + interval: 10s + timeout: 5s + retries: 5 + +networks: + monaco-editor-lsp-next: + name: monaco-editor-lsp-next + driver: bridge