Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: optimize docker build process #2

Merged
merged 1 commit into from Oct 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions Dockerfile
@@ -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"]
2 changes: 1 addition & 1 deletion docker-compose.yml
Expand Up @@ -15,11 +15,11 @@ services:
- '3931:1434'

umbraco-netcore:
restart: always
links:
- umbraco-db:umbraco-db
depends_on:
- umbraco-db
restart: always
build:
context: .
dockerfile: Dockerfile
Expand Down
22 changes: 22 additions & 0 deletions src/UmbracoNetCoreDockerExample.Web/.dockerignore
@@ -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