Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fdd68a6

Browse files
authored
Merge pull request FoundationAgents#43 from voidking/pr
FoundationAgents#35 bugfix: Error: Failed to launch the browser process
2 parents 37b7781 + b1372e2 commit fdd68a6

2 files changed

Lines changed: 36 additions & 13 deletions

File tree

‎Dockerfile‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This Dockerfile is friendly to users in Chinese Mainland :)
1+
# This Dockerfile is friendly to users in Chinese Mainland :)
22
# For users outside mainland China, feel free to modify or delete them :)
33

44
# Use a base image with Python 3.9.17 slim version (Bullseye)
@@ -7,15 +7,20 @@ FROM python:3.9.17-slim-bullseye
77
# Install Debian software needed by MetaGPT
88
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list &&\
99
apt update &&\
10-
apt install -y git curl wget build-essential gcc clang g++ make &&\
10+
apt install -y git curl wget build-essential gcc clang g++ make gnupg &&\
1111
curl -sL https://deb.nodesource.com/setup_19.x | bash - &&\
1212
apt install -y nodejs &&\
13+
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - &&\
14+
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' &&\
15+
apt-get update &&\
16+
apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 --no-install-recommends &&\
1317
apt-get clean
1418

1519
# Set the working directory to /app
1620
WORKDIR /app
1721

1822
# Install Mermaid CLI globally and clone the MetaGPT repository
23+
#ENV PUPPETEER_SKIP_DOWNLOAD='true'
1924
RUN npm config set registry https://registry.npm.taobao.org &&\
2025
npm install -g @mermaid-js/mermaid-cli &&\
2126
npm cache clean --force &&\
@@ -29,6 +34,17 @@ RUN cd metagpt &&\
2934
pip cache purge &&\
3035
python setup.py install
3136

32-
# Running with an infinite loop using the tail command
33-
CMD ["sh", "-c", "tail -f /dev/null"]
37+
# Add metagpt user so we don't need --no-sandbox when use puppeteer
38+
RUN useradd -m metagpt -s /bin/bash &&\
39+
chown metagpt -R /app/metagpt &&\
40+
cp -r /root/.cache /home/metagpt/ &&\
41+
chown metagpt -R /home/metagpt/.cache &&\
42+
chrome_sandbox=$(find /root/.cache/puppeteer/chrome/ -name "chrome_sandbox") &&\
43+
chmod 4755 $chrome_sandbox &&\
44+
cp $chrome_sandbox /usr/local/sbin/chrome-devel-sandbox
45+
46+
WORKDIR /app/metagpt
47+
USER metagpt
3448

49+
# Running with an infinite loop using the tail command
50+
CMD ["sh", "-c", "tail -f /dev/null"]

‎README.md‎

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,34 @@ python setup.py install
5555
```bash
5656
# Step 1: Download metagpt official image and prepare config.yaml
5757
docker pull metagpt/metagpt:v0.1
58-
mkdir -p /opt/metagpt/config && docker run --rm metagpt/metagpt:v0.1 cat /app/metagpt/config/config.yaml > /opt/metagpt/config/config.yaml
58+
mkdir -p /opt/metagpt/{config,workspace} && chmod 777 -R /opt/metagpt
59+
docker run --rm metagpt/metagpt:v0.1 cat /app/metagpt/config/config.yaml > /opt/metagpt/config/config.yaml
5960
vim /opt/metagpt/config/config.yaml # Change the config
6061

61-
# Step 2: Run metagpt image
62+
# Step 2: Run metagpt demo with container
63+
docker run --rm \
64+
--privileged \
65+
-v /opt/metagpt/config:/app/metagpt/config \
66+
-v /opt/metagpt/workspace:/app/metagpt/workspace \
67+
metagpt/metagpt:v0.2 \
68+
python startup.py "Write a cli snake game"
69+
70+
# You can also start a container and execute commands in it
6271
docker run --name metagpt -d \
72+
--privileged \
6373
-v /opt/metagpt/config:/app/metagpt/config \
6474
-v /opt/metagpt/workspace:/app/metagpt/workspace \
65-
metagpt/metagpt:v0.1
75+
metagpt/metagpt:v0.2
6676

67-
# Step 3: Access the metagpt container
6877
docker exec -it metagpt /bin/bash
69-
70-
# Step 4: Play in the container
71-
cd /app/metagpt
72-
python startup.py "Write a cli snake game"
78+
$ python startup.py "Write a cli snake game"
7379
```
7480

7581
The command `docker run ...` do the following things:
76-
- Start metagpt container with default command `tail -f /dev/null`
82+
- Run in privileged mode to have permission to run the browser
7783
- Map host directory `/opt/metagtp/config` to container directory `/app/metagpt/config`
7884
- Map host directory `/opt/metagpt/workspace` to container directory `/app/metagpt/workspace`
85+
- Execute the demo command `python startup.py "Write a cli snake game"`
7986

8087
### Build image by yourself
8188
```bash

0 commit comments

Comments
 (0)