Compare commits

..

No commits in common. "master" and "v1" have entirely different histories.
master ... v1

39 changed files with 4229 additions and 11951 deletions

View File

@ -1,12 +1,2 @@
/coverage
# Dependency directories
node_modules/
jspm_packages/
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
/node_modules

View File

@ -1,3 +0,0 @@
/dist/**
/coverage/**
/node_modules/**

View File

@ -1,12 +1,11 @@
{
"env": {
"node": true,
"es6": true,
"es2021": true,
"jest": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
"plugin:prettier/recommended"

2
.gitattributes vendored
View File

@ -1,4 +1,2 @@
/.yarn/releases/** binary
/.yarn/plugins/** binary
/dist/** linguist-generated=true
/lib/** linguist-generated=true

1
.github/CODEOWNERS vendored Normal file
View File

@ -0,0 +1 @@
* @crazy-max

View File

@ -1,3 +0,0 @@
# Code of conduct
- [Moby community guidelines](https://github.com/moby/moby/blob/master/CONTRIBUTING.md#moby-community-guidelines)

View File

@ -7,13 +7,13 @@ to the public under the [project's open source license](LICENSE).
## Submitting a pull request
1. [Fork](https://github.com/docker/setup-docker-action/fork) and clone the repository
1. [Fork](https://github.com/crazy-max/ghaction-setup-docker/fork) and clone the repository
2. Configure and install the dependencies: `yarn install`
3. Create a new branch: `git checkout -b my-branch-name`
4. Make your changes
5. Format code and build javascript artifacts: `docker buildx bake pre-checkin`
6. Validate all code has correctly formatted and built: `docker buildx bake validate`
7. Push to your fork and [submit a pull request](https://github.com/docker/setup-docker-action/compare)
7. Push to your fork and [submit a pull request](https://github.com/crazy-max/ghaction-setup-docker/compare)
8. Pat your self on the back and wait for your pull request to be reviewed and merged.
Here are a few things you can do that will increase the likelihood of your pull request being accepted:

View File

@ -1,102 +0,0 @@
# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema
name: Bug Report
description: Report a bug
labels:
- status/triage
body:
- type: markdown
attributes:
value: |
Thank you for taking the time to report a bug!
If this is a security issue please report it to the [Docker Security team](mailto:security@docker.com).
Before submitting a bug report, check out the [Troubleshooting doc](https://github.com/docker/setup-docker-action/blob/master/TROUBLESHOOTING.md).
- type: checkboxes
attributes:
label: Contributing guidelines
description: >
Make sure you've read the contributing guidelines before proceeding.
options:
- label: I've read the [contributing guidelines](https://github.com/docker/setup-docker-action/blob/master/.github/CONTRIBUTING.md) and wholeheartedly agree
required: true
- type: checkboxes
attributes:
label: "I've found a bug, and:"
description: |
Make sure that your request fulfills all of the following requirements.
If one requirement cannot be satisfied, explain in detail why.
options:
- label: The documentation does not mention anything about my problem
- label: There are no open or closed issues that are related to my problem
- type: textarea
attributes:
label: Description
description: >
Provide a brief description of the bug in 1-2 sentences.
validations:
required: true
- type: textarea
attributes:
label: Expected behaviour
description: >
Describe precisely what you'd expect to happen.
validations:
required: true
- type: textarea
attributes:
label: Actual behaviour
description: >
Describe precisely what is actually happening.
validations:
required: true
- type: input
attributes:
label: Repository URL
description: >
Enter the URL of the repository where you are experiencing the
issue. If your repository is private, provide a link to a minimal
repository that reproduces the issue.
- type: input
attributes:
label: Workflow run URL
description: >
Enter the URL of the GitHub Action workflow run if public (e.g.
`https://github.com/<user>/<repo>/actions/runs/<id>`)
- type: textarea
attributes:
label: YAML workflow
description: |
Provide the YAML of the workflow that's causing the issue.
Make sure to remove any sensitive information.
render: yaml
validations:
required: true
- type: textarea
attributes:
label: Workflow logs
description: >
[Attach](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/attaching-files)
the [log file of your workflow run](https://docs.github.com/en/actions/managing-workflow-runs/using-workflow-run-logs#downloading-logs)
and make sure to remove any sensitive information.
- type: textarea
attributes:
label: Docker daemon logs
description: >
If applicable, provide the Docker logs available in post step.
render: text
- type: textarea
attributes:
label: Additional info
description: |
Provide any additional information that could be useful.

34
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,34 @@
---
name: Bug report
about: Create a report to help us improve
---
### Behaviour
#### Steps to reproduce this issue
1.
2.
3.
#### Expected behaviour
> Tell us what should happen
#### Actual behaviour
> Tell us what happens instead
### Configuration
* Repository URL (if public):
* Build URL (if public):
```yml
# paste your YAML workflow file here and remove sensitive data
```
### Logs
> Download the [log file of your build](https://docs.github.com/en/actions/managing-workflow-runs/using-workflow-run-logs#downloading-logs)
> and [attach it](https://docs.github.com/en/github/managing-your-work-on-github/file-attachments-on-issues-and-pull-requests) to this issue.

View File

@ -1,6 +0,0 @@
# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository#configuring-the-template-chooser
blank_issues_enabled: true
contact_links:
- name: Questions and Discussions
url: https://github.com/docker/setup-docker-action/discussions/new
about: Use Github Discussions to ask questions and/or open discussion topics.

View File

@ -1,15 +0,0 @@
# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema
name: Feature request
description: Missing functionality? Come tell us about it!
labels:
- kind/enhancement
- status/triage
body:
- type: textarea
id: description
attributes:
label: Description
description: What is the feature you want to see?
validations:
required: true

12
.github/SECURITY.md vendored
View File

@ -1,12 +0,0 @@
# Reporting security issues
The project maintainers take security seriously. If you discover a security
issue, please bring it to their attention right away!
**Please _DO NOT_ file a public issue**, instead send your report privately to
[security@docker.com](mailto:security@docker.com).
Security reports are greatly appreciated, and we will publicly thank you for it.
We also like to send gifts&mdash;if you'd like Docker swag, make sure to let
us know. We currently do not offer a paid security bounty program, but are not
ruling it out in the future.

31
.github/SUPPORT.md vendored Normal file
View File

@ -0,0 +1,31 @@
# Support [![](https://isitmaintained.com/badge/resolution/crazy-max/ghaction-setup-docker.svg)](https://isitmaintained.com/project/crazy-max/ghaction-setup-docker)
First, [be a good guy](https://github.com/kossnocorp/etiquette/blob/master/README.md).
## Reporting an issue
Please do a search in [open issues](https://github.com/crazy-max/ghaction-setup-docker/issues?utf8=%E2%9C%93&q=) to see if the issue or feature request has already been filed.
If you find your issue already exists, make relevant comments and add your [reaction](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments). Use a reaction in place of a "+1" comment.
:+1: - upvote
:-1: - downvote
If you cannot find an existing issue that describes your bug or feature, submit an issue using the guidelines below.
## Writing good bug reports and feature requests
File a single issue per problem and feature request.
* Do not enumerate multiple bugs or feature requests in the same issue.
* Do not add your issue as a comment to an existing issue unless it's for the identical input. Many issues look similar, but have different causes.
The more information you can provide, the more likely someone will be successful reproducing the issue and finding a fix.
You are now ready to [create a new issue](https://github.com/crazy-max/ghaction-setup-docker/issues/new/choose)!
## Closure policy
* Issues that don't have the information requested above (when applicable) will be closed immediately and the poster directed to the support guidelines.
* Issues that go a week without a response from original poster are subject to closure at our discretion.

View File

@ -4,11 +4,6 @@ updates:
directory: "/"
schedule:
interval: "daily"
ignore:
# ignore this dependency
# it seems a bug with dependabot as pining to commit sha should not
# trigger a new version similar to https://github.com/docker/buildx/pull/2222#issuecomment-1919092153
- dependency-name: "docker/actions-toolkit"
labels:
- "dependencies"
- "bot"

View File

@ -1,9 +1,5 @@
name: ci
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
schedule:
@ -17,8 +13,8 @@ on:
pull_request:
env:
DOCKER_VERSION: v27.3.1
DOCKER_BUILD_SUMMARY: false
DOCKER_VERSION: v23.0.6
SIGN_QEMU_BINARY: 1
jobs:
main:
@ -28,23 +24,31 @@ jobs:
matrix:
os:
- ubuntu-latest
- ubuntu-24.04-arm
#- macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317
- macos-13
- macos-latest
- windows-latest
version:
- ""
- v27.3.1
- type=image,tag=27.3.1
- pinned
- latest
steps:
-
name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
-
name: Set version
shell: bash
run: |
if [ "${{ matrix.version }}" != "pinned" ]; then
echo "DOCKER_VERSION=${{ matrix.version }}" >> $GITHUB_ENV
fi
-
name: Set up Docker
uses: ./
with:
version: ${{ matrix.version }}
version: ${{ env.DOCKER_VERSION }}
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v2
channel:
runs-on: ${{ matrix.os }}
@ -53,20 +57,22 @@ jobs:
matrix:
os:
- ubuntu-latest
- ubuntu-24.04-arm
#- macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317
- macos-13
- macos-latest
- windows-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
-
name: Set up Docker
uses: ./
with:
version: ${{ env.DOCKER_VERSION }}
version: v23.0.0-rc.4
channel: test
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v2
daemon-config:
runs-on: ${{ matrix.os }}
@ -75,19 +81,16 @@ jobs:
matrix:
os:
- ubuntu-latest
- ubuntu-24.04-arm
#- macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317
- macos-13
- macos-latest
- windows-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
-
name: Set up Docker
uses: ./
with:
version: ${{ env.DOCKER_VERSION }}
daemon-config: |
{
"debug": true,
@ -95,6 +98,10 @@ jobs:
"containerd-snapshotter": true
}
}
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v2
context:
runs-on: ${{ matrix.os }}
@ -103,14 +110,12 @@ jobs:
matrix:
os:
- ubuntu-latest
- ubuntu-24.04-arm
#- macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317
- macos-13
- macos-latest
- windows-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
-
name: Set up Docker
uses: ./
@ -121,39 +126,29 @@ 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
runs-on: macos-13
colima-start-args:
runs-on: macos-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
-
name: Set up Docker
uses: ./
with:
version: ${{ env.DOCKER_VERSION }}
env:
LIMA_START_ARGS: --cpus 4 --memory 8
COLIMA_START_ARGS: --cpu 4 --memory 8 --disk 32 --dns 1.1.1.1 --dns 8.8.8.8 --dns-host example.com=1.2.3.4
build-linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
containerd:
- containerd-system
- containerd-tarball
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Uninstall containerd
if: matrix.containerd == 'containerd-tarball'
run: |
sudo apt-get remove -y containerd.io
uses: actions/checkout@v3
-
name: Set up Docker
uses: ./
@ -165,13 +160,13 @@ jobs:
docker run -d -p 5000:5000 --restart=always --name registry registry:2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v2
with:
driver: docker
driver-opts: network=host
-
name: Build and push
uses: docker/build-push-action@v6
uses: docker/build-push-action@v4
with:
context: ./test
push: true
@ -181,19 +176,17 @@ 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 }}
strategy:
fail-fast: false
matrix:
os:
#- macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317
- macos-13
runs-on: macos-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
-
name: Set up Docker
uses: ./
@ -205,13 +198,13 @@ jobs:
docker run -d -p 5000:5000 --restart=always --name registry registry:2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v2
with:
driver: docker
driver-opts: network=host
-
name: Build and push
uses: docker/build-push-action@v6
uses: docker/build-push-action@v4
with:
context: ./test
push: true
@ -221,13 +214,17 @@ 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
steps:
-
name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
-
name: Set up Docker
uses: ./
@ -242,90 +239,7 @@ jobs:
name: Inspect
run: |
docker image inspect test
set-host:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker
uses: ./
with:
version: ${{ env.DOCKER_VERSION }}
set-host: true
-
name: List contexts
run: |
docker context ls
rootless:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker
uses: ./
with:
version: ${{ env.DOCKER_VERSION }}
rootless: true
-
name: List contexts
run: |
docker context ls
tcp:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- ubuntu-24.04-arm
#- macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317
- macos-13
- windows-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker
id: setup_docker
uses: ./
with:
version: ${{ env.DOCKER_VERSION }}
tcp-port: 2378
-
name: Check docker info through TCP
run: |
docker info
env:
DOCKER_HOST: ${{ steps.setup_docker.outputs.tcp }}
undock-regctl-version:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
undock_version:
- ''
- v0.9.0
regctl_version:
- ''
- v0.8.2
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker
uses: ./
with:
version: type=image
env:
UNDOCK_VERSION: ${{ matrix.undock_version }}
REGCTL_VERSION: ${{ matrix.regctl_version }}
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v2

View File

@ -1,17 +0,0 @@
name: pr-assign-author
permissions:
contents: read
on:
pull_request_target:
types:
- opened
- reopened
jobs:
run:
uses: crazy-max/.github/.github/workflows/pr-assign-author.yml@1b673f36fad86812f538c1df9794904038a23cbf
permissions:
contents: read
pull-requests: write

View File

@ -1,21 +0,0 @@
name: publish
on:
release:
types:
- published
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Publish
uses: actions/publish-immutable-action@v0.0.4

View File

@ -1,9 +1,5 @@
name: test
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
@ -17,16 +13,14 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
-
name: Test
uses: docker/bake-action@v6
uses: docker/bake-action@v3
with:
targets: test
-
name: Upload coverage
uses: codecov/codecov-action@v5
uses: codecov/codecov-action@v3
with:
source: .
files: ./coverage/clover.xml
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage/clover.xml

View File

@ -1,9 +1,5 @@
name: validate
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
@ -15,17 +11,16 @@ jobs:
prepare:
runs-on: ubuntu-latest
outputs:
targets: ${{ steps.generate.outputs.targets }}
targets: ${{ steps.targets.outputs.matrix }}
steps:
-
name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
-
name: List targets
id: generate
uses: docker/bake-action/subaction/list-targets@v6
with:
target: validate
name: Targets matrix
id: targets
run: |
echo "matrix=$(docker buildx bake validate --print | jq -cr '.group.validate.targets')" >> $GITHUB_OUTPUT
validate:
runs-on: ubuntu-latest
@ -36,8 +31,11 @@ jobs:
matrix:
target: ${{ fromJson(needs.prepare.outputs.targets) }}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Validate
uses: docker/bake-action@v6
uses: docker/bake-action@v3
with:
targets: ${{ matrix.target }}

66
.gitignore vendored
View File

@ -1,5 +1,7 @@
# https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
node_modules
lib
# Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
logs
*.log
@ -7,7 +9,6 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
@ -18,14 +19,34 @@ pids
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
@ -35,19 +56,36 @@ jspm_packages/
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
# dotenv environment variables file
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
.env.test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/

View File

@ -1,6 +0,0 @@
# Dependency directories
node_modules/
jspm_packages/
# yarn v2
.yarn/

File diff suppressed because one or more lines are too long

View File

@ -1,13 +0,0 @@
logFilters:
- code: YN0013
level: discard
- code: YN0019
level: discard
- code: YN0076
level: discard
nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"

169
README.md
View File

@ -1,26 +1,14 @@
[![GitHub release](https://img.shields.io/github/release/docker/setup-docker-action.svg?style=flat-square)](https://github.com/docker/setup-docker-action/releases/latest)
[![GitHub release](https://img.shields.io/github/release/crazy-max/ghaction-setup-docker.svg?style=flat-square)](https://github.com/crazy-max/ghaction-setup-docker/releases/latest)
[![GitHub marketplace](https://img.shields.io/badge/marketplace-docker--setup--docker-blue?logo=github&style=flat-square)](https://github.com/marketplace/actions/docker-setup-docker)
[![CI workflow](https://img.shields.io/github/actions/workflow/status/docker/setup-docker-action/ci.yml?branch=master&label=ci&logo=github&style=flat-square)](https://github.com/docker/setup-docker-action/actions?workflow=ci)
[![Test workflow](https://img.shields.io/github/actions/workflow/status/docker/setup-docker-action/test.yml?branch=master&label=test&logo=github&style=flat-square)](https://github.com/docker/setup-docker-action/actions?workflow=test)
[![Codecov](https://img.shields.io/codecov/c/github/docker/setup-docker-action?logo=codecov&style=flat-square)](https://codecov.io/gh/docker/setup-docker-action)
[![CI workflow](https://img.shields.io/github/actions/workflow/status/crazy-max/ghaction-setup-docker/ci.yml?branch=master&label=ci&logo=github&style=flat-square)](https://github.com/crazy-max/ghaction-setup-docker/actions?workflow=ci)
[![Test workflow](https://img.shields.io/github/actions/workflow/status/crazy-max/ghaction-setup-docker/test.yml?branch=master&label=test&logo=github&style=flat-square)](https://github.com/crazy-max/ghaction-setup-docker/actions?workflow=test)
[![Codecov](https://img.shields.io/codecov/c/github/crazy-max/ghaction-setup-docker?logo=codecov&style=flat-square)](https://codecov.io/gh/crazy-max/ghaction-setup-docker)
## About
GitHub Action to set up (download and install) [Docker CE](https://docs.docker.com/engine/).
Works on Linux, macOS and Windows.
> [!NOTE]
> This action is useful if you want to pin against a specific Docker version or
> set up a custom daemon configuration or if Docker is not available on your
> runner. If you're using [GitHub-hosted runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources)
> on Linux or Windows, Docker is already up and running, so it might not be
> necessary to use this action.
> [!WARNING]
> Does not work on macOS runners with ARM architecture (no nested virtualization):
> * https://github.com/crazy-max/ghaction-setup-docker/pull/53
> * https://github.com/docker/actions-toolkit/issues/317
![Screenshot](.github/setup-docker-action.png)
___
@ -28,11 +16,10 @@ ___
* [Usage](#usage)
* [Quick start](#quick-start)
* [Daemon configuration](#daemon-configuration)
* [Define custom `limactl start` arguments (macOS)](#define-custom-limactl-start-arguments-macos)
* [Define custom `colima start` arguments (macOS)](#define-custom-colima-start-arguments-macos)
* [Customizing](#customizing)
* [inputs](#inputs)
* [inputs.version](#inputsversion)
* [outputs](#outputs)
* [Notes](#notes)
* [Contributing](#contributing)
* [License](#license)
@ -52,7 +39,7 @@ jobs:
steps:
-
name: Set up Docker
uses: docker/setup-docker-action@v4
uses: crazy-max/ghaction-setup-docker@v1
```
### Daemon configuration
@ -74,7 +61,7 @@ jobs:
steps:
-
name: Set up Docker
uses: docker/setup-docker-action@v4
uses: crazy-max/ghaction-setup-docker@v1
with:
daemon-config: |
{
@ -85,10 +72,10 @@ jobs:
}
```
### Define custom `limactl start` arguments (macOS)
### Define custom `colima start` arguments (macOS)
You can define custom [`limactl start` arguments](https://lima-vm.io/docs/reference/limactl_start/)
using the `LIMA_START_ARGS` environment variable to customize the VM:
You can define custom [`colima start` arguments](https://github.com/abiosoft/colima#customizing-the-vm)
using the `COLIMA_START_ARGS` environment variable to customize the VM:
```yaml
name: ci
@ -102,106 +89,92 @@ jobs:
steps:
-
name: Set up Docker
uses: docker/setup-docker-action@v4
uses: crazy-max/ghaction-setup-docker@v1
env:
LIMA_START_ARGS: --cpus 4 --memory 8
COLIMA_START_ARGS: --cpu 4 --memory 8 --disk 32
```
## Customizing
### inputs
The following inputs can be used as `step.with` keys
Following inputs can be used as `step.with` keys
| Name | Type | Default | Description |
|-----------------|--------|-----------------------|-----------------------------------------------------------------------------------------------------------------------------|
| `version` | String | `latest` | Docker version to use. See [inputs.version](#inputs.version). |
| `channel` | String | `stable` | Docker CE [channel](https://download.docker.com/linux/static/) (`stable` or `test`). Only applicable to `type=archive` |
| `version` | String | `latest` | Docker CE version (e.g., `v23.0.1`). |
| `channel` | String | `stable` | Docker CE [channel](https://download.docker.com/linux/static/) (e.g, `stable`, `edge` or `test`). |
| `daemon-config` | String | | [Docker daemon JSON configuration](https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file) |
| `tcp-port` | Number | | TCP port to expose the Docker API locally |
| `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 |
### inputs.version
## Notes
By default, the latest stable version of Docker is fetched from download.docker.com.
### macOS: `qemu[stderr]: qemu-system-x86_64: Unknown Error`
You can specify a specific version number (e.g. `v27.4.0`).
Which is a shorthand for the full comma separated value:
Colima may fail to start with the following error:
`type=archive,channel=stable,version=v27.4.0`
You can also use this full csv format instead.
Currently supported source types are:
- `archive`
- `image`
#### `type=archive`
| Key | Default | Description |
|-----------|------------|--------------------------------------------------------------------------------------|
| `type` | `archive` | The source type of the Docker binaries. Possible values are `archive` and `image`. |
| `channel` | `stable` | The download.docker.com channel (`stable` or `test`). |
| `version` | `latest` | The Docker version to use. |
Examples:
```yaml
# last stable released version
version: latest
version: type=archive # same as above
version: version=latest # same as above
version: type=archive,version=latest # same as above
```
time="2023-08-26T06:30:33Z" level=info msg="[hostagent] Starting QEMU (hint: to watch the boot progress, see \"/Users/runner/.lima/colima/serial*.log\")"
time="2023-08-26T06:30:34Z" level=info msg="SSH Local Port: 49209"
time="2023-08-26T06:30:34Z" level=info msg="[hostagent] Waiting for the essential requirement 1 of 3: \"ssh\""
time="2023-08-26T06:30:34Z" level=info msg="[hostagent] Driver stopped due to error: \"exit status 255\""
time="2023-08-26T06:30:34Z" level=info msg="[hostagent] Shutting down the host agent"
time="2023-08-26T06:30:34Z" level=warning msg="[hostagent] failed to exit SSH master"
time="2023-08-26T06:30:34Z" level=info msg="[hostagent] Shutting down QEMU with ACPI"
time="2023-08-26T06:30:34Z" level=warning msg="[hostagent] failed to open the QMP socket \"/Users/runner/.lima/colima/qmp.sock\", forcibly killing QEMU"
time="2023-08-26T06:30:34Z" level=info msg="[hostagent] QEMU has already exited"
time="2023-08-26T06:30:34Z" level=fatal msg="exiting, status={Running:false Degraded:false Exiting:true Errors:[] SSHLocalPort:0} (hint: see \"/Users/runner/.lima/colima/ha.stderr.log\")"
time="2023-08-26T06:30:34Z" level=fatal msg="error starting vm: error at 'creating and starting': exit status 1"
```
```yaml
# v27.3.0-rc.1 from test channel
version: type=archive,version=27.3.0-rc.1,channel=test
```
{"level":"debug","msg":"executing [ssh-keygen -t ed25519 -q -N -f /Users/runner/.lima/_config/user]","time":"2023-08-26T07:16:40Z"}
{"level":"debug","msg":"Creating iso file /Users/runner/.lima/colima/cidata.iso","time":"2023-08-26T07:16:41Z"}
{"level":"debug","msg":"Using /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/diskfs_iso3418167253 as workspace","time":"2023-08-26T07:16:41Z"}
{"level":"debug","msg":"OpenSSH version 8.6.1 detected","time":"2023-08-26T07:16:41Z"}
{"level":"debug","msg":"AES accelerator seems available, prioritizing aes128-gcm@openssh.com and aes256-gcm@openssh.com","time":"2023-08-26T07:16:41Z"}
{"level":"debug","msg":"QEMU version 8.0.4 detected","time":"2023-08-26T07:16:43Z"}
{"level":"debug","msg":"firmware candidates = [/Users/runner/.local/share/qemu/edk2-x86_64-code.fd /Users/runner/.colima/_wrapper/4e1b408f843d1c63afbbdcf80c40e4c88d33509f/share/qemu/edk2-x86_64-code.fd /usr/share/OVMF/OVMF_CODE.fd /usr/share/qemu/ovmf-x86_64-code.bin /usr/share/edk2-ovmf/x64/OVMF_CODE.fd]","time":"2023-08-26T07:16:43Z"}
{"level":"info","msg":"Starting QEMU (hint: to watch the boot progress, see \"/Users/runner/.lima/colima/serial*.log\")","time":"2023-08-26T07:16:43Z"}
{"level":"debug","msg":"qCmd.Args: [/Users/runner/.colima/_wrapper/4e1b408f843d1c63afbbdcf80c40e4c88d33509f/bin/qemu-system-x86_64 -m 2048 -cpu host,-pdpe1gb -machine q35,accel=hvf -smp 2,sockets=1,cores=2,threads=1 -drive if=pflash,format=raw,readonly=on,file=/Users/runner/.colima/_wrapper/4e1b408f843d1c63afbbdcf80c40e4c88d33509f/share/qemu/edk2-x86_64-code.fd -boot order=d,splash-time=0,menu=on -drive file=/Users/runner/.lima/colima/basedisk,format=raw,media=cdrom,readonly=on -drive file=/Users/runner/.lima/colima/diffdisk,if=virtio,discard=on -drive id=cdrom0,if=none,format=raw,readonly=on,file=/Users/runner/.lima/colima/cidata.iso -device virtio-scsi-pci,id=scsi0 -device scsi-cd,bus=scsi0.0,drive=cdrom0 -netdev user,id=net0,net=192.168.5.0/24,dhcpstart=192.168.5.15,hostfwd=tcp:127.0.0.1:49168-:22 -device virtio-net-pci,netdev=net0,mac=52:55:55:be:6e:dd -device virtio-rng-pci -display none -device virtio-vga -device virtio-keyboard-pci -device virtio-mouse-pci -device qemu-xhci,id=usb-bus -parallel none -chardev socket,id=char-serial,path=/Users/runner/.lima/colima/serial.sock,server=on,wait=off,logfile=/Users/runner/.lima/colima/serial.log -serial chardev:char-serial -chardev socket,id=char-serial-virtio,path=/Users/runner/.lima/colima/serialv.sock,server=on,wait=off,logfile=/Users/runner/.lima/colima/serialv.log -device virtio-serial-pci,id=virtio-serial0,max_ports=1 -device virtconsole,chardev=char-serial-virtio,id=console0 -virtfs local,mount_tag=mount0,path=/Users/runner,security_model=none -virtfs local,mount_tag=mount1,path=/tmp/colima,security_model=none -chardev socket,id=char-qmp,path=/Users/runner/.lima/colima/qmp.sock,server=on,wait=off -qmp chardev:char-qmp -name lima-colima -pidfile /Users/runner/.lima/colima/qemu.pid]","time":"2023-08-26T07:16:43Z"}
{"level":"info","msg":"Waiting for the essential requirement 1 of 3: \"ssh\"","time":"2023-08-26T07:16:43Z"}
{"level":"debug","msg":"executing script \"ssh\"","time":"2023-08-26T07:16:43Z"}
{"level":"debug","msg":"executing ssh for script \"ssh\": /usr/bin/ssh [ssh -F /dev/null -o IdentityFile=\"/Users/runner/.lima/_config/user\" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o NoHostAuthenticationForLocalhost=yes -o GSSAPIAuthentication=no -o PreferredAuthentications=publickey -o Compression=no -o BatchMode=yes -o IdentitiesOnly=yes -o Ciphers=\"^aes128-gcm@openssh.com,aes256-gcm@openssh.com\" -o User=runner -o ControlMaster=auto -o ControlPath=\"/Users/runner/.lima/colima/ssh.sock\" -o ControlPersist=5m -p 49168 127.0.0.1 -- /bin/bash]","time":"2023-08-26T07:16:43Z"}
{"level":"debug","msg":"stdout=\"\", stderr=\"ssh: connect to host 127.0.0.1 port 49168: Connection refused\\r\\n\", err=failed to execute script \"ssh\": stdout=\"\", stderr=\"ssh: connect to host 127.0.0.1 port 49168: Connection refused\\r\\n\": exit status 255","time":"2023-08-26T07:16:43Z"}
{"level":"debug","msg":"qemu[stderr]: qemu-system-x86_64: Unknown Error","time":"2023-08-26T07:16:43Z"}
{"level":"info","msg":"Driver stopped due to error: \"exit status 255\"","time":"2023-08-26T07:16:43Z"}
{"level":"info","msg":"Shutting down the host agent","time":"2023-08-26T07:16:44Z"}
{"level":"debug","msg":"shutting down the SSH master","time":"2023-08-26T07:16:44Z"}
{"level":"debug","msg":"executing ssh for exiting the master: /usr/bin/ssh [ssh -F /dev/null -o IdentityFile=\"/Users/runner/.lima/_config/user\" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o NoHostAuthenticationForLocalhost=yes -o GSSAPIAuthentication=no -o PreferredAuthentications=publickey -o Compression=no -o BatchMode=yes -o IdentitiesOnly=yes -o Ciphers=\"^aes128-gcm@openssh.com,aes256-gcm@openssh.com\" -o User=runner -o ControlMaster=auto -o ControlPath=\"/Users/runner/.lima/colima/ssh.sock\" -o ControlPersist=5m -O exit -p 49168 127.0.0.1]","time":"2023-08-26T07:16:44Z"}
{"error":"failed to execute `ssh -O exit -p 49168 127.0.0.1`, out=\"Control socket connect(/Users/runner/.lima/colima/ssh.sock): No such file or directory\\r\\n\": exit status 255","level":"warning","msg":"failed to exit SSH master","time":"2023-08-26T07:16:44Z"}
{"level":"info","msg":"Shutting down QEMU with ACPI","time":"2023-08-26T07:16:44Z"}
{"error":"dial unix /Users/runner/.lima/colima/qmp.sock: connect: connection refused","level":"warning","msg":"failed to open the QMP socket \"/Users/runner/.lima/colima/qmp.sock\", forcibly killing QEMU","time":"2023-08-26T07:16:44Z"}
{"level":"info","msg":"QEMU has already exited","time":"2023-08-26T07:16:44Z"}
```
#### `type=image`
Other possible source type is `image` which will pull the Docker binaries from the `moby/moby-bin` and
`dockereng/cli-bin` Docker Hub repositories.
The advantage of using this source type is that these images are built by the Moby and Docker CI pipelines
for each branch and PR, so you can use the `tag` input to install a specific version or branch (e.g. `master`).
| Key | Default | Description |
|-----------|------------|--------------------------------------------------------------------------------------|
| `tag` | `latest` | The image tag to use. |
See https://hub.docker.com/r/moby/moby-bin/tags and https://hub.docker.com/r/dockereng/cli-bin/tags for available tags.
Examples:
```yaml
# install last stable released version from bin images
version: type=image
version: type=image,tag=latest # same as above
```
To fix this issue you can replace the existing signature of QEMU binary with
the required entitlements as suggested in https://github.com/abiosoft/colima/issues/786#issuecomment-1693629650.
This can be done within this action by setting the env var `SIGN_QEMU_BINARY=1`:
```yaml
# a cutting-edge version from the `master` branch
version: type=image,tag=master
-
name: Set up Docker
uses: crazy-max/ghaction-setup-docker@v1
env:
SIGN_QEMU_BINARY: 1
```
```yaml
# install v27.4.0 from bin images
version: type=image,tag=27.4.0
```
### outputs
The following outputs are available
| Name | Type | Description |
|--------|--------|---------------------------------------|
| `sock` | String | Docker socket path |
| `tcp` | String | Docker TCP address if tcp-port is set |
## Contributing
Want to contribute? Awesome! You can find information about contributing to
this project in the [CONTRIBUTING.md](/.github/CONTRIBUTING.md)
Want to contribute? Awesome! The most basic way to show your support is to star
the project, or to raise issues. If you want to open a pull request, please
read the [contributing guidelines](.github/CONTRIBUTING.md).
You can also support this project by [**becoming a sponsor on GitHub**](https://github.com/sponsors/crazy-max)
or by making a [PayPal donation](https://www.paypal.me/crazyws) to ensure this
journey continues indefinitely!
Thanks again for your support, it is much appreciated! :pray:
## License

View File

@ -17,195 +17,40 @@ describe('getInputs', () => {
[
0,
new Map<string, string>([
['version', 'v24.0.8'],
['set-host', 'false'],
['rootless', 'false'],
['version', 'v23.0.1'],
]),
{
source: {
type: 'archive',
version: 'v24.0.8',
channel: 'stable'
},
version: 'v23.0.1',
channel: '',
context: '',
daemonConfig: '',
rootless: false,
setHost: false
} as context.Inputs
],
[
1,
new Map<string, string>([
['version', 'v24.0.0-rc.4'],
['version', 'v23.0.0-rc.4'],
['channel', 'test'],
['context', 'foo'],
['daemon-config', `{"debug":true,"features":{"containerd-snapshotter":true}}`],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
type: 'archive',
version: 'v24.0.0-rc.4',
channel: 'test'
},
version: 'v23.0.0-rc.4',
channel: 'test',
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'],
]),
new Map<string, string>([]),
{
source: {
type: 'archive',
version: 'latest',
channel: 'stable',
},
version: 'latest',
channel: '',
context: '',
daemonConfig: '',
rootless: false,
setHost: true
} as context.Inputs
],
[
3,
new Map<string, string>([
['version', 'type=image,tag=master'],
['context', 'foo'],
['daemon-config', `{"debug":true,"features":{"containerd-snapshotter":true}}`],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
type: 'image',
tag: 'master',
},
context: 'foo',
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`,
rootless: false,
setHost: false
} as context.Inputs
],
[
4,
new Map<string, string>([
['version', 'type=image'],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
type: 'image',
tag: 'latest',
},
context: '',
daemonConfig: '',
rootless: false,
setHost: false
} as context.Inputs
],
[
5,
new Map<string, string>([
['version', 'type=archive'],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
type: 'archive',
version: 'latest',
channel: 'stable',
},
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: {
type: 'archive',
version: 'v27.2.0',
channel: 'test',
},
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: {
type: 'image',
tag: '27.2.1',
},
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
],
[
9,
new Map<string, string>([
['version', 'v24.0.8'],
['tcp-port', '2378'],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
type: 'archive',
version: 'v24.0.8',
channel: 'stable'
},
context: '',
daemonConfig: '',
tcpPort: 2378,
rootless: false,
setHost: false
} as context.Inputs
],
]
])(
'[%d] given %p as inputs, returns %p',
async (num: number, inputs: Map<string, string>, expected: context.Inputs) => {

View File

@ -1,14 +1,14 @@
# https://help.github.com/en/articles/metadata-syntax-for-github-actions
name: Docker Setup Docker
description: Set up Docker for use in GitHub Actions by downloading and installing a version of Docker CE
author: docker
name: 'Docker Setup Docker'
description: 'Set up Docker for use in GitHub Actions by downloading and installing a version of Docker CE'
author: 'crazy-max'
branding:
icon: 'anchor'
color: 'blue'
inputs:
version:
description: 'Docker CE version. (e.g, v24.0.9)'
description: 'Docker CE version. (e.g, v23.0.1)'
required: false
default: 'latest'
channel:
@ -17,28 +17,11 @@ inputs:
daemon-config:
description: 'Docker daemon JSON configuration'
required: false
tcp-port:
description: 'TCP port to expose the Docker API locally'
required: false
context:
description: 'Docker context name. (default setup-docker-action)'
required: false
set-host:
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:
description: "Docker socket path"
tcp:
description: "Docker TCP address if tcp-port is set"
runs:
using: 'node20'
using: 'node16'
main: 'dist/index.js'
post: 'dist/index.js'

View File

@ -1,12 +1,3 @@
comment: false
coverage:
status:
project: # settings affecting project coverage
default:
target: auto # auto % coverage target
threshold: 5% # allow for 5% reduction of coverage without failing
patch: off
github_checks:
annotations: false

View File

@ -1,20 +1,13 @@
# syntax=docker/dockerfile:1
ARG NODE_VERSION=20
ARG NODE_VERSION=16
FROM node:${NODE_VERSION}-alpine AS base
RUN apk add --no-cache cpio findutils git
WORKDIR /src
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache <<EOT
corepack enable
yarn --version
yarn config set --home enableTelemetry 0
EOT
FROM base AS deps
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \
yarn install && mkdir /vendor && cp yarn.lock /vendor
@ -35,7 +28,6 @@ EOT
FROM deps AS build
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \
yarn run build && mkdir /out && cp -Rf dist /out/
@ -56,7 +48,6 @@ EOT
FROM deps AS format
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \
yarn run format \
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' | cpio -pdm /out
@ -66,15 +57,13 @@ COPY --from=format /out /
FROM deps AS lint
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \
yarn run lint
FROM deps AS test
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \
yarn run test --coverage --coverageDirectory=/tmp/coverage
yarn run test --coverageDirectory=/tmp/coverage
FROM scratch AS test-coverage
COPY --from=test /tmp/coverage /

93
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

3268
dist/licenses.txt generated vendored

File diff suppressed because it is too large Load Diff

2
dist/sourcemap-register.js generated vendored

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,3 @@
target "_common" {
args = {
BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1
}
}
group "default" {
targets = ["build"]
}
@ -17,49 +11,42 @@ group "validate" {
}
target "build" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile"
target = "build-update"
output = ["."]
}
target "build-validate" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile"
target = "build-validate"
output = ["type=cacheonly"]
}
target "format" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile"
target = "format-update"
output = ["."]
}
target "lint" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile"
target = "lint"
output = ["type=cacheonly"]
}
target "vendor-update" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile"
target = "vendor-update"
output = ["."]
}
target "vendor-validate" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile"
target = "vendor-validate"
output = ["type=cacheonly"]
}
target "test" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile"
target = "test-coverage"
output = ["./coverage"]

View File

@ -15,7 +15,6 @@ process.env = Object.assign({}, process.env, {
module.exports = {
clearMocks: true,
testEnvironment: 'node',
moduleFileExtensions: ['js', 'ts'],
testMatch: ['**/*.test.ts'],
transform: {

View File

@ -4,44 +4,40 @@
"main": "lib/main.js",
"scripts": {
"build": "ncc build src/main.ts --source-map --minify --license licenses.txt",
"lint": "yarn run prettier && yarn run eslint",
"format": "yarn run prettier:fix && yarn run eslint:fix",
"eslint": "eslint --max-warnings=0 .",
"eslint:fix": "eslint --fix .",
"prettier": "prettier --check \"./**/*.ts\"",
"prettier:fix": "prettier --write \"./**/*.ts\"",
"test": "jest",
"lint": "eslint src/**/*.ts __tests__/**/*.ts",
"format": "eslint --fix src/**/*.ts __tests__/**/*.ts",
"test": "jest --coverage",
"all": "yarn run build && yarn run format && yarn test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/docker/setup-docker-action.git"
"url": "git+https://github.com/crazy-max/ghaction-setup-docker.git"
},
"keywords": [
"actions",
"docker",
"engine"
],
"author": "Docker Inc.",
"author": "CrazyMax",
"license": "Apache-2.0",
"packageManager": "yarn@3.6.3",
"dependencies": {
"@actions/core": "^1.11.1",
"@docker/actions-toolkit": "^0.61.0"
"@actions/core": "^1.10.0",
"@docker/actions-toolkit": "^0.12.0-rc.1",
"uuid": "^9.0.0"
},
"devDependencies": {
"@types/node": "^20.6.0",
"@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^6.6.0",
"@vercel/ncc": "^0.38.0",
"eslint": "^8.49.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-jest": "^27.2.3",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.6.4",
"prettier": "^3.0.3",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
"@types/node": "^16.11.26",
"@typescript-eslint/eslint-plugin": "^5.14.0",
"@typescript-eslint/parser": "^5.14.0",
"@vercel/ncc": "^0.33.3",
"eslint": "^8.11.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^26.1.1",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.2.5",
"prettier": "^2.3.1",
"ts-jest": "^27.1.2",
"ts-node": "^10.7.0",
"typescript": "^4.4.4"
}
}

View File

@ -1,102 +1,17 @@
import * as core from '@actions/core';
import {parse} from 'csv-parse/sync';
import {InstallSource} from '@docker/actions-toolkit/lib/docker/install';
import {Util} from '@docker/actions-toolkit/lib/util';
export interface Inputs {
source: InstallSource;
version: string;
channel: string;
daemonConfig?: string;
tcpPort?: number;
context: string;
setHost: boolean;
rootless: boolean;
}
export function getInputs(): Inputs {
const rawVersion = core.getInput('version') || 'latest';
const source = parseSource(rawVersion);
const channel = core.getInput('channel');
if (channel && source.type === 'archive') {
source.channel = channel;
}
return {
source: source,
version: core.getInput('version') || 'latest',
channel: core.getInput('channel'),
daemonConfig: core.getInput('daemon-config'),
tcpPort: Util.getInputNumber('tcp-port'),
context: core.getInput('context'),
setHost: core.getBooleanInput('set-host'),
rootless: core.getBooleanInput('rootless')
context: core.getInput('context')
};
}
function parseSource(input: string): InstallSource {
let [type, version, channel, tag] = ['archive', 'latest', 'stable', 'latest'];
const fields = parse(input, {
relaxColumnCount: true,
skipEmptyLines: true
})[0];
for (const field of fields) {
const parts = field
.toString()
.split(/(?<=^[^=]+?)=/)
.map(item => item.trim());
switch (parts[0]) {
case 'type':
type = parts[1];
break;
case 'version':
version = parts[1];
break;
case 'channel':
channel = parts[1];
break;
case 'tag':
tag = parts[1];
break;
default:
if (fields.length === 1) {
version = parts[0];
break;
}
throw new Error(`Invalid field: ${parts[0]}`);
}
}
if (!type) {
throw new Error(`Invalid type: ${type}`);
}
if (!channel) {
throw new Error(`Invalid channel: ${channel}`);
}
if (!version) {
throw new Error(`Invalid version: ${version}`);
}
if (!tag) {
throw new Error(`Invalid tag: ${tag}`);
}
let src: InstallSource;
switch (type) {
case 'archive':
src = {
type: 'archive',
version: version,
channel: channel
};
break;
case 'image':
src = {
type: 'image',
tag: tag
};
break;
default:
throw new Error(`Invalid version: ${input}`);
}
return src;
}

View File

@ -1,95 +1,40 @@
import * as crypto from 'crypto';
import os from 'os';
import path from 'path';
import * as uuid from 'uuid';
import * as core from '@actions/core';
import * as actionsToolkit from '@docker/actions-toolkit';
import {Install} from '@docker/actions-toolkit/lib/docker/install';
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
import {Install as RegclientInstall} from '@docker/actions-toolkit/lib/regclient/install';
import {Regctl} from '@docker/actions-toolkit/lib/regclient/regctl';
import {Install as UndockInstall} from '@docker/actions-toolkit/lib/undock/install';
import {Undock} from '@docker/actions-toolkit/lib/undock/undock';
import * as context from './context';
import * as stateHelper from './state-helper';
const regctlDefaultVersion = 'v0.8.3';
const undockDefaultVersion = 'v0.10.0';
actionsToolkit.run(
// main
async () => {
const input: context.Inputs = context.getInputs();
const runDir = path.join(os.homedir(), `setup-docker-action-${crypto.randomUUID().slice(0, 8)}`);
const runDir = path.join(os.homedir(), `setup-docker-action-${uuid.v4()}`);
if (input.context == 'default') {
throw new Error(`'default' context cannot be used.`);
}
if (input.source.type === 'image') {
await core.group(`Download and install regctl`, async () => {
const regclientInstall = new RegclientInstall();
const regclientBinPath = await regclientInstall.download(
process.env.REGCTL_VERSION && process.env.REGCTL_VERSION.trim()
? process.env.REGCTL_VERSION
: regctlDefaultVersion,
true
);
await regclientInstall.install(regclientBinPath);
});
await core.group(`Download and install undock`, async () => {
const undockInstall = new UndockInstall();
const undockBinPath = await undockInstall.download(
process.env.UNDOCK_VERSION && process.env.UNDOCK_VERSION.trim()
? process.env.UNDOCK_VERSION
: undockDefaultVersion,
true
);
await undockInstall.install(undockBinPath);
});
}
let tcpPort: number | undefined;
let tcpAddress: string | undefined;
if (input.tcpPort) {
tcpPort = input.tcpPort;
tcpAddress = `tcp://127.0.0.1:${tcpPort}`;
}
const install = new Install({
runDir: runDir,
source: input.source,
rootless: input.rootless,
version: input.version,
channel: input.channel || 'stable',
contextName: input.context || 'setup-docker-action',
daemonConfig: input.daemonConfig,
localTCPPort: tcpPort,
regctl: new Regctl(),
undock: new Undock()
daemonConfig: input.daemonConfig
});
let toolDir;
if (!(await Docker.isAvailable()) || input.source) {
if (!(await Docker.isAvailable()) || input.version) {
await core.group(`Download docker`, async () => {
toolDir = await install.download();
});
}
if (toolDir) {
stateHelper.setRunDir(runDir);
const sockPath = await install.install();
await core.group(`Setting outputs`, async () => {
core.info(`sock=${sockPath}`);
core.setOutput('sock', sockPath);
if (tcpAddress) {
core.info(`tcp=${tcpAddress}`);
core.setOutput('tcp', tcpAddress);
}
});
if (input.setHost) {
await core.group(`Setting Docker host`, async () => {
core.exportVariable('DOCKER_HOST', sockPath);
core.info(`DOCKER_HOST=${sockPath}`);
});
}
await install.install();
}
await core.group(`Docker info`, async () => {
@ -103,9 +48,7 @@ actionsToolkit.run(
return;
}
const install = new Install({
runDir: stateHelper.runDir,
regctl: new Regctl(),
undock: new Undock()
runDir: stateHelper.runDir
});
await install.tearDown();
}

View File

@ -3,6 +3,7 @@
"esModuleInterop": true,
"target": "es6",
"module": "commonjs",
"strict": true,
"newLine": "lf",
"outDir": "./lib",
"rootDir": "./src",
@ -12,8 +13,9 @@
"useUnknownInCatchVariables": false,
},
"exclude": [
"./__tests__/**/*",
"./lib/**/*",
"node_modules",
"**/*.test.ts",
"jest.config.ts"
]
}

11049
yarn.lock

File diff suppressed because it is too large Load Diff