Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from thecogworks/fix/docker
fix: optimize docker build process
- Loading branch information
Showing
3 changed files
with
33 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env | ||
WORKDIR /app | ||
|
||
COPY *.sln . | ||
COPY *.sln ./ | ||
|
||
COPY NuGet.config . | ||
COPY NuGet.config ./ | ||
|
||
COPY src/*/*.csproj ./ | ||
RUN for file in $(ls *.csproj); do mkdir -p src/${file%.*}/ && mv $file src/${file%.*}/; done | ||
|
||
RUN ls ./src/ -a | ||
|
||
RUN dotnet restore | ||
|
||
# Copy everything else and build | ||
COPY . ./ | ||
RUN dotnet publish -c Release -o ./out | ||
RUN dotnet build -c Release -o ./out/build | ||
|
||
FROM build-env AS publish | ||
RUN dotnet publish -c Release -o ./out/publish --no-restore | ||
|
||
COPY ./src/UmbracoNetCoreDockerExample.Web/umbraco ./out/publish/umbraco | ||
|
||
# Build runtime image | ||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 | ||
WORKDIR /app | ||
ENV ASPNETCORE_URLS=http://+:80 | ||
COPY --from=build-env /app/out ./ | ||
COPY --from=publish /app/out/publish ./ | ||
|
||
ENTRYPOINT ["dotnet", "UmbracoNetCoreDockerExample.Web.dll"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,25 @@ | ||
* | ||
!obj/Docker/publish/* | ||
!obj/Docker/empty/ | ||
|
||
!config/* | ||
!config/ | ||
!config/**/* | ||
!umbraco/* | ||
!umbraco/ | ||
!umbraco/**/* | ||
.git | ||
.cache | ||
.vs | ||
.vscode | ||
.gitignore | ||
.dockerignore | ||
Dockerfile.* | ||
Dockerfile | ||
bin | ||
obj | ||
appsettings.Development.json | ||
appsettings.local.json | ||
configs/ms.sql.env | ||
*.csproj.user | ||
*.md |