Хорошо, я пытаюсь заставить сборку docker-compose работать с API ядра .net.структура папок выглядит следующим образом:
- серверная часть
- дБ
- сервисы
- SRC
- test
- services.sln
- Dockerfile
- client
- docker-compose.yml
Мой корневой файл docker-compose.yml выглядит следующим образом:
version: '3.3'
services:
plan-analytics-postgres:
container_name: plan-analytics-postgres
restart: always
environment:
POSTGRES_USER: admin
POSTGRES_PASSWORD: admin
PGPASSWORD: admin
build:
context: ./backend/db
ports:
- '5432:5432'
networks:
- 'backend-net'
plan-analytics-services:
container_name: plan-analytics-services
build:
context: ./backend/services
ports:
- '9001:9001'
volumes:
- './backend/services/api:/services'
environment:
NODE_ENV: 'dev'
port: '9001'
BABEL_DISABLE_CACHE: 1
DATABASE_URL: 'postgres://admin:admin@plan-analytics-postgres:5432/plan-analytics'
DATABASE_TEST_URL: 'postgres://admin:admin@plan-analytics-postgres:5432/plan-analytics-integration'
networks:
- 'backend-net'
- 'frontend-net'
plan-analytics-web:
container_name: plan-analytics-web
build:
context: ./client
ports:
- '3000:3000'
- '35729:35729'
environment:
NODE_ENV: 'development'
CHOKIDAR_USEPOLLING: 1
volumes:
- './client:/src/app'
- '/src/app/node_modules'
depends_on:
- 'plan-analytics-postgres'
- 'plan-analytics-services'
networks:
- 'frontend-net'
networks:
frontend-net:
driver: bridge
backend-net:
driver: bridge
message-net:
driver: bridge
Dockerfiles для клиента и базы данных работают, как и ожидалось, но мне не повезло с настройкой и запуском моего API.У меня есть аналогичная установка с узлом API, и он работает чудесно.Я хотел бы помочь, выяснить, что не так с Dockerfile, который запускает C # API.Вот его содержание:
FROM microsoft/dotnet:2.1-sdk AS builder
RUN mkdir -p src/services
WORKDIR /services
# Add ./NuGet.config
COPY ./*.sln ./
COPY src/*/*.csproj ./
RUN for file in $(ls *.csproj); do mkdir -p src/${file%.*}/ && mv $file src/${file%.*}/; done
# COPY test/*/*.csproj ./
# RUN for file in $(ls *.csproj); do mkdir -p test/${file%.*}/ && mv $file test/${file%.*}/; done
RUN dotnet restore
COPY ./src/api ./src/api
# COPY ./test ./test
RUN dotnet build -c Release --no-restore
# FROM build as publish
# WORKDIR /src/services/api
# RUN dotnet publish -c Release -o out
# Do the following when we add NuGet packages
# RUN dotnet build -c Release --no-restore
RUN dotnet publish "./src/api/api.csproj" -c Release -o "../../dist" --no-restore
# Build runtime image
FROM microsoft/dotnet:2.1.0
WORKDIR /services
COPY --from=build /services/dist .
ENTRYPOINT ["dotnet", "api.dll"]
Это ошибка, которую я получаю:
Step 9/14 : RUN dotnet build -c Release --no-restore
---> Running in 47ffd4456e9d
Microsoft (R) Build Engine version 15.8.166+gd4e8d81a88 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
/usr/share/dotnet/sdk/2.1.402/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(198,5): error NETSDK1004: Assets file '/Users/bryce/Documents/stacks/react-redux-to-net-core-postgres/backend/services/src/api/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [/services/src/api/api.csproj]
Build FAILED.
/usr/share/dotnet/sdk/2.1.402/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(198,5): error NETSDK1004: Assets file '/Users/bryce/Documents/stacks/react-redux-to-net-core-postgres/backend/services/src/api/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [/services/src/api/api.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.54
ERROR: Service 'plan-analytics-services' failed to build: The command '/bin/sh -c dotnet build -c Release --no-restore' returned a non-zero code: 1