This repository has been archived by the owner on Aug 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: huangzt <[email protected]>
- Loading branch information
Showing
6 changed files
with
164 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: build_docker | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
release: | ||
types: [created] # 表示在创建新的 Release 时触发 | ||
|
||
jobs: | ||
build_docker: | ||
name: Build docker | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- run: | | ||
echo "本次构建的版本为:${GITHUB_REF_NAME} (但是这个变量目前上下文中无法获取到)" | ||
echo 本次构建的版本为:${{ github.ref_name }} | ||
env | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: true | ||
labels: ${{ steps.meta.outputs.labels }} | ||
platforms: linux/amd64,linux/arm64 | ||
tags: | | ||
${{ secrets.DOCKERHUB_USERNAME }}/chatgpt-to-api:${{ github.ref_name }} | ||
${{ secrets.DOCKERHUB_USERNAME }}/chatgpt-to-api:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# 设置基础镜像为 Golang 官方镜像 | ||
FROM golang:1.20.3-alpine | ||
|
||
# 设置环境变量 | ||
# Reverse Proxy - Available on accessToken | ||
# Default: https://bypass.churchless.tech/api/conversation | ||
ENV API_REVERSE_PROXY 'https://bypass.churchless.tech/api/conversation' | ||
ENV SERVER_HOST '0.0.0.0' | ||
|
||
# 设置工作目录为 /app | ||
WORKDIR /app | ||
|
||
# 将本地应用程序复制到容器中 | ||
COPY . . | ||
|
||
# 下载应用程序所需的依赖项 | ||
RUN go mod download | ||
|
||
# 构建应用程序二进制文件 | ||
RUN go build -o app | ||
|
||
# 暴露应用程序运行的端口 | ||
EXPOSE 8080 | ||
|
||
# 启动应用程序 | ||
CMD ["./app"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# ChatGPT-to-API | ||
Create a fake API using ChatGPT's website | ||
|
||
**API endpoint: http://127.0.0.1:8080/v1/chat/completions.** | ||
|
||
**When calling the API, you must include the authorization parameter in the request header: `'Authorization':'Bearer ' + accessToken`.** | ||
|
||
**You can get your accessToken from the following link: [ChatGPT](https://chat.openai.com/api/auth/session)** | ||
|
||
**This API can be used with the project [BetterChatGPT](https://github.com/huangzt/BetterChatGPT)** | ||
|
||
## Docker build & Run | ||
|
||
```bash | ||
docker build -t chatgpt-to-api . | ||
|
||
# Running the API | ||
docker run --name chatgpttoapi -d -p 127.0.0.1:8080:8080 chatgpt-to-api | ||
|
||
# API path | ||
http://127.0.0.1:8080/v1/chat/completions | ||
|
||
``` | ||
|
||
## Docker compose | ||
|
||
[Hub address](https://hub.docker.com/repository/docker/acheong08/chatgpt-to-api/general) | ||
|
||
```yml | ||
version: '3' | ||
|
||
services: | ||
app: | ||
image: acheong08/chatgpt-to-api # Use latest tag | ||
container_name: chatgpttoapi | ||
restart: unless-stopped | ||
ports: | ||
- '8080:8080' | ||
environment: | ||
SERVER_HOST: 0.0.0.0 | ||
SERVER_PORT: 8080 | ||
ADMIN_PASSWORD: TotallySecurePassword | ||
# Reverse Proxy - Available on accessToken | ||
API_REVERSE_PROXY: https://bypass.churchless.tech/api/conversation | ||
# If the parameter API_REVERSE_PROXY is empty, the default request URL is https://chat.openai.com/backend-api/conversation, and the PUID is required. | ||
# You can get your PUID for Plus account from the following link: https://chat.openai.com/api/auth/session. | ||
PUID: xxx | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
version: '3' | ||
|
||
services: | ||
app: | ||
image: acheong08/chatgpt-to-api # 总是使用latest,更新时重新pull该tag镜像即可 | ||
container_name: chatgpttoapi | ||
restart: unless-stopped | ||
ports: | ||
- '8080:8080' | ||
environment: | ||
SERVER_HOST: 0.0.0.0 | ||
SERVER_PORT: 8080 | ||
ADMIN_PASSWORD: TotallySecurePassword | ||
# Reverse Proxy - Available on accessToken | ||
API_REVERSE_PROXY: https://bypass.churchless.tech/api/conversation | ||
# If the parameter API_REVERSE_PROXY is empty, the default request URL is https://chat.openai.com/backend-api/conversation, and the PUID is required. | ||
# You can get your PUID for Plus account from the following link: https://chat.openai.com/api/auth/session. | ||
PUID: xxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters