Skip to content

Commit ffaa67e

Browse files
authored
Merge pull request #181 from shanejbrown/examples-build
Build Examples
2 parents 6237bfb + a271bed commit ffaa67e

File tree

19 files changed

+195
-7
lines changed

19 files changed

+195
-7
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ buildrunner/version.py
2020

2121
buildrunner.results
2222
curator.results
23+
24+
# Ignore all .tar files
25+
# Manually running of some example files may create local .tar files
26+
*.tar

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ See `docs/common-issues <docs/common-issues.rst>`_.
11311131
Example Configurations
11321132
======================
11331133

1134-
See `examples <examples/README.rst>`_.
1134+
See `examples <examples/>`_.
11351135

11361136
Contributing
11371137
============

examples/README.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ To run Buildrunner using an example configuration file, follow these steps from
1414
2. **Execute Buildrunner with a specified configuration file:**
1515
.. code-block:: sh
1616
17-
PYTHONPATH=. ./bin/buildrunner -f examples/<path-to-config-file>
17+
./run-buildrunner.sh -f examples/<path-to-config-file>
1818
1919
*Example:*
2020

2121
.. code-block:: sh
2222
23-
PYTHONPATH=. ./bin/buildrunner -f examples/build/basic/buildrunner.yaml
23+
./run-buildrunner.sh examples/build/basic/buildrunner.yaml
2424
2525
Adding a New Example Configuration File
2626
=======================================
@@ -39,4 +39,9 @@ To contribute a new example configuration file, adhere to the following guidelin
3939
- If necessary, include a ``README.rst`` file in the same directory as the configuration file to provide additional details or instructions.
4040
- Any supporting files required for the configuration should be placed alongside the configuration file.
4141

42-
Following these best practices ensures consistency, maintainability, and ease of use for all contributors and users.
42+
Following these best practices ensures consistency, maintainability, and ease of use for all contributors and users.
43+
44+
Excluding Example Configuration Files from Unit Tests
45+
=====================================================
46+
47+
To exclude an example configuration file from unit tests, add the file path to the ``excluded_example_files`` list in ``tests/test_buildrunner_files.py``.

examples/build/basic/buildrunner.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ steps:
33
simple-build-step:
44
build:
55
dockerfile: |
6-
FROM busybox:latest
6+
FROM alpine:latest
77
RUN echo Hello World
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This example demonstrates how to use the buildargs field in the build step.
2+
# The buildargs field allows you to pass build-time variables to the Dockerfile.
3+
steps:
4+
buildargs-step:
5+
build:
6+
buildargs:
7+
MY_VERSION: 2.0
8+
dockerfile: |
9+
FROM alpine:latest
10+
ARG MY_VERSION
11+
LABEL version=$MY_VERSION
12+
13+
# To view the label in the built image do the following:
14+
# 1. Uncomment the following 'push:' line
15+
# 2. Run 'PYTHONPATH=. ./bin/buildrunner -f examples/build/buildargs/buildrunner.yaml'
16+
# 3. Run 'docker image inspect my-images/buildargs-image:latest' to see the label.
17+
#
18+
# push: my-images/buildargs-image:latest
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Description: This example demonstrates how to use the no-cache option in the build step.
2+
steps:
3+
cache-build-step:
4+
build:
5+
no-cache: false
6+
dockerfile: |
7+
FROM alpine:latest
8+
RUN apk update
9+
RUN echo Hello World
10+
no-cache-build-step:
11+
build:
12+
no-cache: true
13+
dockerfile: |
14+
FROM alpine:latest
15+
RUN apk update
16+
RUN echo Hello World
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This example demonstrates how to import a tarball image in the build step.
2+
# This requires the tarball image to be present in the same directory where buildrunnner is executed.
3+
# Before running this example, make sure to create a tarball image using the following command:
4+
# docker save alpine:latest -o alpine.tar
5+
#
6+
# WARNING: Do not commit the tarball image to the repository.
7+
#
8+
steps:
9+
import-step:
10+
build:
11+
import: alpine.tar
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This example demonstrates how to use the inject field to inject a file into the build context.
2+
# See buildrunner documentation for more information.
3+
steps:
4+
build-step-with-inject:
5+
build:
6+
inject:
7+
# Step 1: Inject a file into the build context
8+
# The file /injectfile.txt will be injected into the build context
9+
examples/build/inject/injectfile.txt: /injectfile.txt
10+
dockerfile: |
11+
FROM alpine
12+
# Step 2: Copy the injected file into the image or use it in some other way in the build process
13+
COPY /injectfile.txt /tmp/
14+
RUN cat /tmp/injectfile.txt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a sample text file that can be injected into the build context

examples/build/platform/README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Contains an example of building a single-platform image.

0 commit comments

Comments
 (0)