Reputation: 592
I have a docker-compose file that works just fine, and a test-containers.ps1 script that run docker-compose. Everything works great locally.
version: '3.4'
services:
horizon.api.v1:
image: ${DOCKER_REGISTRY-}horizonapiv1
environment:
ASPNETCORE_ENVIRONMENT: Development
build:
context: .
dockerfile: api/horizon.api.v1/Dockerfile
Here's the dockerfile to which the docker-compose and heroku.yml files refer:
# horizon.api
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY api/horizon.api.v1/horizon.api.v1.csproj api/horizon.api.v1/
RUN dotnet restore api/horizon.api.v1/horizon.api.v1.csproj
COPY . .
WORKDIR /src/api/horizon.api.v1
RUN dotnet build horizon.api.v1.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish horizon.api.v1.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "horizon.api.v1.dll"]
I wanted to get this up and running in Heroku so my students could see it running, and so students that don't have access to docker could play with the application. I made a heroku.yml file that looks like it should work...but this is the first time I've ever used heroku and it's probable I'm doing something stupid.
build:
config:
ASPNETCORE_ENVIRONMENT: Development
docker:
api: ./api/horizon.api.v1/Dockerfile
When I try to push my repo to heroku I get the following error:
remote: Step 7/17 : COPY ["routing/horizon.routing/horizon.routing.csproj", "routing/horizon.routing/"]
remote: COPY failed: stat /var/lib/docker/tmp/docker-builder722311220/routing/horizon.routing/horizon.routing.csproj: no such file or directory
I've seen a few posts online about a .dockerignore file causing problems, so I renamed my .dockerignore file to take it out of the picture until I figure this out.
The paths should all be correct, why does docker-compose not have any problem finding the necessary paths on my local machine but heroku says they don't exist? What am I doing wrong?
Upvotes: 1
Views: 1361
Reputation: 36
I believe it's probably related to the build context. I'm guessing Heroku doesn't use the context from the root of the project, and uses the directory where the Dockerfile is located.
Upvotes: 2