Skip to content

Commit

Permalink
Merge pull request #2 from thecogworks/fix/docker
Browse files Browse the repository at this point in the history
fix: optimize docker build process
  • Loading branch information
aochmann committed Oct 17, 2020
2 parents 40b1c8b + c1373d6 commit daca178
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
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

0 comments on commit daca178

Please sign in to comment.