Задать вопрос
zenithxxl
@zenithxxl
Веб-разработчик

Почему приложение не может получить доступ к бэкенду?

Репозиторий
Я связываю Next.js+Nest.js+Nginx+PostgreSQL в один docker-compose.yaml
Для сборки Next.js необходимо рабочее api, по этому я разделил запуск на две части: запуск бэкендной части и фронтендной
  1. docker-compose up backend database -d --build
  2. ) (заполнение бд) docker-compose exec backend bun prisma db push
    docker-compose exec backend bun seed
  3. docker-compose up frontend nginx -d --build


Перед вторым этапом я проверяю работоспособность апи
Но несмотря ни на что, почему то образ frontend не собирается, можете подсказать как это исправить?

=> CACHED [frontend builder 5/6] COPY . . 0.0s
=> ERROR [frontend builder 6/6] RUN bun run build 18.6s
------
> [frontend builder 6/6] RUN bun run build:
0.239 $ next build
1.100 Attention: Next.js now collects completely anonymous telemetry regarding usage.
1.100 This information is used to shape Next.js' roadmap and prioritize features.
1.100 You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
1.100 https://nextjs.org/telemetry
1.100
1.165 ▲ Next.js 15.3.2
1.165 - Environments: .env.production
1.165
1.180 Creating an optimized production build ...
12.04 ✓ Compiled successfully in 5.0s
12.06 Linting and checking validity of types ...
13.95 Collecting page data ...
18.58 Error: Unable to connect. Is the computer able to access the url?
18.58 at (.next/server/chunks/853.js:1:174236)
18.58 at (.next/server/chunks/853.js:3:9605)
18.58 at (.next/server/chunks/853.js:3:49033)
18.58 at processTicksAndRejections (null)
18.58 at (.next/server/chunks/853.js:3:21290)
18.58 at processTicksAndRejections (null) {
18.58 errno: 0,
18.58 path: 'backend-test:4200/api',
18.58 code: 'ConnectionRefused',
18.58 config: [Object],
18.58 request: [Writable],
18.58 constructor: [Function],
18.58 toJSON: [Function: toJSON],
18.58 [cause]: [Error: Unable to connect. Is the computer able to access the url?] {
18.58 code: 'ConnectionRefused',
18.58 path: 'backend-test:4200/api',
18.58 errno: 0
18.58 }
18.58 }
18.58
18.58 > Build error occurred
18.58 Error: Failed to collect page data for /users/[id]
18.58 at processTicksAndRejections (null) {
18.58 type: 'Error'
18.58 }
18.61 error: script "build" exited with code 1
------
failed to solve: process "/bin/sh -c bun run build" did not complete successfully: exit code: 1


Версии:
Docker: 28.0.4
Next.js: 15.3.2
Windows 11
  • Вопрос задан
  • 80 просмотров
Подписаться 1 Простой 6 комментариев
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы