feat: add docker proxy

This commit is contained in:
Yidadaa 2023-04-09 00:56:56 +08:00
parent 40b8b225f9
commit c8be5e4267
1 changed files with 11 additions and 1 deletions

View File

@ -3,6 +3,7 @@ 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
@ -27,6 +28,7 @@ RUN yarn build
FROM base AS runner
WORKDIR /app
ENV PROXY_URL=""
ENV OPENAI_API_KEY=""
ENV CODE=""
@ -37,4 +39,12 @@ COPY --from=builder /app/.next/server ./.next/server
EXPOSE 3000
CMD ["node","server.js"]
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; \
else \
node server.js; \
fi