Skip to content

Commit 6692200

Browse files
committed
feat: use native podman build for linux
### What does this PR do? * Switches to using native podman building for Linux rather than using podman machine * Tested against using a manifest as well as a normal image. * Uses CLI commands the equivalant of doing `sudo podman run`. PD does not support running / viewing / using sudo root connections. So we use the CLI instead * Uses CLI commands for saving the image / importing as well. The reasoning is that importing requires `sudo` / privileged and retrieving via image ID does not work for saving via the API. ### Screenshot / video of UI <!-- If this PR is changing UI, please include screenshots or screencasts showing the difference --> ### What issues does this PR fix or reference? <!-- Include any related issues from Podman Desktop repository (or from another issue tracker). --> Closes #623 ### How to test this PR? <!-- Please explain steps to reproduce --> 1. Try on Linux (Fedora 40 or above) 2. Go to build and it should ask for credentials after a few moments of building 3. Successful image build Signed-off-by: Charlie Drage <[email protected]>
1 parent f344b5e commit 6692200

16 files changed

+290
-109
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ The list above is what is supported by the underlying `bootc-image-builder` tech
116116

117117
## Requirements
118118

119-
### Requirement 1. Software and hardware requirements
119+
### Prerequisites: Software and hardware requirements
120120

121121
**OS:**
122122

@@ -126,7 +126,9 @@ Compatible on Windows, macOS & Linux
126126
* [Podman Desktop 1.10.0+](https://github.com/containers/podman-desktop)
127127
* [Podman 5.0.1+](https://github.com/containers/podman)
128128

129-
### Requirement 2. Rootful mode on Podman Machine
129+
### Podman Machine (macOS / Windows)
130+
131+
Podman Machine is required for macOS and Windows in order to run Podman as well as utilize filesystem privileges to build a disk image.
130132

131133
Podman Machine requirements:
132134
* **Rootful mode enabled**
@@ -144,14 +146,14 @@ Or set when initially creating a Podman Machine via Podman Desktop:
144146

145147
![rootful setup](https://raw.githubusercontent.com/containers/podman-desktop-extension-bootc/main/docs/img/rootful_setup.png)
146148

147-
**Linux users:**
149+
### Escalated Privileges (Linux)
148150

149-
On Linux, you are unable to create a Podman Machine through the GUI of Podman Desktop, to create a rootful Podman Machine you can run the following commands:
151+
During the build process, **you will be asked to enter your credentials** so that the bootc extension may run a `sudo podman run` underlying CLI command.
152+
153+
Podman Desktop is ran as the logged-in user. However, bootc-image-builder requires escalated / sudo privileges to run a rootful container.
154+
155+
You can find more information about what specific commands are being ran from the console logs of Podman Desktop.
150156

151-
```sh
152-
podman machine init --memory 6144 --rootful
153-
podman machine start
154-
```
155157

156158
## Installation
157159

packages/backend/src/api-impl.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { History } from './history';
2525
import * as containerUtils from './container-utils';
2626
import { Messages } from '/@shared/src/messages/Messages';
2727
import { telemetryLogger } from './extension';
28-
import { checkPrereqs } from './machine-utils';
28+
import { checkPrereqs, isLinux } from './machine-utils';
2929

3030
export class BootcApiImpl implements BootcApi {
3131
private history: History;
@@ -240,6 +240,10 @@ export class BootcApiImpl implements BootcApi {
240240
telemetryLogger.logError(eventName, data);
241241
}
242242

243+
async isLinux(): Promise<boolean> {
244+
return isLinux();
245+
}
246+
243247
// The API does not allow callbacks through the RPC, so instead
244248
// we send "notify" messages to the frontend to trigger a refresh
245249
// this method is internal and meant to be used by the API implementation

packages/backend/src/build-disk-image.spec.ts

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import os from 'node:os';
2121
import {
2222
buildExists,
2323
createBuilderImageOptions,
24-
createPodmanRunCommand,
24+
createPodmanCLIRunCommand,
2525
getBuilder,
2626
getUnusedName,
2727
} from './build-disk-image';
@@ -279,7 +279,7 @@ test('check uses Centos builder', async () => {
279279
expect(builder).toEqual(bootcImageBuilderCentos);
280280
});
281281

282-
test('create podman run command', async () => {
282+
test('create podman run CLI command', async () => {
283283
const name = 'test123-bootc-image-builder';
284284
const build = {
285285
image: 'test-image',
@@ -290,25 +290,35 @@ test('create podman run command', async () => {
290290
} as BootcBuildInfo;
291291

292292
const options = createBuilderImageOptions(name, build);
293-
const command = createPodmanRunCommand(options);
294-
295-
const expectedCommand = `podman run \\
296-
--name test123-bootc-image-builder \\
297-
--tty \\
298-
--privileged \\
299-
--security-opt label=type:unconfined_t \\
300-
-v /Users/cdrage/bootc/qemutest4:/output/ \\
301-
-v /var/lib/containers/storage:/var/lib/containers/storage \\
302-
--label bootc.image.builder=true \\
303-
${bootcImageBuilderCentos} \\
304-
test-image:latest \\
305-
--output \\
306-
/output/ \\
307-
--local \\
308-
--type \\
309-
raw \\
310-
--target-arch \\
311-
amd64`;
293+
const command = createPodmanCLIRunCommand(options);
294+
295+
// Expect an array of the above
296+
const expectedCommand = [
297+
'podman',
298+
'run',
299+
'--rm',
300+
'--name',
301+
'test123-bootc-image-builder',
302+
'--tty',
303+
'--privileged',
304+
'--security-opt',
305+
'label=type:unconfined_t',
306+
'-v',
307+
'/Users/cdrage/bootc/qemutest4:/output/',
308+
'-v',
309+
'/var/lib/containers/storage:/var/lib/containers/storage',
310+
'--label',
311+
'bootc.image.builder=true',
312+
'quay.io/centos-bootc/bootc-image-builder:latest-1720185748',
313+
'test-image:latest',
314+
'--output',
315+
'/output/',
316+
'--local',
317+
'--type',
318+
'raw',
319+
'--target-arch',
320+
'amd64',
321+
];
312322

313323
expect(command).toEqual(expectedCommand);
314324
});

0 commit comments

Comments
 (0)