Best practices for using Paket with monorepos and Docker builds
See original GitHub issueWhat are the best practices for using Paket with monorepos and Docker builds?
We have a fairly large repository 2.5GB and when we’re doing Docker builds for projects further down the tree, it takes way too much time, because .paket/ is in the root and is needed as a part of the build context.
When we do the following, it takes up to 5 minutes:
$ pwd
/monorepo
$ docker build -t api -f DocumentAPI/Dockerfile .
Dockerfile:
ARG DOTNETCORE_VERSION="2.0"
FROM microsoft/aspnetcore-build:${DOTNETCORE_VERSION} AS build
ARG PROJECT_NAME="DocumentAPI"
WORKDIR /app
# Install Mono
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF \
&& echo "deb http://download.mono-project.com/repo/debian wheezy-libjpeg62-compat main" | tee -a /etc/apt/sources.list.d/mono-xamarin.list \
&& echo "deb http://download.mono-project.com/repo/debian wheezy/snapshots/4.4.2.11 main" | tee -a /etc/apt/sources.list.d/mono-xamarin.list \
&& apt-get update -yq \
&& apt-get install -yq mono-devel \
&& rm -rf /var/lib/apt/lists/*
RUN echo ${PROJECT_NAME}
# Copy everything and run build
RUN mkdir ${PROJECT_NAME}
COPY . ${PROJECT_NAME}
RUN dotnet restore ${PROJECT_NAME}
RUN dotnet build ${PROJECT_NAME}
# Create a intermediate image and run tests
FROM build AS testrunner
WORKDIR /app
RUN dotnet test
ENTRYPOINT ["dotnet", "test"]
# Publish runtime artifacts to a seperate folder
FROM build as publish
WORKDIR /app/${PROJECT_NAME}/${PROJECT_NAME}
RUN dotnet publish -c Release -o out
# Create a runtime image
FROM microsoft/aspnetcore:${DOTNETCORE_VERSION}-runtime AS runtime
WORKDIR /app
COPY --from=publish /app/${PROJECT_NAME}/${PROJECT_NAME}/out .
EXPOSE 8080
ENTRYPOINT ["dotnet", "DocumentAPI.exe"]
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Efficient Docker builds for large monorepos
In this post, I show you how to build images from monorepos incrementally, reusing previous builds beyond the Docker build cache. The solution...
Read more >Building applications on a monorepo with Docker containers
Compiling an application in Docker from a monorepo · Copy files into the build container · Execute dotnet restore on your application ·...
Read more >Building multiple images from a monorepo where each ...
1 Answer 1 · yes, you'd need to modify the azure-pipelines.yml for that. · no. one for all or one for each dockerfile...
Read more >Exploring the Monorepo #5: Perfect Docker
Hi, let's start with a recap: We have a pnpm-based monorepo that contains two apps and three libraries. All those packages are Dockerized....
Read more >Advice about CI/CD with Docker and a monorepo
The key to having an efficient monorepo CI setup is efficient caching. Each part of your build should know how to not build...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@gaui can
.dockerignore
help you?Actually, the
.dockerignore
files has to be on the same level as thedocker build .
command , and is always relative from that. I would like to see Docker look up the.dockerignore
file with a bottom-up approach, from the same location as the Dockerfile in the-f
flag, where you could ignore files from the root context, but specify all.dockerignore
rules from the project folder. This is just how Docker works. I raised this in the docker/cli repo. Going to close this issue.