I'm trying to compose my two projects with one solution:
-Root
.sln
docker-compose.yml
-Application.Api
Dockerfile
-Application.SMTP
Dockerfile
My Dockerfile in Application.Api:
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
WORKDIR /app
EXPOSE 443
EXPOSE 80
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY ../ ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "Application.Api.dll"]
Dockerfile in Application.SMTP:
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
WORKDIR /app
EXPOSE 443
EXPOSE 80
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY ../ ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "Application.SMTP.dll"]
And my docker-compose is:
version: '3.4'
services:
application.smtp:
image: ${DOCKER_REGISTERY-}eshopsmtp
build:
context: .
dockerfile: Application.SMTP/Dockerfile
application.api:
image: ${DOCKER_REGISTERY-}eshopapi
build:
context: .
dockerfile: Application.Api/Dockerfile
When I use docker-compose build:
When I am trying to run Dockerfile from Api it crashes, because couldn't find reference from SMTP:
How to compose these two projects? I couldn't find any solution that works for me