Skip to content

Commit 78055a6

Browse files
authored
Merge pull request #170 from Dogtiti/refactor/docker
fix: refactor docker
2 parents 1e8aa5e + 4e1101a commit 78055a6

16 files changed

+343
-123
lines changed

.env.example

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,27 @@ NODE_ENV=development
33

44
# Next Auth config:
55
# Generate a secret with `openssl rand -base64 32`, or visit https://generate-secret.vercel.app/
6-
NEXTAUTH_SECRET=changeme
6+
NEXTAUTH_SECRET=***
77
NEXTAUTH_URL=http://localhost:3000
88

99
# Prisma
1010
DATABASE_URL=file:./db.sqlite
1111

1212
# External APIs:
13-
OPENAI_API_KEY=changeme
13+
OPENAI_API_KEY=***
1414

1515
# Guest Mode:
16-
//The key NEXT_PUBLIC_GUEST_KEY should be in this format: abc,qwe,123, where each comma-separated value can be used
17-
NEXT_PUBLIC_GUEST_KEY=changeme
16+
The key NEXT_PUBLIC_GUEST_KEY should be in this format: abc,qwe,123, where each comma-separated value can be used
17+
NEXT_PUBLIC_GUEST_KEY=***
18+
19+
# Websearch. Fill both of these values to enable it locally
20+
NEXT_PUBLIC_WEB_SEARCH_ENABLED=false # Disables the ability to toggle web search
21+
SERP_API_KEY=*** # https://serper.dev/ for an API key
22+
23+
# Auth providers. Required to enable sign in, in production. Development mode uses local auth.
24+
GOOGLE_CLIENT_ID=***
25+
GOOGLE_CLIENT_SECRET=***
26+
GITHUB_CLIENT_ID=***
27+
GITHUB_CLIENT_SECRET=***
28+
DISCORD_CLIENT_SECRET=***
29+
DISCORD_CLIENT_ID=***

.github/workflows/build-docker-image.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,20 @@ jobs:
3636
uses: docker/build-push-action@v4
3737
with:
3838
context: .
39+
file: prod.Dockerfile
3940
build-args: |
4041
NEXTAUTH_URL=http://localhost:3000
41-
DATABASE_URL=file:../db/db.sqlite
42-
SKIP_ENV_VALIDATION=1
42+
DATABASE_URL=file:./db.sqlite
43+
OPENAI_API_KEY: ${OPENAI_API_KEY}
44+
NEXT_PUBLIC_WEB_SEARCH_ENABLED: ${NEXT_PUBLIC_WEB_SEARCH_ENABLED}
45+
SERP_API_KEY: ${SERP_API_KEY}
46+
NEXT_PUBLIC_FF_AUTH_ENABLED: ${NEXT_PUBLIC_FF_AUTH_ENABLED}
47+
GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID}
48+
GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET}
49+
GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID}
50+
GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET}
51+
DISCORD_CLIENT_ID: ${DISCORD_CLIENT_ID}
52+
DISCORD_CLIENT_SECRET: ${DISCORD_CLIENT_SECRET}
4353
push: true
4454
tags: ${{ steps.meta.outputs.tags }}
4555
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 0 additions & 42 deletions
This file was deleted.

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ One-Click to deploy well-designed AutoGPT-Next-Web web UI on Vercel.
3939
- [ ] 5. Add support for WeChat login
4040

4141
## Business Version
42-
During the period of maintaining open source projects, many friends came to consult about customizing the system. Considering that there may be more friends who have similar needs, we decided to start the internal test plan of the commercial version~
43-
* plan support -
44-
User login system, billing system, charging system, etc., so that everyone can directly deploy a charged version of AutoGPT, and can directly obtain income
45-
* way of participation -
46-
To pre-order the commercial version and view the details of the commercial version plan, please click the link below [AutoGPT-Next-Web Business Vision](https://egqz2y6eul.feishu.cn/docx/PxoMd7LGfoobAixiuWacxRWQnNd)
42+
43+
During the period of maintaining open source projects, many friends came to consult about customizing the system. Considering that there may be more friends who have similar needs, we decided to start the internal test plan of the commercial version~
44+
45+
- plan support -
46+
User login system, billing system, charging system, etc., so that everyone can directly deploy a charged version of AutoGPT, and can directly obtain income
47+
- way of participation -
48+
To pre-order the commercial version and view the details of the commercial version plan, please click the link below [AutoGPT-Next-Web Business Vision](https://egqz2y6eul.feishu.cn/docx/PxoMd7LGfoobAixiuWacxRWQnNd)
4749

4850
## Get Started
4951

@@ -66,15 +68,15 @@ A: The project originated from AgentGPT. Our goal is to continuously provide use
6668
The easiest way to run AutoGPT-Next-Web locally is by using docker.
6769

6870
```bash
69-
docker-compose -f docker-compose-local.yml up -d --remove-orphans
71+
docker-compose -f docker-compose.dev.yml up -d --remove-orphans
7072
```
7173

7274
### Docker-Image
7375

7476
Using `docker-image`
7577

7678
```bash
77-
docker-compose up -d --remove-orphans
79+
docker-compose -f docker-compose.prod.yml up -d --remove-orphans
7880
```
7981

8082
### Local Development Setup

dev.Dockerfile

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
FROM node:19-alpine
2+
3+
RUN apk update && apk add --no-cache openssl
4+
5+
ARG NEXTAUTH_SECRET=$(openssl rand -base64 32)
6+
ENV NEXTAUTH_SECRET=$NEXTAUTH_SECRET
7+
8+
ARG DATABASE_URL
9+
ENV DATABASE_URL=$DATABASE_URL
10+
11+
ARG NEXTAUTH_SECRET=
12+
ENV NEXTAUTH_SECRET=$NEXTAUTH_SECRET
13+
14+
ARG NEXTAUTH_URL
15+
ENV NEXTAUTH_URL=$NEXTAUTH_URL
16+
17+
ARG SKIP_ENV_VALIDATION
18+
ENV SKIP_ENV_VALIDATION=$SKIP_ENV_VALIDATION
19+
20+
WORKDIR /app
21+
22+
23+
24+
# Install dependencies based on the preferred package manager
25+
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
26+
27+
# Copy the rest of the application code
28+
COPY . .
29+
30+
# Prevent Husky errors by disabling the `prepare` script
31+
RUN npm pkg set scripts.prepare="exit 0"
32+
33+
# set npm registry
34+
RUN npm config set registry 'https://registry.npmmirror.com/'
35+
36+
RUN \
37+
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
38+
elif [ -f package-lock.json ]; then npm ci; \
39+
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i; \
40+
# Allow install without lockfile, so example works even without Node.js installed locally
41+
else echo "Warning: Lockfile not found. It is recommended to commit lockfiles to version control." && yarn install; \
42+
fi
43+
44+
45+
46+
47+
ENTRYPOINT ["sh", "entrypoint.sh"]
48+
49+
# Next.js collects completely anonymous telemetry data about general usage. Learn more here: https://nextjs.org/telemetry
50+
# Uncomment the following line to disable telemetry at run time
51+
# ENV NEXT_TELEMETRY_DISABLED 1
52+
53+
# Note: Don't expose ports here, Compose will handle that for us
54+
55+
# Start Next.js in development mode based on the preferred package manager
56+
CMD \
57+
if [ -f yarn.lock ]; then yarn dev; \
58+
elif [ -f package-lock.json ]; then npm run dev; \
59+
elif [ -f pnpm-lock.yaml ]; then pnpm dev; \
60+
else yarn dev; \
61+
fi

docker-compose-local.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

docker-compose.dev.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: '3'
2+
3+
volumes:
4+
db:
5+
src:
6+
public:
7+
8+
services:
9+
autogpt:
10+
build:
11+
context: .
12+
dockerfile: dev.Dockerfile
13+
args:
14+
NEXTAUTH_URL: http://localhost:3000
15+
DATABASE_URL: file:./db.sqlite
16+
SKIP_ENV_VALIDATION: 1 # omit this property to enable schema validation for the environment variables
17+
container_name: autogpt
18+
environment:
19+
OPENAI_API_KEY: ${OPENAI_API_KEY} # openai api key
20+
NEXT_PUBLIC_WEB_SEARCH_ENABLED: ${NEXT_PUBLIC_WEB_SEARCH_ENABLED} # enable web search
21+
SERP_API_KEY: ${SERP_API_KEY} # serp api key
22+
NEXT_PUBLIC_GUEST_KEY: ${NEXT_PUBLIC_GUEST_KEY} # guest key
23+
ports:
24+
- 3000:3000
25+
volumes:
26+
- src:/app/src
27+
- public:/app/public
28+
- db:/app/db
29+
restart: unless-stopped

docker-compose.prod.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: '3'
2+
3+
services:
4+
autogpt:
5+
container_name: autogpt
6+
image: dogtititi/autogpt-next-web:lastest
7+
# build:
8+
# context: .
9+
# dockerfile: prod.Dockerfile
10+
# args:
11+
# NEXTAUTH_URL: http://localhost:3000
12+
# DATABASE_URL: file:./db.sqlite
13+
# OPENAI_API_KEY: ${OPENAI_API_KEY} # openai api key
14+
# NEXT_PUBLIC_WEB_SEARCH_ENABLED: ${NEXT_PUBLIC_WEB_SEARCH_ENABLED} # enable web search
15+
# SERP_API_KEY: ${SERP_API_KEY} # serp api key
16+
# NEXT_PUBLIC_GUEST_KEY: ${NEXT_PUBLIC_GUEST_KEY} # guest key
17+
# NEXT_PUBLIC_FF_AUTH_ENABLED: ${NEXT_PUBLIC_FF_AUTH_ENABLED} # auth enable
18+
# GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID} # google client id
19+
# GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET} # google client secret
20+
# GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID} # github client id
21+
# GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET} # github client secret
22+
# DISCORD_CLIENT_ID: ${DISCORD_CLIENT_ID} # discord client id
23+
# DISCORD_CLIENT_SECRET: ${DISCORD_CLIENT_SECRET} # discord client secret
24+
ports:
25+
- 3000:3000
26+
restart: unless-stopped

docker-compose.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/README_CN.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ One-Click to deploy well-designed AutoGPT-Next-Web web UI on Vercel.
3939
- [ ] 5. 增加微信登录支持
4040

4141
## 商业愿景
42+
4243
在维护开源项目的期间,很多朋友前来咨询关于定制系统的事宜。考虑到可能有更多有类似需求的朋友,我们决定启动商业版本的内部测试计划
43-
* 计划支持 -
44-
用户登录系统、计费系统、收费系统等,使每个人都可以直接部署一个收费版本的AutoGPT,并直接获得收入。
45-
* 参与方式 -
46-
要预定商业版并查看商业版计划的详情,请单击下面的链接[AutoGPT-Next-Web商业愿景](https://egqz2y6eul.feishu.cn/docx/PxoMd7LGfoobAixiuWacxRWQnNd)
44+
45+
- 计划支持 -
46+
用户登录系统、计费系统、收费系统等,使每个人都可以直接部署一个收费版本的 AutoGPT,并直接获得收入。
47+
- 参与方式 -
48+
要预定商业版并查看商业版计划的详情,请单击下面的链接[AutoGPT-Next-Web 商业愿景](https://egqz2y6eul.feishu.cn/docx/PxoMd7LGfoobAixiuWacxRWQnNd)
4749

4850
## 常见问题
4951

@@ -66,15 +68,15 @@ A:项目源自于 AgentGPT,我们目标是持续输出对国内用户友好
6668
使用 Docker 是在本地运行 AutoGPT-Next-Web 最简单的方法。
6769

6870
```bash
69-
docker-compose -f docker-compose-local.yml up -d --remove-orphans
71+
docker-compose -f docker-compose.dev.yml up -d --remove-orphans
7072
```
7173

7274
### Docker-Image
7375

7476
使用 `docker-image` 部署
7577

7678
```bash
77-
docker-compose up -d --remove-orphans
79+
docker-compose -f docker-compose.prod.yml up -d --remove-orphans
7880
```
7981

8082
### 本地开发环境配置

0 commit comments

Comments
 (0)