GithubHelp home page GithubHelp logo

william-yeh / kaniko-demo Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 15 KB

Demonstrate how Kaniko makes use of build cache

C# 59.50% Dockerfile 4.62% CSS 2.25% HTML 8.54% JavaScript 25.09%
docker kaniko

kaniko-demo's Introduction

Kaniko demo

This repo is to demonstrate how Kaniko makes use of build cache.

Build images with Docker CLI

  1. Initial build:

    % docker build  -t todoapi:1  src 
    
  2. Build again with cache:

    % docker build  -t todoapi:2  src 
    
  3. Modify src and re-build with cache:

    % touch src/empty-3
    
    % docker build  -t todoapi:3  src 
    

Result:

Step Time
1 3m19s
2 0m5.81s
3 0m15.85s

Build images with Kaniko

  1. Set environment variable PROJECT_ID and REPO for convenience:

    % export PROJECT_ID=project_id_of_your_gcp_project
    
    % export REPO=repo_name_of_your_image
    
  2. Initial build with empty cache:

    % time \
      docker run --rm  -v $(pwd)/src:/kaniko-workspace  \
      gcr.io/kaniko-project/executor:latest             \
          --cache=true  --context=/kaniko-workspace     \
          --destination=gcr.io/$PROJECT_ID/$REPO
    
  3. Build again with cache:

    % time \
      docker run --rm  -v $(pwd)/src:/kaniko-workspace  \
      gcr.io/kaniko-project/executor:latest             \
          --cache=true  --context=/kaniko-workspace     \
          --destination=gcr.io/$PROJECT_ID/$REPO
    
  4. Modify src and re-build with cache:

    % touch src/empty-4
    
    % time \
      docker run --rm  -v $(pwd)/src:/kaniko-workspace  \
      gcr.io/kaniko-project/executor:latest             \
          --cache=true  --context=/kaniko-workspace     \
          --destination=gcr.io/$PROJECT_ID/$REPO
    

Result:

Step Time
2 4m23s
3 1m20s
4 1m55s

Caveat with Kaniko + .NET Core SDK

If you use dotnet/core/sdk as base image, you may encounter error messages near the end of Kaniko build steps, similar to the following:

error building image: error building stage: Unable to add file /tmp/clr-debug-pipe-149-16587078-out to layered map: Error creating hash for /tmp/clr-debug-pipe-149-16587078-out: lstat /tmp/clr-debug-pipe-149-16587078-out: no such file or directory

A workaround is to set environment variable COMPlus_EnableDiagnostics before dotnet publish in Dockerfile:

ENV COMPlus_EnableDiagnostics=0
...
dotnet publish

For more info, see GoogleContainerTools/kaniko#391 (comment)

About the TodoApi source code

The sample code in src directory was extracted from the TodoApi demo in the Microsoft Docs site, retrieved on Nov 27, 2019:

The original source code to be used in this repo is packed in the TodoApi-original.zip file for your reference.

kaniko-demo's People

Contributors

william-yeh avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.