《使用云原生構建包打包.pdf》由會員分享,可在線閱讀,更多相關《使用云原生構建包打包.pdf(52頁珍藏版)》請在三個皮匠報告上搜索。
1、#CiscoLive#CiscoLive#CiscoLive#CiscoLiveAshley Novak,Principal Engineer,CPX CloudOpsabnovakDEVNET-2000Pack it up with Cloud Native Buildpacks 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveEnter y
2、our personal notes hereCisco Webex App 3Questions?Use Cisco Webex App to chat with the speaker after the sessionFind this session in the Cisco Live Mobile AppClick“Join the Discussion”Install the Webex App or go directly to the Webex spaceEnter messages/questions in the Webex spaceHowWebex spaces wi
3、ll be moderated by the speaker until June 9,2023.12343https:/ 2023 Cisco and/or its affiliates.All rights reserved.Cisco PublicDEVNET-2000Agenda 2023 Cisco and/or its affiliates.All rights reserved.Cisco PublicAgenda 2023 Cisco and/or its affiliates.All rights reserved.Cisco PublicIntroductionDocker
4、file HurdlesCloud Native Buildpacks OverviewDemoCNB LifecycleAdvanced CNB CapabilitiesConclusion&QADEVNET-20004 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveAshley NovakPrincipal Engineer,CPX,ON
5、Ex Engineering Planning,Agility&Operations,Cisco 5DEVNET-2000ExperienceExperience16+years of Enterprise Application Development,leading development teams to create scalable architecturesFocused on Cloud Native technologies,approaches,and patterns for the past 8 yearsCurrently working within Ciscos C
6、ustomer and Partner Engineering(CPX)organization aligning technical tools,standards,and approaches across our many groups and engineers.Lives in the Chicagoland area with my wife,two sons,and an 8lb white fluffy dog that thinks hes a bunny 2023 Cisco and/or its affiliates.All rights reserved.Cisco P
7、ublic#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveDocker!=DockerfileDEVNET-20007 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveDockerfile HurdlesFROM debi
8、anCOPY./appRUN apt-get updateRUN apt-get y install openjdk-8-jdk ssh vimCMD“java”,“-jar”,“/app/target/app.jar”DEVNET-20008 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveDockerfile HurdlesOrder Ma
9、tters for CachingFROM debianCOPY./appRUN apt-get updateRUN apt-get y install openjdk-8-jdk ssh vimCOPY./appCMD“java”,“-jar”,“/app/target/app.jar”DEVNET-20009 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#
10、CiscoLiveDockerfile HurdlesFROM debianRUN apt-get updateRUN apt-get y install openjdk-8-jdk ssh vimCOPY./appCMD“java”,“-jar”,“/app/target/app.jar”DEVNET-200010 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Publi
11、c#CiscoLiveDockerfile HurdlesMore Specific COPY to limit cache bustsFROM debianRUN apt-get updateRUN apt-get y install openjdk-8-jdk ssh vimCOPY./appCOPY target/app.jar/appCMD“java”,“-jar”,“/app/target/app.jar”DEVNET-200011 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive
12、2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveDockerfile HurdlesFROM debianRUN apt-get updateRUN apt-get y install openjdk-8-jdk ssh vimCOPY target/app.jar/appCMD“java”,“-jar”,“/app/app.jar”DEVNET-200012 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#C
13、iscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveDockerfile HurdlesIdentify caching optimizationsFROM debianRUN apt-get updateRUN apt-get y install openjdk-8-jdk ssh vimRUN apt-get update&apt-get y install openjdk-8-jdk ssh vimCOPY target/app.jar/appCMD“java”,“-jar
14、”,“/app/app.jar”DEVNET-200013 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveDockerfile HurdlesReduce Image SizeFROM debianRUN apt-get update&apt-get y install openjdk-8-jdk ssh vimCOPY target/app
15、.jar/appCMD“java”,“-jar”,“/app/app.jar”DEVNET-200014 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveDockerfile HurdlesReduce Image SizeFROM debianRUN apt-get update&apt-get y install no-install-re
16、commends openjdk-8-jdk ssh vim&rm rf/var/lib/apt/lists/*COPY target/app.jar/appCMD“java”,“-jar”,“/app/app.jar”DEVNET-200015 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveDockerfile HurdlesOfficia
17、l ImagesFROM debianRUN apt-get update&apt-get y install no-install-recommends openjdk-8-jdk&rm rf/var/lib/apt/lists/*COPY target/app.jar/appCMD“java”,“-jar”,“/app/app.jar”DEVNET-200016 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All ri
18、ghts reserved.Cisco Public#CiscoLiveDockerfile HurdlesOfficial ImagesFROM debianRUN apt-get update&apt-get y install no-install-recommends openjdk-8-jdk&rm rf/var/lib/apt/lists/*FROM openjdk:8COPY target/app.jar/appCMD“java”,“-jar”,“/app/app.jar”DEVNET-200017 2023 Cisco and/or its affiliates.All rig
19、hts reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveDockerfile HurdlesBuilding with DockerFROM openjdk:8COPY target/app.jar/appCMD“java”,“-jar”,“/app/app.jar”DEVNET-200018 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#Cis
20、coLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveDockerfile HurdlesBuilding with DockerFROM openjdk:8FROM maven:3.6-jdk-8-alpineWORKDIR/appCOPY target/app.jar/appCOPY pom.xml.RUN mvn e B dependency:resolveCOPY src./srcRUN mvn e B packageCMD“java”,“-jar”,“/app/app.jar
21、”DEVNET-200019 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveDockerfile HurdlesMulti-Stage BuildsFROM maven:3.6-jdk-8-alpineWORKDIR/appCOPY pom.xml.RUN mvn e B dependency:resolveCOPY src./srcRUN
22、mvn e B packageCMD“java”,“-jar”,“/app/app.jar”DEVNET-200020 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveDockerfile HurdlesMulti-Stage BuildsFROM maven:3.6-jdk-8-alpine AS builderWORKDIR/appCOPY
23、 pom.xml.RUN mvn e B dependency:resolveCOPY src./srcRUN mvn e B packageCMD“java”,“-jar”,“/app/app.jar”FROM openjdk:8-jre-alpineCOPY-from=builder/app/target/app.jar/CMD“java”,“-jar”,“/app/app.jar”DEVNET-200021 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/
24、or its affiliates.All rights reserved.Cisco Public#CiscoLiveDockerfile HurdlesOptimized Multi-Stage DockerfileFROM maven:3.6-jdk-8-alpine AS builderWORKDIR/appCOPY pom.xml.RUN mvn e B dependency:resolveCOPY src./srcRUN mvn e B packageFROM openjdk:8-jre-alpineCOPY-from=builder/app/target/app.jar/CMD“
25、java”,“-jar”,“/app/app.jar”DEVNET-200022 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveApplication Images with DockerfilesImage LayersAppRuntime(e.g.JDK)OSCOPY target/app.jar/appRUN apt-get insta
26、ll openjdk-8FROM debianDEVNET-200023 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveHow many images are in your container registry?DEVNET-200024 2023 Cisco and/or its affiliates.All rights reserve
27、d.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveChallenges of Manual Dockerfile creationImages(and dev envs)change over timeReproducable,secure buildsHuman ErrorNon-reproducibleManual Security UpdatesDEVNET-200025Cloud Native Buildpacks 2023 Cisco
28、and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveWhat are Cloud Native Buildpacks?DEVNET-200027 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All
29、rights reserved.Cisco Public#CiscoLiveCloud Native Buildpacks areReusableReusableUse the same buildpack on many appsFastFastOnly re-builds and uploads layers when necessaryModularModularCombine buildpacks to create composite imagesSafeSafeApps meet security requirements w/o developer interventionDEV
30、NET-200028 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveCloud Native BuildpacksAn Open StandardPlatformLifecycleBuildpacksCNB SpecificationPlatform APIBuildpack APIpackpackkpackSalesforce Heroku
31、TektonGoogle CloudDEVNET-200029 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveComponents of Cloud Native BuildpacksBuildpackA set of executables that inspects your app source code and creates a p
32、lan to build and run your application.StackA stack is composed of two images that are intended to work together,the build image and the run image.BuilderA builder is an image that contains all the components necessary to execute a build.LifecycleThe lifecycle orchestrates buildpack execution,then as
33、sembles the resulting artifacts into a final app image.DEVNET-200030 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveCloud Native BuildpacksOverviewstackbuild imagerun imagebuild imagelifecyclebuil
34、dpack 3buildpack 2buildpack 1builder imagesourcerun imagebp2-provided layersbp1-provided layersapp imagepackbp3-provided layersApp layersDEVNET-200031 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLi
35、veLook whats createdApp image that hasa reproducible buildmetadata that can be inspectedlogical mapping of layers to componentsOS(run image)bp2 provided layersbp1 provided layersappDEVNET-200032 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affilia
36、tes.All rights reserved.Cisco Public#CiscoLiveLifecycleAnalyzeRestores files that buildpacks may use to optimize the build and export phases.DetectFinds an ordered group of buildpacks to use during the build phase.RestoreRestores layers from the cache.What is the Lifecycle?detectrestorebuildexportan
37、alyzeBuildTransforms application source code into runnable artifacts that can be packaged into a container.ExportCreates the final OCI image.DEVNET-200033Demo 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public
38、#CiscoLiveDEVNET-200042AdvancedCloud Native Buildpacks 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveRebaseOSbp2 provided layersbp1 provided layersappDEVNET-200044 2023 Cisco and/or its affiliate
39、s.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveRebaseCVE!New OSbp2 provided layersbp1 provided layersappDEVNET-200045 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.
40、All rights reserved.Cisco Public#CiscoLiveRebaseCVE!New OSABI CompatABI Compatbp2 provided layersbp1 provided layersappDEVNET-200046 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveRebaseOSOS$pack
41、rebase myimagebp2 provided layersbp1 provided layersappDEVNET-200047 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveSoftware Bill of Materials(SBOM)Advanced Cloud Native Buildpacks$pack inspect-im
42、age sample-nodejsInspecting image:sample-nodejsREMOTE:(not present)LOCAL:Stack:io.buildpacks.stacks.bionicBase Image:Reference:5d10637559ec14ba0c6795f10e975cb9d2896f138f9eb09570500cf052c0b00bTop Layer:sha256:3905f740ea0f0cbb7c10597d8f8abe5e50f092a1a3ee960915498811beec51c3Run Images:index.docker.io/p
43、aketobuildpacks/run:base-cnbgcr.io/paketo-buildpacks/run:base-cnbBuildpacks:ID VERSION HOMEPAGEpaketo-buildpacks/ca-certificates 3.1.0 https:/ 0.12.3 https:/ 0.9.0 https:/ https:/ 0.8.0 https:/ 0.9.0 https:/ https:/ SHELL COMMAND ARGSweb(default)bash npm startDEVNET-200048 2023 Cisco and/or its affi
44、liates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveSoftware Bill of Materials(SBOM)Advanced Cloud Native BuildpacksDEVNET-200049 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its
45、 affiliates.All rights reserved.Cisco Public#CiscoLiveCreating your own StackA stack is composed of two images that are intended to work together:1.The build image of a stack provides the base image from which the build environment is constructed.2.The run image of a stack provides the base image fr
46、om which application images are built.DEVNET-200050 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveCreating your own BuilderDEVNET-200051 2023 Cisco and/or its affiliates.All rights reserved.Cisco
47、 Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveCreating your own Builder$pack builder create my-builder:jammy-config./builder.tomlCreate Builder$pack build my-app-builder my-builder:jammyUse BuilderDEVNET-200052Builder Demo 2023 Cisco and/or its affiliat
48、es.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveDEVNET-200054 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLiveFill out your
49、session surveys!Attendees who fill out a minimum of four session surveys and the overall event survey will get Cisco Live-branded socks(while supplies last)!55DEVNET-2000These points help you get on the leaderboard and increase your chances of winning daily and grand prizesAttendees will also earn 1
50、00 points in the Cisco Live Challenge for every survey completed.2023 Cisco and/or its affiliates.All rights reserved.Cisco Public 2023 Cisco and/or its affiliates.All rights reserved.Cisco PublicContinue your educationVisit the Cisco Showcase for related demosBook your one-on-oneMeet the Engineer m
51、eetingAttend the interactive education with DevNet,Capture the Flag,and Walk-in LabsVisit the On-Demand Library for more sessions at www.CiscoL you#CiscoLiveThank you#CiscoLive 2023 Cisco and/or its affiliates.All rights reserved.Cisco Public#CiscoLive 2023 Cisco and/or its affiliates.All rights res
52、erved.Cisco Public#CiscoLive58Gamify your Cisco Live experience!Get points Get points for attending this session!for attending this session!Open the Cisco Events App.Click on Cisco Live Challenge in the side menu.Click on View Your Badges at the top.Click the+at the bottom of the screen and scan the QR code:How:123458 2023 Cisco and/or its affiliates.All rights reserved.Cisco PublicDEVNET-2000#CiscoLive#CiscoLive