Skip to content

Commit 319d450

Browse files
Add Podman build documentation
1 parent 5043212 commit 319d450

File tree

5 files changed

+165
-7
lines changed

5 files changed

+165
-7
lines changed

user/podman.md

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
---
2+
title: Use Podman in Builds
3+
layout: en
4+
---
5+
6+
Travis CI builds can run and build container images with Podman, and can also push images to container repositories or other remote storage. Podman provides a Docker-compatible command-line interface, making it a suitable alternative that doesn't require a daemon to run.
7+
8+
To use Podman add the following settings to your `.travis.yml`:
9+
10+
```yaml
11+
services:
12+
- podman
13+
```
14+
{: data-file=".travis.yml"}
15+
16+
Then you can add `- podman` commands to your build as shown in the following examples.
17+
18+
> We do not currently support use of Podman on macOS.
19+
20+
> For information on how to use Podman on Travis CI Enterprise, check out [Enabling Container Builds](/user/enterprise/build-images/#enabling-container-builds).
21+
22+
## Use a Container Image from a Repository
23+
24+
This example runs two container instances built from the same image:
25+
26+
- a web application
27+
- the application test suite
28+
29+
After specifying in the `.travis.yml` to use Podman (with `services: - podman`) and your language of choice, the `before_install` build step pulls a container image then runs it with appropriate parameters.
30+
31+
The full `.travis.yml` might look like this:
32+
33+
```yaml
34+
language: ruby
35+
36+
services:
37+
- podman
38+
39+
before_install:
40+
- podman pull docker.io/nginx:latest
41+
- podman run -d -p 127.0.0.1:80:8080 docker.io/nginx:latest
42+
- podman ps -a
43+
- podman run --rm docker.io/nginx:latest /bin/sh -c "nginx -v"
44+
45+
script:
46+
- bundle exec rake test
47+
```
48+
{: data-file=".travis.yml"}
49+
50+
## Build a Container Image from a Containerfile
51+
52+
Instead of downloading the container image from a registry, you can build it directly from a Containerfile (equivalent to a Dockerfile) in your repository.
53+
54+
To build the Containerfile in the current directory and give it a label, use the following command:
55+
56+
```bash
57+
podman build -t myusername/myapp .
58+
```
59+
60+
The full `.travis.yml` would look like this:
61+
62+
```yaml
63+
language: ruby
64+
65+
services:
66+
- podman
67+
68+
before_install:
69+
- podman build -t myusername/myapp .
70+
- podman run -d -p 127.0.0.1:80:8080 myusername/myapp /bin/sh -c "cd /app; ./start.sh;"
71+
- podman ps -a
72+
- podman run myusername/myapp /bin/sh -c "cd /app; ./run_tests.sh"
73+
74+
script:
75+
- bundle exec rake test
76+
```
77+
{: data-file=".travis.yml"}
78+
79+
## Push a Container Image to a Registry
80+
81+
To push an image to a container registry, one must first authenticate via `podman login`. The username and password used for login should be stored in the repository settings environment variables, which may be set up through the repository settings web page or locally via the Travis CLI, e.g.:
82+
83+
```bash
84+
travis env set REGISTRY_USERNAME myusername
85+
travis env set REGISTRY_PASSWORD secretsecret
86+
```
87+
88+
Be sure to [encrypt environment variables](/user/environment-variables/#encrypting-environment-variables) using the travis gem.
89+
90+
Within your `.travis.yml` prior to attempting a `podman push` or perhaps before `podman pull` of a private image, e.g.:
91+
92+
```bash
93+
echo "$REGISTRY_PASSWORD" | podman login -u "$REGISTRY_USERNAME" --password-stdin quay.io
94+
```
95+
96+
### Branch-Based Registry Pushes
97+
98+
To push a particular branch of your repository to a remote registry, use the custom deploy section of your `.travis.yml`:
99+
100+
```yaml
101+
deploy:
102+
provider: script
103+
script: bash container_push
104+
on:
105+
branch: master
106+
```
107+
{: data-file=".travis.yml"}
108+
109+
Where `container_push` is a script in your repository containing:
110+
111+
```bash
112+
#!/bin/bash
113+
echo "$REGISTRY_PASSWORD" | podman login -u "$REGISTRY_USERNAME" --password-stdin quay.io
114+
podman push myusername/myapp
115+
```
116+
{: data-file="container_push"}
117+
118+
### Private Registry Login
119+
120+
When pushing to a private registry, be sure to specify the hostname in the `podman login` command, e.g.:
121+
122+
```bash
123+
echo "$REGISTRY_PASSWORD" | podman login -u "$REGISTRY_USERNAME" --password-stdin registry.example.com
124+
```
125+
126+
## Use Podman Compose
127+
128+
The Podman Compose tool allows you to run multi-container applications. You can install it in your build environment by adding the following to your `.travis.yml`:
129+
130+
```yaml
131+
before_install:
132+
- pip install podman-compose
133+
```
134+
{: data-file=".travis.yml"}
135+
136+
## Install a specific Podman version
137+
138+
You can install a specific version of Podman by manually updating it in the `before_install` step of your `.travis.yml`:
139+
140+
```yaml
141+
before_install:
142+
- source /etc/os-release
143+
- echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
144+
- curl -L "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key" | sudo apt-key add -
145+
- sudo apt-get update
146+
- sudo apt-get -y install podman=<specific-version>
147+
```
148+
{: data-file=".travis.yml"}
149+
150+
> Check what version of Podman you're running with `podman --version`
151+
152+
## Examples
153+
154+
- [example/podman-web-app](https://github.com/example/podman-web-app/blob/master/.travis.yml) (A web application using Podman for container management)
155+
- [example/podman-backup](https://github.com/example/podman-backup/blob/master/.travis.yml) (A cron job that backs up databases running in Podman containers)

user/reference/bionic.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ All Ubuntu 18.04 builds include the following versions of Docker: version contro
4444
| **shfmt** | `3.8.0` |
4545
{: style="width: 30%" }
4646

47-
### Docker
47+
### Docker and Container Tools
4848

4949
| Package | Version |
5050
|:-------------------|:----------------------------------|
51-
| **Docker** | `24.0.2` (build cb74dfc) |
52-
| **docker-compose** | `v2.20.3` |
51+
| **Docker** | `24.0.2` (build cb74dfc) |
52+
| **docker-compose** | `v2.20.3` |
53+
| **Podman** | `3.4.2` |
5354
{: style="width: 30%" }
5455

5556
### Ruby Support

user/reference/focal.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ To use the IBM Advance Toolchain v14 compilers under `amd64` architecture in Foc
8383
- Python Interpreter Path: `/opt/python380-amd64/python3.8`
8484
- Build Python Command: `sudo sh python_interpreter.sh`
8585

86-
### Docker
86+
### Docker and Container Tools
8787

8888
* Docker `28.0.1` is installed.
8989
* docker-compose `v2.27.1` is also available.
90+
* Podman `3.4.2` is installed as an alternative container engine.
9091

9192
## Ruby support
9293

@@ -179,4 +180,3 @@ To use Android, specify `language: android` in your `.travis.yml` and refer to t
179180
## Other Ubuntu Linux Build Environments
180181

181182
For details on other Ubuntu Linux build environments available on Travis CI, please refer to the [Ubuntu Linux overview page](/user/reference/linux/).
182-
```

user/reference/jammy.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ For preinstalled language interpreters, a standard version manager like `rvm` is
4343
| shfmt | `3.8.0` |
4444
{: style="width: 30%" }
4545

46-
### Docker
46+
### Docker and Container Tools
4747

4848
* Docker `28.0.1` (build 068a01e) is installed.
4949
* docker-compose `v2.27.1` is also available.
50+
* Podman `3.4.4` is installed as an alternative container engine.
5051

5152
### Ruby Support
5253

@@ -138,4 +139,3 @@ To use Android, specify `language: android` in your `.travis.yml` and refer to t
138139
## Other Ubuntu Linux Build Environments
139140

140141
For details on other Ubuntu Linux build environments available on Travis CI, please refer to the [Ubuntu Linux overview page](/user/reference/linux/).
141-
```

user/reference/noble.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ For preinstalled language interpreters, a standard version manager like `rvm` is
4848

4949
* Docker `27.5.1` is installed.
5050
* docker-compose `2.32.4` is also available.
51+
* Podman `3.4.4` is installed as an alternative container engine.
52+
5153

5254
## Ruby Support
5355

0 commit comments

Comments
 (0)