I am trying to setup a docker compose deployment but I have having an issue with the COPY that is in one of the projects. I have tried changing the path a few times without any luck. I continue to get the following issue:
ERROR: Service 'cryptoappapi' failed to build : COPY failed: file not found in
build context or excluded by .dockerignore: stat
CryptoApp.Api/CryptoApp.Api.csproj: file does not exist
This is my layout
This is my docker file is standard:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["CryptoApp.Api/CryptoApp.Api.csproj", "CryptoApp.Api/"]
RUN dotnet restore "CryptoApp.Api/CryptoApp.Api.csproj"
COPY . .
WORKDIR "/src/CryptoApp.Api"
RUN dotnet build "CryptoApp.Api.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "CryptoApp.Api.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "CryptoApp.Api.dll"]
This is my docker compose:
services:
# First the AspNet Core app
cryptoappapi:
## Get the image to use and set the container name
image: cryptoappapi:latest
container_name: cryptoappapi
# State a dependancy on Redis working
depends_on:
- "redis_image"
- "postgres_image"
# Location of the Dockerfile
build:
context: ./CryptoApp.Api
dockerfile: Dockerfile
# Set access ports for localhost on the left
ports:
- "80:5000"
- "443:5001"
# Configure a link to Redis
links:
- "redis_image"
- "postgres_image"
# The Application needs a connection string for Redis, this just needs to be the Redis Service name as defined below
# Pass it in as an Environmental Variable
environment:
- RedisConnection=redis_image
- DB_CONNECTION_STRING="host=postgres_image;port=5432;database=xx;username=xxx;password=xxx"
# Set them all to the same network
networks:
- dockerapi-dev
