Skip to content

Commit dfef5e1

Browse files
Matt PryorMoteHue
authored andcommitted
Add support for using podman + skopeo with Tilt (azimuth-cloud#194)
* Add support for using podman with Tilt * Add docs for using podman + skopeo
1 parent 564b5a8 commit dfef5e1

File tree

3 files changed

+66
-30
lines changed

3 files changed

+66
-30
lines changed

Tiltfile

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ if not os.path.exists(SETTINGS_FILE):
3434
# Load the settings
3535
settings = deep_merge(
3636
{
37+
# The engine that will be used to build container images for your changes
38+
# Supported options are docker, podman
39+
"build_engine": "docker",
40+
# The engine that will be used to mirror container images when required
41+
# Supported options are skopeo (recommended), docker, podman
42+
# Defaults to the build engine
43+
# "mirror_engine": "skopeo",
3744
# The components that will be managed by Tilt, if locally available
3845
# By default, we search for local checkouts as siblings of this checkout
3946
"components": {
@@ -101,27 +108,23 @@ def build_image(name, context, build_args = None):
101108
"""
102109
Defines an image build and returns the image name.
103110
"""
111+
build_engine = settings["build_engine"]
112+
if build_engine not in ["docker", "podman"]:
113+
fail("unknown build engine - %s" % build_engine)
104114
image = image_name(name)
105-
# The Azimuth CaaS operator relies on the .git folder to be in the Docker build context
106-
# This is because it uses pbr for versioning
107-
# Unfortunately, Tilt's docker_build function _always_ ignores the .git directory :-(
115+
# Some of the Azimuth components rely on the .git folder to be in the build context (pbr)
116+
# Unfortunately, Tilt's {docker,podman}_build functions _always_ ignores the .git directory
108117
# So we use a custom build command
109-
build_command = [
110-
"docker",
111-
"build",
112-
"-t",
113-
"$EXPECTED_REF",
114-
"--platform",
115-
"linux/amd64",
116-
context,
117-
]
118-
if build_args:
119-
for arg_name, arg_value in build_args.items():
120-
build_command.extend([
121-
"--build-arg",
122-
"'%s=%s'" % (arg_name, arg_value),
123-
])
124-
custom_build(image, " ".join(build_command), [context])
118+
build_args = " ".join([
119+
item
120+
for arg_name, arg_value in (build_args or {}).items()
121+
for item in ["--build-arg", "'%s=%s'" % (arg_name, arg_value)]
122+
])
123+
build_command = (
124+
"%s build -t $EXPECTED_REF --platform linux/amd64 %s %s && " % (build_engine, build_args, context) +
125+
"%s push $EXPECTED_REF" % build_engine
126+
)
127+
custom_build(image, build_command, [context], skips_local_docker = True)
125128
return image
126129

127130

@@ -130,14 +133,18 @@ def mirror_image(name, source_image):
130133
Defines a mirrored image and returns the image name.
131134
"""
132135
image = image_name(name)
133-
custom_build(
134-
image,
135-
(
136-
"docker pull --platform linux/amd64 {source_image} && " +
137-
"docker tag {source_image} $EXPECTED_REF"
138-
).format(source_image = source_image),
139-
[]
140-
)
136+
mirror_engine = settings.get("mirror_engine") or settings["build_engine"]
137+
if mirror_engine in ["docker", "podman"]:
138+
mirror_command = (
139+
"%s pull --platform linux/amd64 %s && " % (mirror_engine, source_image) +
140+
"%s tag %s $EXPECTED_REF && " % (mirror_engine, source_image) +
141+
"%s push $EXPECTED_REF" % mirror_engine
142+
)
143+
elif mirror_engine == "skopeo":
144+
mirror_command = "skopeo copy --all docker://%s docker://$EXPECTED_REF" % source_image
145+
else:
146+
fail("unrecognised mirror engine - %s" % mirror_engine)
147+
custom_build(image, mirror_command, [], skips_local_docker = True)
141148
return image
142149

143150

docs/configuration/04-target-cloud/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ First, the Keystone configuration of the target cloud must be modified to add Az
6363
[trusted dashboard](https://docs.openstack.org/keystone/latest/admin/federation/configure_federation.html#add-a-trusted-dashboard-websso),
6464
otherwise it will be unable to retrieve a token via the federated flow. When configuring Azimuth as a
6565
trusted dashboard, you must specify the URL that will receive token data, where the portal domain
66-
depends on the [ingress configuration](./06-ingress.md):
66+
depends on the [ingress configuration](../06-ingress.md):
6767

6868
```ini title="Keystone configuration"
6969
[federation]

docs/developing/index.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,25 @@ In order to use Tilt to develop Azimuth, the following tools must be available o
108108
development machine (in addition to those required to install Azimuth itself):
109109

110110
* The [Tilt CLI](https://docs.tilt.dev/install.html)
111-
* A `docker` command, e.g. [Docker Desktop](https://docs.docker.com/desktop/)
111+
* A `docker` or `podman` command,
112+
e.g. [Docker Desktop](https://docs.docker.com/desktop/) or [Podman Desktop](https://podman-desktop.io/)
112113
* The [kubectl command](https://kubernetes.io/docs/tasks/tools/#kubectl)
113114
* The [Helm CLI](https://helm.sh/docs/intro/install/)
115+
* The [skopeo CLI](https://github.com/containers/skopeo) (optional)
114116

115117
For developing the Azimuth UI, the following are also required:
116118

117119
* [node.js](https://nodejs.org)
118120
* The [Yarn Classic](https://classic.yarnpkg.com/lang/en/docs/install/) package manager
119121

120-
### Configuring a container registry
122+
### Tilt settings
121123

122124
Azimuth's Tilt configuration looks for a file called `tilt-settings.yaml` that defines settings
123125
for the development environment. This file is specific to you and should not be added to version
124126
control (it is specified in `.gitignore`).
125127

128+
#### Configuring a container registry
129+
126130
In order to get the code under development into your running Azimuth instance, Tilt must have
127131
access to a container registry that is accessible to both your development machine and the
128132
Azimuth instance. In response to code changes, Tilt will automatically build and push images
@@ -150,6 +154,31 @@ image_prefix: ghcr.io/jbloggs
150154
your Azimuth instance can use them. Until you do this, you will see image pull errors in
151155
the Tilt interface.
152156
157+
#### Using Podman for builds
158+
159+
In situations where using Docker is not viable, e.g. due to licensing constraints, Azimuth's
160+
Tilt configuration also supports using [Podman](https://podman.io/) to build and push container
161+
images.
162+
163+
To configure Tilt to use `podman` to build container images, use the following setting:
164+
165+
```yaml title="tilt-settings.yaml"
166+
build_engine: podman
167+
```
168+
169+
#### Using skopeo to mirror images
170+
171+
Some Azimuth components require images to be mirrored. By default, Azimuth's Tilt configuration
172+
uses the configured build engine for this by pulling, re-tagging and pushing the specified image.
173+
174+
[skopeo](https://github.com/containers/skopeo) is a tool that is built for performing operations
175+
on container images, such as efficiently copying an image from one repository to another, and
176+
Azimuth's Tilt configuration supports using this to mirror images:
177+
178+
```yaml title="tilt-settings.yaml"
179+
mirror_engine: skopeo
180+
```
181+
153182
### Using the Tilt environment
154183

155184
Tilt will look for checkouts of Azimuth components as siblings of your Azimuth configuration

0 commit comments

Comments
 (0)