diff --git a/Dockerfile b/Dockerfile index 93ac2505e..e8f717b7c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,4 @@ -# This Dockerfile is friendly to users in Chinese Mainland :) -# For users outside mainland China, feel free to modify or delete them :) - -# Use a base image with Python 3.9.17 slim version (Bullseye) +# Use a base image with Python3.9 and Nodejs20 slim version FROM nikolaik/python-nodejs:python3.9-nodejs20-slim # Install Debian software needed by MetaGPT @@ -9,21 +6,15 @@ RUN apt update &&\ apt install -y git chromium fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 --no-install-recommends &&\ apt clean -# Set the working directory to /app -WORKDIR /app - # Install Mermaid CLI globally -ENV CHROME_BIN="/usr/bin/chromium" -ENV AM_I_IN_A_DOCKER_CONTAINER Yes -ADD puppeteer-config.json /puppeteer-config.json +ENV CHROME_BIN="/usr/bin/chromium" \ + AM_I_IN_A_DOCKER_CONTAINER="true" RUN npm install -g @mermaid-js/mermaid-cli &&\ npm cache clean --force -# Copy src to container the MetaGPT repository -COPY . /app/metagpt - # Install Python dependencies and install MetaGPT -RUN cd metagpt &&\ +COPY . /app/metagpt +RUN cd /app/metagpt &&\ mkdir workspace &&\ pip install -r requirements.txt &&\ pip cache purge &&\ diff --git a/README.md b/README.md index 84f9ee293..c43ddb2ec 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,8 @@ ### Build image by yourself ```bash # You can also build metagpt image by yourself. -cd metagpt && docker build --network host -t metagpt:v0.3 . +git clone https://github.com/geekan/MetaGPT.git +cd MetaGPT && docker build -t metagpt:v0.3 . ``` ## Configuration diff --git a/metagpt/utils/mermaid.py b/metagpt/utils/mermaid.py index edb09ffc7..51e54ac33 100644 --- a/metagpt/utils/mermaid.py +++ b/metagpt/utils/mermaid.py @@ -13,7 +13,7 @@ from metagpt.const import PROJECT_ROOT from metagpt.logs import logger from metagpt.utils.common import check_cmd_exists -IS_DOCKER = os.environ.get('AM_I_IN_A_DOCKER_CONTAINER', False) +IS_DOCKER = os.environ.get('AM_I_IN_A_DOCKER_CONTAINER', 'false').lower() def mermaid_to_file(mermaid_code, output_file_without_suffix, width=2048, height=2048) -> int: @@ -30,17 +30,20 @@ def mermaid_to_file(mermaid_code, output_file_without_suffix, width=2048, height tmp.write_text(mermaid_code, encoding='utf-8') if check_cmd_exists('mmdc') != 0: - logger.warning("RUN `npm install -g @mermaid-js/mermaid-cli` to install mmdc") + logger.warning( + "RUN `npm install -g @mermaid-js/mermaid-cli` to install mmdc") return -1 for suffix in ['pdf', 'svg', 'png']: output_file = f'{output_file_without_suffix}.{suffix}' # Call the `mmdc` command to convert the Mermaid code to a PNG logger.info(f"Generating {output_file}..") - if IS_DOCKER: - subprocess.run(['mmdc', '-p', '/puppeteer-config.json', '-i', str(tmp), '-o', output_file, '-w', str(width), '-H', str(height)]) + if IS_DOCKER == 'true': + subprocess.run(['mmdc', '-p', '/app/metagpt/puppeteer-config.json', '-i', + str(tmp), '-o', output_file, '-w', str(width), '-H', str(height)]) else: - subprocess.run(['mmdc', '-i', str(tmp), '-o', output_file, '-w', str(width), '-H', str(height)]) + subprocess.run(['mmdc', '-i', str(tmp), '-o', + output_file, '-w', str(width), '-H', str(height)]) return 0