Skip to content

Commit

Permalink
Merge pull request #124 from vvoland/rootless
Browse files Browse the repository at this point in the history
Add rootless support
  • Loading branch information
crazy-max authored Nov 14, 2024
2 parents e02739b + 343f867 commit 332d315
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 34 deletions.
46 changes: 15 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ jobs:
uses: ./
with:
version: ${{ env.DOCKER_VERSION }}
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v2

channel:
runs-on: ${{ matrix.os }}
Expand All @@ -85,10 +81,6 @@ jobs:
with:
version: v24.0.0-rc.4
channel: test
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v2

daemon-config:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -120,10 +112,6 @@ jobs:
"containerd-snapshotter": true
}
}
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v2
context:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -154,10 +142,6 @@ jobs:
name: Check context
run: |
docker context inspect foo
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v2
lima-start-args:
#runs-on: macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317
Expand Down Expand Up @@ -220,10 +204,6 @@ jobs:
name: Inspect
run: |
docker buildx imagetools inspect localhost:5000/name/app:latest --format '{{json .}}'
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v2
build-macos:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -270,10 +250,6 @@ jobs:
name: Inspect
run: |
docker buildx imagetools inspect localhost:5000/name/app:latest --format '{{json .}}'
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v2
build-windows:
runs-on: windows-latest
Expand All @@ -295,10 +271,6 @@ jobs:
name: Inspect
run: |
docker image inspect test
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v2
set-host:
runs-on: ubuntu-latest
Expand All @@ -315,7 +287,19 @@ jobs:
name: List contexts
run: |
docker context ls
rootless:
runs-on: ubuntu-latest
steps:
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v2
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker
uses: ./
with:
rootless: true
-
name: List contexts
run: |
docker context ls
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ The following inputs can be used as `step.with` keys
| `daemon-config` | String | | [Docker daemon JSON configuration](https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file) |
| `context` | String | `setup-docker-action` | Docker context name. |
| `set-host` | Bool | `false` | Set `DOCKER_HOST` environment variable to docker socket path. |
| `rootless` | Bool | `false` | Start daemon in rootless mode |

### outputs

Expand Down
34 changes: 34 additions & 0 deletions __tests__/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('getInputs', () => {
new Map<string, string>([
['version', 'v24.0.8'],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
Expand All @@ -28,6 +29,7 @@ describe('getInputs', () => {
},
context: '',
daemonConfig: '',
rootless: false,
setHost: false
} as context.Inputs
],
Expand All @@ -39,6 +41,7 @@ describe('getInputs', () => {
['context', 'foo'],
['daemon-config', `{"debug":true,"features":{"containerd-snapshotter":true}}`],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
Expand All @@ -48,13 +51,15 @@ describe('getInputs', () => {
},
context: 'foo',
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`,
rootless: false,
setHost: false
} as context.Inputs
],
[
2,
new Map<string, string>([
['set-host', 'true'],
['rootless', 'false'],
]),
{
source: {
Expand All @@ -64,6 +69,7 @@ describe('getInputs', () => {
},
context: '',
daemonConfig: '',
rootless: false,
setHost: true
} as context.Inputs
],
Expand All @@ -74,6 +80,7 @@ describe('getInputs', () => {
['context', 'foo'],
['daemon-config', `{"debug":true,"features":{"containerd-snapshotter":true}}`],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
Expand All @@ -82,6 +89,7 @@ describe('getInputs', () => {
},
context: 'foo',
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`,
rootless: false,
setHost: false
} as context.Inputs
],
Expand All @@ -90,6 +98,7 @@ describe('getInputs', () => {
new Map<string, string>([
['version', 'type=image'],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
Expand All @@ -98,6 +107,7 @@ describe('getInputs', () => {
},
context: '',
daemonConfig: '',
rootless: false,
setHost: false
} as context.Inputs
],
Expand All @@ -106,6 +116,7 @@ describe('getInputs', () => {
new Map<string, string>([
['version', 'type=archive'],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
Expand All @@ -116,13 +127,15 @@ describe('getInputs', () => {
setHost: false,
context: '',
daemonConfig: '',
rootless: false,
} as context.Inputs
],
[
6,
new Map<string, string>([
['version', 'version=v27.2.0,channel=test'],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
Expand All @@ -133,13 +146,15 @@ describe('getInputs', () => {
setHost: false,
context: '',
daemonConfig: '',
rootless: false,
} as context.Inputs
],
[
7,
new Map<string, string>([
['version', 'type=image,tag=27.2.1'],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
Expand All @@ -149,6 +164,25 @@ describe('getInputs', () => {
setHost: false,
context: '',
daemonConfig: '',
rootless: false,
} as context.Inputs
],
[
8,
new Map<string, string>([
['version', 'type=image,tag=27.2.1'],
['set-host', 'false'],
['rootless', 'true']
]),
{
source: {
type: 'image',
tag: '27.2.1',
},
setHost: false,
context: '',
daemonConfig: '',
rootless: true,
} as context.Inputs
],
])(
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ inputs:
description: 'Set DOCKER_HOST environment variable to docker socket path'
default: 'false'
required: false
rootless:
description: 'Enable Docker rootless mode'
default: 'false'
required: false

outputs:
sock:
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface Inputs {
daemonConfig?: string;
context: string;
setHost: boolean;
rootless: boolean;
}

export function getInputs(): Inputs {
Expand All @@ -21,7 +22,8 @@ export function getInputs(): Inputs {
source: source,
daemonConfig: core.getInput('daemon-config'),
context: core.getInput('context'),
setHost: core.getBooleanInput('set-host')
setHost: core.getBooleanInput('set-host'),
rootless: core.getBooleanInput('rootless')
};
}

Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ actionsToolkit.run(
const install = new Install({
runDir: runDir,
source: input.source,
rootless: input.rootless,
contextName: input.context || 'setup-docker-action',
daemonConfig: input.daemonConfig
});
Expand Down

0 comments on commit 332d315

Please sign in to comment.