Skip to content

Commit

Permalink
👷 build: fix DNS resolving issue in Docker (lobehub#3837)
Browse files Browse the repository at this point in the history
* 🐛 fix: DNS resolving issue in Docker Compose

* 👷 build: re-generate `resolv.conf` before running

* 🔨 chore: add ref link to comments
  • Loading branch information
hezhijie0327 authored Sep 9, 2024
1 parent 001e1e1 commit 7232c58
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ RUN \
# Install the dependencies
&& pnpm i \
# Add sharp dependencies
&& mkdir -p /sharp \
&& pnpm add sharp --prefix /sharp
&& mkdir -p /deps \
&& pnpm add sharp --prefix /deps

COPY . .

Expand All @@ -80,7 +80,7 @@ COPY --from=builder /app/public /app/public
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder /app/.next/standalone /app/
COPY --from=builder /app/.next/static /app/.next/static
COPY --from=builder /sharp/node_modules/.pnpm /app/node_modules/.pnpm
COPY --from=builder /deps/node_modules/.pnpm /app/node_modules/.pnpm

## Production image, copy all the files and run next
FROM base
Expand Down Expand Up @@ -188,5 +188,12 @@ CMD \
"$protocol $host $port" \
> "/etc/proxychains/proxychains.conf"; \
fi; \
# Fix DNS resolving issue in Docker Compose, ref https://github.com/lobehub/lobe-chat/pull/3837
if [ -f "/etc/resolv.conf" ]; then \
resolv_conf=$(grep '^nameserver' "/etc/resolv.conf" | awk '{print "nameserver " $2}'); \
printf "%s\n" \
"$resolv_conf" \
> "/etc/resolv.conf"; \
fi; \
# Run the server
${PROXYCHAINS} node "/app/server.js";
7 changes: 7 additions & 0 deletions Dockerfile.database
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ CMD \
"$protocol $host $port" \
> "/etc/proxychains/proxychains.conf"; \
fi; \
# Fix DNS resolving issue in Docker Compose, ref https://github.com/lobehub/lobe-chat/pull/3837
if [ -f "/etc/resolv.conf" ]; then \
resolv_conf=$(grep '^nameserver' "/etc/resolv.conf" | awk '{print "nameserver " $2}'); \
printf "%s\n" \
"$resolv_conf" \
> "/etc/resolv.conf"; \
fi; \
# Run migration
node "/app/docker.cjs"; \
if [ "$?" -eq "0" ]; then \
Expand Down

0 comments on commit 7232c58

Please sign in to comment.