diff --git a/Dockerfile b/Dockerfile index da5b41315e56..8142403b6e1b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,12 +10,13 @@ RUN \ fi \ # Add required package & update base package && apk update \ - && apk add --no-cache bind-tools proxychains-ng \ + && apk add --no-cache bind-tools proxychains-ng sudo \ && apk upgrade --no-cache \ # Add user nextjs to run the app && addgroup --system --gid 1001 nodejs \ && adduser --system --uid 1001 nextjs \ && chown -R nextjs:nodejs "/etc/proxychains" \ + && echo "nextjs ALL=(ALL) NOPASSWD: /bin/chmod * /etc/resolv.conf" >> /etc/sudoers \ && rm -rf /tmp/* /var/cache/apk/* ## Builder image, install all the dependencies and build the app @@ -190,6 +191,7 @@ CMD \ fi; \ # Fix DNS resolving issue in Docker Compose, ref https://github.com/lobehub/lobe-chat/pull/3837 if [ -f "/etc/resolv.conf" ]; then \ + sudo chmod 666 "/etc/resolv.conf"; \ resolv_conf=$(grep '^nameserver' "/etc/resolv.conf" | awk '{print "nameserver " $2}'); \ printf "%s\n" \ "$resolv_conf" \ diff --git a/Dockerfile.database b/Dockerfile.database index 56e6dd6d6d8c..33ee0ea08f3e 100644 --- a/Dockerfile.database +++ b/Dockerfile.database @@ -10,12 +10,13 @@ RUN \ fi \ # Add required package & update base package && apk update \ - && apk add --no-cache bind-tools proxychains-ng \ + && apk add --no-cache bind-tools proxychains-ng sudo \ && apk upgrade --no-cache \ # Add user nextjs to run the app && addgroup --system --gid 1001 nodejs \ && adduser --system --uid 1001 nextjs \ && chown -R nextjs:nodejs "/etc/proxychains" \ + && echo "nextjs ALL=(ALL) NOPASSWD: /bin/chmod * /etc/resolv.conf" >> /etc/sudoers \ && rm -rf /tmp/* /var/cache/apk/* ## Builder image, install all the dependencies and build the app @@ -222,6 +223,7 @@ CMD \ fi; \ # Fix DNS resolving issue in Docker Compose, ref https://github.com/lobehub/lobe-chat/pull/3837 if [ -f "/etc/resolv.conf" ]; then \ + sudo chmod 666 "/etc/resolv.conf"; \ resolv_conf=$(grep '^nameserver' "/etc/resolv.conf" | awk '{print "nameserver " $2}'); \ printf "%s\n" \ "$resolv_conf" \