Skip to content

Latest commit

 

History

History
179 lines (149 loc) · 9.84 KB

plan-build.md

File metadata and controls

179 lines (149 loc) · 9.84 KB
copyright lastupdated keywords subcollection
years
2021
2021-09-16
build for code engine, planning for code engine, source code building for code engine, source code repositories and code engine, image builds for code engine, container image builds for code engine, build strategy for code engine, build size for code engine, build, build run, source repository, image registry
codeengine

{:DomainName: data-hd-keyref="APPDomain"} {:DomainName: data-hd-keyref="DomainName"} {:android: data-hd-operatingsystem="android"} {:api: .ph data-hd-interface='api'} {:apikey: data-credential-placeholder='apikey'} {:app_key: data-hd-keyref="app_key"} {:app_name: data-hd-keyref="app_name"} {:app_secret: data-hd-keyref="app_secret"} {:app_url: data-hd-keyref="app_url"} {:audio: .audio} {:authenticated-content: .authenticated-content} {:beta: .beta} {:c#: .ph data-hd-programlang='c#'} {:c#: data-hd-programlang="c#"} {:cli: .ph data-hd-interface='cli'} {:codeblock: .codeblock} {:curl: #curl .ph data-hd-programlang='curl'} {:curl: .ph data-hd-programlang='curl'} {:deprecated: .deprecated} {:dotnet-standard: .ph data-hd-programlang='dotnet-standard'} {:download: .download} {:external: .external target="_blank"} {:external: target="_blank" .external} {:faq: data-hd-content-type='faq'} {:fuzzybunny: .ph data-hd-programlang='fuzzybunny'} {:generic: data-hd-operatingsystem="generic"} {:generic: data-hd-programlang="generic"} {:gif: data-image-type='gif'} {:go: .ph data-hd-programlang='go'} {:help: data-hd-content-type='help'} {:hide-dashboard: .hide-dashboard} {:hide-in-docs: .hide-in-docs} {:important: .important} {:ios: data-hd-operatingsystem="ios"} {:java: #java .ph data-hd-programlang='java'} {:java: .ph data-hd-programlang='java'} {:java: data-hd-programlang="java"} {:javascript: .ph data-hd-programlang='javascript'} {:javascript: data-hd-programlang="javascript"} {:middle: .ph data-hd-position='middle'} {:navgroup: .navgroup} {:new_window: target="_blank"} {:node: .ph data-hd-programlang='node'} {:note: .note} {:objectc: .ph data-hd-programlang='Objective C'} {:objectc: data-hd-programlang="objectc"} {:org_name: data-hd-keyref="org_name"} {:php: .ph data-hd-programlang='PHP'} {:php: data-hd-programlang="php"} {:pre: .pre} {:preview: .preview} {:python: .ph data-hd-programlang='python'} {:python: data-hd-programlang="python"} {:release-note: data-hd-content-type='release-note'} {:right: .ph data-hd-position='right'} {:route: data-hd-keyref="route"} {:row-headers: .row-headers} {:ruby: .ph data-hd-programlang='ruby'} {:ruby: data-hd-programlang="ruby"} {:runtime: architecture="runtime"} {:runtimeIcon: .runtimeIcon} {:runtimeIconList: .runtimeIconList} {:runtimeLink: .runtimeLink} {:runtimeTitle: .runtimeTitle} {:screen: .screen} {:script: data-hd-video='script'} {:service: architecture="service"} {:service_instance_name: data-hd-keyref="service_instance_name"} {:service_name: data-hd-keyref="service_name"} {:shortdesc: .shortdesc} {:space_name: data-hd-keyref="space_name"} {:step: data-tutorial-type='step'} {:step: data-tutorial-type='step'} {:subsection: outputclass="subsection"} {:support: data-reuse='support'} {:swift: #swift .ph data-hd-programlang='swift'} {:swift: .ph data-hd-programlang='swift'} {:swift: data-hd-programlang="swift"} {:table: .aria-labeledby="caption"} {:term: .term} {:terraform: .ph data-hd-interface='terraform'} {:tip: .tip} {:tooling-url: data-tooling-url-placeholder='tooling-url'} {:topicgroup: .topicgroup} {:troubleshoot: data-hd-content-type='troubleshoot'} {:tsCauses: .tsCauses} {:tsResolve: .tsResolve} {:tsSymptoms: .tsSymptoms} {:tutorial: data-hd-content-type='tutorial'} {:ui: .ph data-hd-interface='ui'} {:unity: .ph data-hd-programlang='unity'} {:url: data-credential-placeholder='url'} {:user_ID: data-hd-keyref="user_ID"} {:vbnet: .ph data-hd-programlang='vb.net'} {:video: .video}

Planning your build

{: #plan-build}

Before you start building images with {{site.data.keyword.codeenginefull}}, learn about the different options you have for your build. {: shortdesc}

A build, or image build, is a mechanism that you can use to create a container image from your source code. {{site.data.keyword.codeengineshort}} supports building from a Dockerfile and Cloud Native Buildpacks.

{{site.data.keyword.codeengineshort}} provides custom resource definition (CRD) methods. For more information, see {{site.data.keyword.codeengineshort}} API reference - Source -to-image CRD methods.

Prepare your source repository

{: #build-plan-repo}

To give {{site.data.keyword.codeengineshort}} access to your source code, you need to make it available in a Git repository, for example in GitHub{: external} or GitLab{: external}. If your source repository is not public, you must add access to {{site.data.keyword.codeengineshort}}.

Choose a build strategy

{: #build-strategy}

{{site.data.keyword.codeengineshort}} can build your container image by using one of following strategies:

Dockerfile

{: #build-dockerfile-strat}

Dockerfile{: external} build that uses the BuildKit{: external} tool. To use this strategy, add a Dockerfile to your source repository. This Dockerfile describes the steps that are needed to build a container image from your source repository. The Dockerfile might contain steps that copy static files from your sources into the container to be hosted by a web service, for example. It might compile source code that is written in the language of your choice and add the resulting binary to your container image. For more information about Dockerfile builds, see Writing a Dockerfile for {{site.data.keyword.codeengineshort}}.

When you pull an image from Docker Hub to use with apps or jobs in Code Engine, be aware of Docker rate limits{: external} for free plan (anonymous) users. You might experience pull limits if you receive a 429 error that indicates you reached your pull rate limit. To increase rate limits{: external}, you can upgrade your account to a Docker Pro or Team subscription. {: tip}

Cloud Native Buildpacks

{: #build-buildpack-strat}

Cloud Native Buildpack{: external} that uses Paketo{: external} to inspect your source repository and detect which runtime environment that your code is based on and how a container image is built from your sources. Buildpacks make assumptions about the directory structure of your source repositories. For more information about how to structure your source repository correctly, see the samples that are provided for your runtime.

Runtime Version Samples
Go 1.16.7 Go samples{: external}.
Java 11.0.12 Java samples{: external}.
Node.js 14.17.6 Node.js samples{: external}.
PHP 7.4.23 PHP samples{: external}.
Ruby 2.7.4 Ruby samples{: external}.
.NET Core 5.0.400 (.NET Core SDK),
5.0.9 (.NET Core Runtime)
.NET Core samples{: external}.
{: caption="Runtime sample files" caption-side="top"}

Determine the size of the build

{: #build-size}

{{site.data.keyword.codeengineshort}} classifies builds into small, medium, large, and xlarge size. The size of the build defines how CPU cores, memory, and disk space are assigned to the build. A smaller build is less expensive, but typically also slower due to the lower number of CPU cores. Also, the memory and disk requirements of your build might cause the build to fail with a smaller size.

Size Dockerfile Buildpacks
small
  • CPU 0.5
  • Memory 2 GB
  • Disk 2 GB
  • CPU 0.5
  • Memory 2 GB
  • Disk 2 GB
medium
  • CPU 1
  • Memory 4 GB
  • Disk 4 GB
  • CPU 1
  • Memory 4 GB
  • Disk 4 GB
large
  • CPU 2
  • Memory 8 GB
  • Disk 8 GB
  • CPU 2
  • Memory 8 GB
  • Disk 8 GB
xlarge
  • CPU 4
  • Memory 16 GB
  • Disk 16 GB
  • CPU 4
  • Memory 16 GB
  • Disk 16 GB
{: caption="Build size values." caption-side="top"}

If you are uncertain about which size to choose, consider starting with small or medium. If the build fails due to lack of memory or disk space, or is not fast enough, then switch to larger sizes. {: tip}

Choose your container image registry

{: #build-registry}

After your container image is built, store it in a container image repository. With {{site.data.keyword.codeengineshort}}, you can add access to your private container image registries.

Next steps for builds

{: #nextsteps-planbuild}

When your planning is complete, build your container image.