Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

Visual Studioの謎のDockerfile

More than 1 year has passed since last update.
FROM mcr.microsoft.com/dotnet/core/runtime:2.2-stretch-slim AS base
WORKDIR /app


FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build
WORKDIR /src
COPY ["hoge-server/hoge-server.csproj", "hoge-server/"]
RUN dotnet restore "hoge-server/hoge-server.csproj"
COPY . .
WORKDIR "/src/hoge-server"
RUN dotnet build "hoge-server.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "hoge-server.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "hoge-server.dll"]

 こんなファイルなんですけど、これを普通にたたくとバグるんですよね。

Step 7/17 : COPY ["hoge-server/hoge-server.csproj", "hoge-server/"]
ERROR: Service 'hoge-server' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder655807069/hoge-server/hoge-server.csproj: no such file or directory

あたりまえだけどファイルの指定位置がおかしい。Dockerfileがhoge-serverディレクトリの中にあるのに、hoge-serverディレクトリの中を見に行くみたいなことになってるんですよね。一旦上のディレクトリにDockerfileを持ち上げてるような動きをしてる。で、ためしにもちあげて実行すると普通にうごくんですよね。

なので同じDockerfileを二つ置いて運用しています。いやーなんでこんな仕様になってるのか教えてくれ~

piffett
Unityクライアントエンジニア(になる予定)
https://piffett.hateblo.jp/
shinonomeinc
東京理科大学発ベンチャー。提携大学内にソフトウェア研究所を組織し、学生向けのTech教育を提供しています。
http://shinonome.io
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away