Open mercedesyenzzz opened 2 years ago
@mercedesyenzzz If you have existing Dockerfile
files for your projects, I would suggest explicitly pointing Tye to those via the tye.yaml
, as well as explicitly setting their Dockerfile contexts. It may be that your existing Dockerfile
files assume a different context than what Tye sets by default.
If that doesn't work, then perhaps you can strip down your workspace into a minimal repro in order to do some investigation?
According to the documentation, setting a Dockerfile is only supported for tye run
. However, this does not seem to work for me. For example, when I run tye run --docker
, tye doesn't seem to use my own Docker image, even if I specify it and the context in tye.yaml
.
In this repository I created there is an AspNetWebApp with a standard Docker image from Microsoft and a standalone Blazorwasm app with a custom Docker image. docker-compose up
works as expected. tye run
works as expected too and already gives me a benefit (--watch & --debug options are very nice). If there are any further questions please let me know.
I thought the repository I created for this issue was sufficient for further investigation, but here are the steps to reproduce the issue:
dotnet new webapp -n WebApp
cd WebApp
cat > Dockerfile <<EOL
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY WebApp.csproj ./
RUN dotnet restore "WebApp.csproj"
COPY . .
RUN dotnet build "WebApp.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "WebApp.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "WebApp.dll"]
EOL
To prove that the Dockerimage is working as expected:
docker build -t webapp .
tye init
or with dockerFile
and dockerFileContext
properties (doesn't make any difference for me):
cat > tye.yaml <<EOL
name: webapp
services:
- name: webapp
project: WebApp.csproj
dockerFile: Dockerfile
dockerFileContext: .
EOL
I am using Windows 10 (Version 1909 (OS Build 18363.1916)
, Docker Desktop 4.3.2 (72729)
and Docker Engine v20.10.11
. I tried this from Windows 10 directly and WSL2 (Ubuntu 20.04) with Tye version 0.10.0-alpha.21420.1+7cec0655cc474aee8d3c3a3d180678985209d439
& 0.11.0-alpha.22057.1+388bd9bbe56ad83b6eeb5104a91ec7eab6af400f
.
tye run
works like expected but tye run --docker
does not seem to use my Dockerimage
. All other commands (tye build, tye push, tye deploy
) give me the error failed to compute cache key: "/WebApp.csproj" not found: not found
i mentioned earlier.
Would be great if someone could take a look at this and tell me if the issue can be reproduced or not, because I would really like to use the deploy
functionality of tye.
I had the same issue with failed to compute cache key: ... .csproj not found and I removed all the Dockerfile and everything was successfully built. You may try to remove all the Dockerfile generated from Visual Studio as a workaround
@fntawiniga this workaround is known to me, but unfortunately it does not work for Blazor Web Assembly Standalone. But good to know that I am not the only one who has this issue!
It looks like tye build
publishes the project locally, and then copies the contents of the publish output into the Docker image. The Dockerfile context, therefore, is fixed to the publish output directory. (That's why the .csproj
file is not found; as it's not part of the context.) If you want to use a custom Dockerfile, it would need to be written with that assumption, which is a very different assumption from other Docker tooling which typically expects the publication to be done in the container, as part of the image creation.
Ahh okay that makes sense, thanks for the explanation. I think for me the effort is less to just manually build, push and deploy my images instead of customizing all my Dockerfiles to tye... Would be very cool if in the future an update will allow me to use custom docker images. 🤞🏾
Not being the original developer/maintainer, I can only speculate as to why build/deploy relies on a local publish when using a custom Dockerfile. I don't see why Tye couldn't just rely on a custom Dockerfile to generate a "complete" image, especially as that would allow the same Dockerfile to be used across run/build/deploy.
Note that this issue is related to (if not a duplicate of) #998.
same issues. tye run --watch is success but tye deploy is failed
I came across Tye yesterday and first of all I have to say that I really like it. :thumbsup: :clap:
However, I can't currently publish anything if I'm already using Docker images in my projects. I want Tye to use my Dockerfiles, which it does. The Dockerfiles themselves work, it's just that Tye can't execute some copy commands when creating them. Would it be possible that the
internal .dockerignore
ignores my.csproj
files?Here is my Dockerfile:
My tye.yaml has nothing special and looks like this:
The output from
tye build -v Debug
:I tried this with version
0.10.0-alpha.21420.1+7cec0655cc474aee8d3c3a3d180678985209d439
&0.11.0-alpha.22057.1+388bd9bbe56ad83b6eeb5104a91ec7eab6af400f
.My guess is that an entry in the
internal .dockerignore
prevents this copy operation. I did not specify a.dockerignore
, but still one is loaded(as you can see in the logs...). Would there be any way for me to change the internal.dockerignore
or has anyone encountered this bug already?Any kind of help is very much appreciated :pray: