ChatGPT-Next-Web/Dockerfile

65 lines
1.5 KiB
Docker
Raw Normal View History

FROM node:18-alpine AS base
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
2023-03-31 01:41:43 +08:00
COPY package.json yarn.lock ./
2023-05-04 11:26:14 +08:00
RUN yarn config set registry 'https://registry.npmmirror.com/'
2023-03-31 01:41:43 +08:00
RUN yarn install
FROM base AS builder
RUN apk update && apk add --no-cache git
ENV OPENAI_API_KEY=""
2023-12-24 17:54:33 +08:00
ENV GOOGLE_API_KEY=""
ENV CODE=""
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN yarn build
FROM base AS runner
WORKDIR /app
2023-04-09 20:35:42 +08:00
RUN apk add proxychains-ng
2023-04-09 00:56:56 +08:00
ENV PROXY_URL=""
ENV OPENAI_API_KEY=""
2023-12-24 17:54:33 +08:00
ENV GOOGLE_API_KEY=""
ENV CODE=""
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/.next/server ./.next/server
EXPOSE 3000
2023-04-09 00:56:56 +08:00
CMD if [ -n "$PROXY_URL" ]; then \
2024-06-26 17:36:14 +08:00
export HOSTNAME="0.0.0.0"; \
2023-12-24 17:54:33 +08:00
protocol=$(echo $PROXY_URL | cut -d: -f1); \
host=$(echo $PROXY_URL | cut -d/ -f3 | cut -d: -f1); \
port=$(echo $PROXY_URL | cut -d: -f3); \
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 "localnet 127.0.0.0/255.0.0.0" >> $conf; \
echo "localnet ::1/128" >> $conf; \
echo "[ProxyList]" >> $conf; \
echo "$protocol $host $port" >> $conf; \
cat /etc/proxychains.conf; \
2024-06-26 17:36:14 +08:00
proxychains -f $conf node server.js; \
2023-04-09 00:56:56 +08:00
else \
2023-12-24 17:54:33 +08:00
node server.js; \
2023-04-09 20:35:42 +08:00
fi