Skip to content

Commit 332d315

Browse files
authored
Merge pull request #124 from vvoland/rootless
Add rootless support
2 parents e02739b + 343f867 commit 332d315

File tree

8 files changed

+60
-34
lines changed

8 files changed

+60
-34
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ jobs:
5555
uses: ./
5656
with:
5757
version: ${{ env.DOCKER_VERSION }}
58-
-
59-
name: Dump context
60-
if: always()
61-
uses: crazy-max/ghaction-dump-context@v2
6258

6359
channel:
6460
runs-on: ${{ matrix.os }}
@@ -85,10 +81,6 @@ jobs:
8581
with:
8682
version: v24.0.0-rc.4
8783
channel: test
88-
-
89-
name: Dump context
90-
if: always()
91-
uses: crazy-max/ghaction-dump-context@v2
9284

9385
daemon-config:
9486
runs-on: ${{ matrix.os }}
@@ -120,10 +112,6 @@ jobs:
120112
"containerd-snapshotter": true
121113
}
122114
}
123-
-
124-
name: Dump context
125-
if: always()
126-
uses: crazy-max/ghaction-dump-context@v2
127115
128116
context:
129117
runs-on: ${{ matrix.os }}
@@ -154,10 +142,6 @@ jobs:
154142
name: Check context
155143
run: |
156144
docker context inspect foo
157-
-
158-
name: Dump context
159-
if: always()
160-
uses: crazy-max/ghaction-dump-context@v2
161145
162146
lima-start-args:
163147
#runs-on: macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317
@@ -220,10 +204,6 @@ jobs:
220204
name: Inspect
221205
run: |
222206
docker buildx imagetools inspect localhost:5000/name/app:latest --format '{{json .}}'
223-
-
224-
name: Dump context
225-
if: always()
226-
uses: crazy-max/ghaction-dump-context@v2
227207
228208
build-macos:
229209
runs-on: ${{ matrix.os }}
@@ -270,10 +250,6 @@ jobs:
270250
name: Inspect
271251
run: |
272252
docker buildx imagetools inspect localhost:5000/name/app:latest --format '{{json .}}'
273-
-
274-
name: Dump context
275-
if: always()
276-
uses: crazy-max/ghaction-dump-context@v2
277253
278254
build-windows:
279255
runs-on: windows-latest
@@ -295,10 +271,6 @@ jobs:
295271
name: Inspect
296272
run: |
297273
docker image inspect test
298-
-
299-
name: Dump context
300-
if: always()
301-
uses: crazy-max/ghaction-dump-context@v2
302274
303275
set-host:
304276
runs-on: ubuntu-latest
@@ -315,7 +287,19 @@ jobs:
315287
name: List contexts
316288
run: |
317289
docker context ls
290+
291+
rootless:
292+
runs-on: ubuntu-latest
293+
steps:
318294
-
319-
name: Dump context
320-
if: always()
321-
uses: crazy-max/ghaction-dump-context@v2
295+
name: Checkout
296+
uses: actions/checkout@v4
297+
-
298+
name: Set up Docker
299+
uses: ./
300+
with:
301+
rootless: true
302+
-
303+
name: List contexts
304+
run: |
305+
docker context ls

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ The following inputs can be used as `step.with` keys
135135
| `daemon-config` | String | | [Docker daemon JSON configuration](https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file) |
136136
| `context` | String | `setup-docker-action` | Docker context name. |
137137
| `set-host` | Bool | `false` | Set `DOCKER_HOST` environment variable to docker socket path. |
138+
| `rootless` | Bool | `false` | Start daemon in rootless mode |
138139

139140
### outputs
140141

__tests__/context.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ describe('getInputs', () => {
1919
new Map<string, string>([
2020
['version', 'v24.0.8'],
2121
['set-host', 'false'],
22+
['rootless', 'false'],
2223
]),
2324
{
2425
source: {
@@ -28,6 +29,7 @@ describe('getInputs', () => {
2829
},
2930
context: '',
3031
daemonConfig: '',
32+
rootless: false,
3133
setHost: false
3234
} as context.Inputs
3335
],
@@ -39,6 +41,7 @@ describe('getInputs', () => {
3941
['context', 'foo'],
4042
['daemon-config', `{"debug":true,"features":{"containerd-snapshotter":true}}`],
4143
['set-host', 'false'],
44+
['rootless', 'false'],
4245
]),
4346
{
4447
source: {
@@ -48,13 +51,15 @@ describe('getInputs', () => {
4851
},
4952
context: 'foo',
5053
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`,
54+
rootless: false,
5155
setHost: false
5256
} as context.Inputs
5357
],
5458
[
5559
2,
5660
new Map<string, string>([
5761
['set-host', 'true'],
62+
['rootless', 'false'],
5863
]),
5964
{
6065
source: {
@@ -64,6 +69,7 @@ describe('getInputs', () => {
6469
},
6570
context: '',
6671
daemonConfig: '',
72+
rootless: false,
6773
setHost: true
6874
} as context.Inputs
6975
],
@@ -74,6 +80,7 @@ describe('getInputs', () => {
7480
['context', 'foo'],
7581
['daemon-config', `{"debug":true,"features":{"containerd-snapshotter":true}}`],
7682
['set-host', 'false'],
83+
['rootless', 'false'],
7784
]),
7885
{
7986
source: {
@@ -82,6 +89,7 @@ describe('getInputs', () => {
8289
},
8390
context: 'foo',
8491
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`,
92+
rootless: false,
8593
setHost: false
8694
} as context.Inputs
8795
],
@@ -90,6 +98,7 @@ describe('getInputs', () => {
9098
new Map<string, string>([
9199
['version', 'type=image'],
92100
['set-host', 'false'],
101+
['rootless', 'false'],
93102
]),
94103
{
95104
source: {
@@ -98,6 +107,7 @@ describe('getInputs', () => {
98107
},
99108
context: '',
100109
daemonConfig: '',
110+
rootless: false,
101111
setHost: false
102112
} as context.Inputs
103113
],
@@ -106,6 +116,7 @@ describe('getInputs', () => {
106116
new Map<string, string>([
107117
['version', 'type=archive'],
108118
['set-host', 'false'],
119+
['rootless', 'false'],
109120
]),
110121
{
111122
source: {
@@ -116,13 +127,15 @@ describe('getInputs', () => {
116127
setHost: false,
117128
context: '',
118129
daemonConfig: '',
130+
rootless: false,
119131
} as context.Inputs
120132
],
121133
[
122134
6,
123135
new Map<string, string>([
124136
['version', 'version=v27.2.0,channel=test'],
125137
['set-host', 'false'],
138+
['rootless', 'false'],
126139
]),
127140
{
128141
source: {
@@ -133,13 +146,15 @@ describe('getInputs', () => {
133146
setHost: false,
134147
context: '',
135148
daemonConfig: '',
149+
rootless: false,
136150
} as context.Inputs
137151
],
138152
[
139153
7,
140154
new Map<string, string>([
141155
['version', 'type=image,tag=27.2.1'],
142156
['set-host', 'false'],
157+
['rootless', 'false'],
143158
]),
144159
{
145160
source: {
@@ -149,6 +164,25 @@ describe('getInputs', () => {
149164
setHost: false,
150165
context: '',
151166
daemonConfig: '',
167+
rootless: false,
168+
} as context.Inputs
169+
],
170+
[
171+
8,
172+
new Map<string, string>([
173+
['version', 'type=image,tag=27.2.1'],
174+
['set-host', 'false'],
175+
['rootless', 'true']
176+
]),
177+
{
178+
source: {
179+
type: 'image',
180+
tag: '27.2.1',
181+
},
182+
setHost: false,
183+
context: '',
184+
daemonConfig: '',
185+
rootless: true,
152186
} as context.Inputs
153187
],
154188
])(

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ inputs:
2424
description: 'Set DOCKER_HOST environment variable to docker socket path'
2525
default: 'false'
2626
required: false
27+
rootless:
28+
description: 'Enable Docker rootless mode'
29+
default: 'false'
30+
required: false
2731

2832
outputs:
2933
sock:

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/context.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface Inputs {
77
daemonConfig?: string;
88
context: string;
99
setHost: boolean;
10+
rootless: boolean;
1011
}
1112

1213
export function getInputs(): Inputs {
@@ -21,7 +22,8 @@ export function getInputs(): Inputs {
2122
source: source,
2223
daemonConfig: core.getInput('daemon-config'),
2324
context: core.getInput('context'),
24-
setHost: core.getBooleanInput('set-host')
25+
setHost: core.getBooleanInput('set-host'),
26+
rootless: core.getBooleanInput('rootless')
2527
};
2628
}
2729

src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ actionsToolkit.run(
2222
const install = new Install({
2323
runDir: runDir,
2424
source: input.source,
25+
rootless: input.rootless,
2526
contextName: input.context || 'setup-docker-action',
2627
daemonConfig: input.daemonConfig
2728
});

0 commit comments

Comments
 (0)