Skip to content

Commit

Permalink
🐛 fix: fix /etc/resolv.confedit permission in docker image (lobehub…
Browse files Browse the repository at this point in the history
  • Loading branch information
hezhijie0327 authored Sep 10, 2024
1 parent 99acb93 commit fdaa190
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" \
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile.database
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" \
Expand Down

0 comments on commit fdaa190

Please sign in to comment.