Qarik-Group / docker-buildx-resource

Apache License 2.0
1 stars 5 forks source link

Multiarch Docker Resource

Builds multi-architecture Docker images using the docker buildx experimental plugin for Concourse CI.

Learn more about multi-architecture images and Docker Buildx.

This Concourse CI resource otherwise the same as the popular docker-image-resource.

The initial implementation removed many options from the build/out implementation for which I could not yet determine the equivalent feature for multi-arch support. I may need to switch to interacting directly with the registry via its API. For example https://stackoverflow.com/a/38362476/36170.

Source Configuration

Behavior

check: Check for new images.

The current image digest is fetched from the registry for the given tag of the repository.

in: Fetch the image from the registry.

Pulls down the repository image by the requested digest.

The following files will be placed in the destination:

Parameters

As with all concourse resources, to modify params of the implicit get step after each put step you may also set these parameters under a put get_params. For example:

put: foo
params: {...}
get_params: {skip_download: true}

out: Build and push a Dockerfile.

Push a Docker image to the source's repository and tag. The resulting version is the image's digest.

Parameters

Example

resource_types:
- name: docker-buildx
  type: docker-image
  privileged: true
  source:
    repository: starkandwayne/docker-image-resource
    tag: latest

resources:
- name: git-resource
  type: git
  source: # ...

- name: git-resource-image
  type: docker-buildx
  source:
    repository: concourse/git-resource
    username: username
    password: password

jobs:
- name: build-rootfs
  plan:
  - get: git-resource
  - put: git-resource-image
    params:
        build: git-resource

Development

Prerequisites

Running the tests

The tests have been embedded with the Dockerfile; ensuring that the testing environment is consistent across any docker enabled platform. When the docker image builds, the test are run inside the docker container, on failure they will stop the build.

Run the tests with the following commands for both alpine and ubuntu images:

docker build -t docker-buildx-resource -f dockerfiles/alpine/Dockerfile .
docker build -t docker-buildx-resource -f dockerfiles/ubuntu/Dockerfile .

To use the newly built image, push it to a docker registry that's accessible to Concourse and configure your pipeline to use it:

resource_types:
- name: docker-buildx
  type: docker-image
  privileged: true
  source:
    repository: example.com:5000/docker-image-resource
    tag: latest

resources:
- name: some-image
  type: docker-buildx
  ...

Contributing

Please make all pull requests to the master branch and ensure tests pass locally.