Skip to content

Commit

Permalink
feat: add proxy for docker
Browse files Browse the repository at this point in the history
  • Loading branch information
Yidadaa committed Apr 9, 2023
1 parent c8be5e4 commit 1bb7b4a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
18 changes: 14 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ FROM node:18-alpine AS base
FROM base AS deps

RUN apk add --no-cache libc6-compat
RUN apk --no-cache add proxychains-ng

WORKDIR /app

COPY package.json yarn.lock ./

RUN yarn config set registry 'https://registry.npm.taobao.org'
RUN yarn install

FROM base AS builder
Expand All @@ -28,6 +28,8 @@ RUN yarn build
FROM base AS runner
WORKDIR /app

RUN apk add proxychains-ng

ENV PROXY_URL=""
ENV OPENAI_API_KEY=""
ENV CODE=""
Expand All @@ -43,8 +45,16 @@ CMD if [ -n "$PROXY_URL" ]; then \
protocol=$(echo $PROXY_URL | cut -d: -f1); \
host=$(echo $PROXY_URL | cut -d/ -f3 | cut -d: -f1); \
port=$(echo $PROXY_URL | cut -d: -f3); \
echo "$protocol $host $port" >> /etc/proxychains.conf; \
proxychains node server.js; \
conf=/etc/proxychains.conf; \
echo "strict_chain" >> $conf; \
echo "proxy_dns" >> $conf; \
echo "remote_dns_subnet 224" >> $conf; \
echo "tcp_read_time_out 15000" >> $conf; \
echo "tcp_connect_time_out 8000" >> $conf; \
echo "[ProxyList]" >> $conf; \
echo "$protocol $host $port" >> $conf; \
cat /etc/proxychains.conf; \
proxychains -f $conf node server.js; \
else \
node server.js; \
fi
fi
15 changes: 7 additions & 8 deletions scripts/fetch-prompts.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import fetch from "node-fetch";
import fs from "fs/promises";

const RAW_CN_URL =
"https://raw.githubusercontent.com/PlexPt/awesome-chatgpt-prompts-zh/main/prompts-zh.json";
const CN_URL =
"https://cdn.jsdelivr.net/gh/PlexPt/awesome-chatgpt-prompts-zh@main/prompts-zh.json";
const RAW_EN_URL =
"https://raw.githubusercontent.com/f/awesome-chatgpt-prompts/main/prompts.csv";
const EN_URL =
"https://cdn.jsdelivr.net/gh/f/awesome-chatgpt-prompts@main/prompts.csv";
const RAW_FILE_URL = "https://raw.githubusercontent.com/";
const MIRRORF_FILE_URL = "https://raw.fgit.ml/";

const RAW_CN_URL = "PlexPt/awesome-chatgpt-prompts-zh/main/prompts-zh.json";
const CN_URL = MIRRORF_FILE_URL + RAW_CN_URL;
const RAW_EN_URL = "f/awesome-chatgpt-prompts/main/prompts.csv";
const EN_URL = MIRRORF_FILE_URL + RAW_EN_URL;
const FILE = "./public/prompts.json";

async function fetchCN() {
Expand Down

0 comments on commit 1bb7b4a

Please sign in to comment.