EJo*_*EJo 2 docker .net-core dockerfile docker-swarm docker-container
我正在使用 Visual Studio 2017 for MAC 运行 .netcore2.0 webapi。我有一个项目结构如下。
src
--Solution.sln
-- Common
-- commonPrj
-- Common.csproj
--Data
-- QM
-- QM.csproj
--Repo
--Repo.csproj
--Ser
-- Host
-- Api
--api.csproj
Run Code Online (Sandbox Code Playgroud)
我也有 DOCKERFILE 内容。这是在执行 dotnet 构建过程时抛出错误,因为构建代理无法解析 common.csproj/ 我认为我的 dockerfile 定义是错误的。有人可以协助完成这项工作吗[我在这里用 dockerfile 尝试了很多选项]>?
#FROM microsoft/aspnetcore-build:2.0 AS build-env
FROM microsoft/aspnetcore
# copy csproj and restore as distinct layers
#COPY *.csproj ./
#RUN dotnet restore
# copy everything else and build
#COPY . ./ ./ ./
#RUN dotnet restore
#RUN dotnet publish -c Release -o out
# build runtime image
#FROM microsoft/aspnetcore:2.0
#WORKDIR /app
#COPY --from=build-env /app/out .
#EXPOSE 5000
COPY ./out /out
WORKDIR /out
#WORKDIR /publish
ENTRYPOINT ["dotnet", "Rando.MortgageCenter.WebAPI.dll"]
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用 Docker 云环境 [cloud.docker.com/swarm] 构建这个 docker 镜像
Error Log from docker cloud build
Building in Docker Cloud's infrastructure...
Cloning into '.'...
Warning: Permanently added the RSA host key for IP address '104.192.143.1' to the list of known hosts.
Reset branch 'master'
Your branch is up-to-date with 'origin/master'.
KernelVersion: 4.4.0-93-generic
Arch: amd64
BuildTime: 2017-08-17T22:50:04.828747906+00:00
ApiVersion: 1.30
Version: 17.06.1-ce
MinAPIVersion: 1.12
GitCommit: 874a737
Os: linux
GoVersion: go1.8.3
Starting build of index.docker.io/systreeau/mortgagecenter:latest...
Step 1/4 : FROM microsoft/aspnetcore
---> f79840764591
Step 2/4 : COPY ./out /out
COPY failed: stat /var/lib/docker/tmp/docker-builder177013174/out: no such file or directory
ERROR: Build failed: COPY failed: stat /var/lib/docker/tmp/docker-builder177013174/out: no such file or directory
ERROR: Build failed with exit code 2
Run Code Online (Sandbox Code Playgroud)
所以我发现你必须将你的 DOCKERFILE 放在 src 文件夹中,这是解决方案的根目录。这样 docker 上下文就变成了这条路径。
现在你有一个 Dockerfile 如下
FROM microsoft/aspnetcore-build:2.0 as build
WORKDIR /app
COPY . .
#COPY Solution.sln .
# RUN ls -l
RUN dotnet restore ./Solution.sln
COPY . .
RUN dotnet publish ./Ser/Host/Api/api.csproj --output /out/ --configuration Release
# runtime image
FROM microsoft/aspnetcore:2.0
WORKDIR /app
COPY --from=build /out .
ENTRYPOINT ["api.dll"]
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助遇到我面临的问题的人
归档时间: |
|
查看次数: |
1930 次 |
最近记录: |