-
Notifications
You must be signed in to change notification settings - Fork 16
Build Examples #181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Build Examples #181
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
134c7e5
Add inject example
shanejbrown 1e11e96
Add platform and platforms example configs
shanejbrown 2281a44
Update README to point to examples directory
shanejbrown 8574cf1
Add examples/run/services configs
shanejbrown 2baf3af
Add run-buildrunner.sh
shanejbrown 17a4e71
Update inject example
shanejbrown 4fac782
Add no-cache example
shanejbrown 6d987f4
Add buildargs and import examples.
shanejbrown 1fd7392
Update run-buildrunner.sh
shanejbrown 8edde9b
At *.tar to .gitignore
shanejbrown a271bed
Update readme and tests for example files
shanejbrown File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,5 +3,5 @@ steps: | |
| simple-build-step: | ||
| build: | ||
| dockerfile: | | ||
| FROM busybox:latest | ||
| FROM alpine:latest | ||
| RUN echo Hello World | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # This example demonstrates how to use the buildargs field in the build step. | ||
| # The buildargs field allows you to pass build-time variables to the Dockerfile. | ||
| steps: | ||
| buildargs-step: | ||
| build: | ||
| buildargs: | ||
| MY_VERSION: 2.0 | ||
| dockerfile: | | ||
| FROM alpine:latest | ||
| ARG MY_VERSION | ||
| LABEL version=$MY_VERSION | ||
|
|
||
| # To view the label in the built image do the following: | ||
| # 1. Uncomment the following 'push:' line | ||
| # 2. Run 'PYTHONPATH=. ./bin/buildrunner -f examples/build/buildargs/buildrunner.yaml' | ||
| # 3. Run 'docker image inspect my-images/buildargs-image:latest' to see the label. | ||
| # | ||
| # push: my-images/buildargs-image:latest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # Description: This example demonstrates how to use the no-cache option in the build step. | ||
| steps: | ||
| cache-build-step: | ||
| build: | ||
| no-cache: false | ||
| dockerfile: | | ||
| FROM alpine:latest | ||
| RUN apk update | ||
| RUN echo Hello World | ||
| no-cache-build-step: | ||
| build: | ||
| no-cache: true | ||
| dockerfile: | | ||
| FROM alpine:latest | ||
| RUN apk update | ||
| RUN echo Hello World |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # This example demonstrates how to import a tarball image in the build step. | ||
| # This requires the tarball image to be present in the same directory where buildrunnner is executed. | ||
| # Before running this example, make sure to create a tarball image using the following command: | ||
| # docker save alpine:latest -o alpine.tar | ||
| # | ||
| # WARNING: Do not commit the tarball image to the repository. | ||
| # | ||
| steps: | ||
| import-step: | ||
| build: | ||
| import: alpine.tar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # This example demonstrates how to use the inject field to inject a file into the build context. | ||
| # See buildrunner documentation for more information. | ||
| steps: | ||
| build-step-with-inject: | ||
| build: | ||
| inject: | ||
| # Step 1: Inject a file into the build context | ||
| # The file /injectfile.txt will be injected into the build context | ||
| examples/build/inject/injectfile.txt: /injectfile.txt | ||
| dockerfile: | | ||
| FROM alpine | ||
| # Step 2: Copy the injected file into the image or use it in some other way in the build process | ||
| COPY /injectfile.txt /tmp/ | ||
| RUN cat /tmp/injectfile.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| This is a sample text file that can be injected into the build context |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Contains an example of building a single-platform image. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Example of a buildrunner.yaml file that specifies a single platform build step. | ||
| # The 'platform' field is optional and can be used to specify the platform for the build step. | ||
| # If the 'platform' field is not specified, the default platform is native platform of the machine running buildrunner. | ||
| steps: | ||
| single-platform-build-step: | ||
| build: | ||
| dockerfile: | | ||
| FROM alpine:latest | ||
| RUN echo Hello World | ||
| platform: linux/amd64 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Contains an example of building a multi-platform image. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Example of a buildrunner.yaml file that specifies a multi-platform build step. | ||
| # The 'platforms' field is optional and can be used to specify the platforms for the build step. | ||
| # If the 'platforms' field is not specified, by default it will build a single platform, using the native platform of the machine running buildrunner. | ||
| steps: | ||
| multi-platform-build-step: | ||
| build: | ||
| dockerfile: | | ||
| FROM alpine:latest | ||
| LABEL custom_label="Buildrunner example label" | ||
| platforms: | ||
| - linux/amd64 | ||
| - linux/arm64 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,5 @@ | |
| steps: | ||
| simple-run-step: | ||
| run: | ||
| image: busybox:latest | ||
| image: alpine:latest | ||
| cmd: echo Hello World | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| FROM ubuntu | ||
|
|
||
| RUN apt-get update \ | ||
| && apt-get upgrade -y \ | ||
| && apt-get install -y inetutils-ping bash vim |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # This example demonstrates how to run multiple services in a single step. | ||
| # The services are defined in the services section of the run step. | ||
| # Note: Change cmd to tail -f /dev/null to keep the services running for debugging. | ||
| steps: | ||
| my-build-step: | ||
| build: | ||
| path: examples/run/services | ||
| commit: | ||
| repository: myimages/image1 | ||
| tags: [ 'latest' ] | ||
| my-services-step: | ||
| run: | ||
| image: myimages/image1:latest | ||
| cmd: echo "Hello, World!" && sleep 1 && echo "Goodbye, World!" | ||
| services: | ||
| stats1: | ||
| build: | ||
| path: examples/run/services | ||
| cmd: echo "Hello, World!" && sleep 1 && echo "Goodbye, World!" | ||
| stats2: | ||
| build: | ||
| path: examples/run/services | ||
| cmd: echo "Hello, World!" && sleep 1 && echo "Goodbye, World!" | ||
| stats3: | ||
| build: | ||
| path: examples/run/services | ||
| cmd: echo "Hello, World!" && sleep 1 && echo "Goodbye, World!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Standalone file with buildrunner configuration using services. | ||
| # The services are defined in the services section of the run step. | ||
| # Note: Change cmd to tail -f /dev/null to keep the services running for debugging. | ||
| steps: | ||
| my-build-step: | ||
| build: | ||
| dockerfile: | | ||
| FROM ubuntu | ||
| RUN apt-get update \ | ||
| && apt-get upgrade -y \ | ||
| && apt-get install -y inetutils-ping bash vim | ||
| commit: | ||
| repository: myimages/image1 | ||
| tags: [ 'latest' ] | ||
| my-services-step: | ||
| run: | ||
| image: myimages/image1:latest | ||
| cmd: echo "Hello, World!" && sleep 1 && echo "Goodbye, World!" | ||
| services: | ||
| stats1: | ||
| build: | ||
| dockerfile: | | ||
| FROM ubuntu | ||
| RUN apt-get update \ | ||
| && apt-get upgrade -y \ | ||
| && apt-get install -y inetutils-ping bash vim | ||
| cmd: echo "Hello, World!" && sleep 1 && echo "Goodbye, World!" | ||
| stats2: | ||
| build: | ||
| dockerfile: | | ||
| FROM ubuntu | ||
| RUN apt-get update \ | ||
| && apt-get upgrade -y \ | ||
| && apt-get install -y inetutils-ping bash vim | ||
| cmd: echo "Hello, World!" && sleep 1 && echo "Goodbye, World!" | ||
| stats3: | ||
| build: | ||
| dockerfile: | | ||
| FROM ubuntu | ||
| RUN apt-get update \ | ||
| && apt-get upgrade -y \ | ||
| && apt-get install -y inetutils-ping bash vim | ||
| cmd: echo "Hello, World!" && sleep 1 && echo "Goodbye, World!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This script will run the local buildrunner code from the root of the project | ||
| # | ||
| # To get help, run the following command: | ||
| # ./run-buildrunner.sh --help | ||
| # | ||
| # To run the buildrunner with a specific configuration file, run the following command: | ||
| # ./run-buildrunner.sh -f examples/build/basic/buildrunner.yaml | ||
| PYTHONPATH=. ./bin/buildrunner --cleanup-images "$@" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I should have done this a long time ago.