From c8be5e42671e534e3382db67f80560442086772c Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Sun, 9 Apr 2023 00:56:56 +0800 Subject: [PATCH] feat: add docker proxy --- Dockerfile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6f7547b21..47373c906 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \ No newline at end of file