Building Docker Images

Building and pushing images to Dockerhub with Concourse CI. The two pipelines that follow contain a single job that builds and pushes them to dockerhub.

oci-build-task - The new-school way

resources:
- name: code-repo
type: git
source:
branch: main
private_key: ((repo_key))
uri: git@gitlab.com:oozie/dockerfiles.git
paths: [ oozie/python/3.9 ]
- name: oozie_python
type: registry-image
source:
repository: oozie/python
tag: 3.9
username: ((docker_user))
password: ((docker_password))
jobs:
- name: publish-image
plan:
- get: code-repo
trigger: true
- task: build
privileged: true
config:
platform: linux
image_resource:
type: registry-image
source:
repository: concourse/oci-build-task
inputs:
- name: code-repo
outputs:
- name: image
params:
DOCKERFILE: code-repo/oozie/python/3.9/Dockerfile
run:
path: build
- put: oozie_python
params:
image: image/image.tar

docker-image - The legacy way

  • code-repo - git repo containing the docker file
  • my-docker-image - definition of docker repo name and tag with credentials for pushing
resources:
- name: code-repo
type: git
source:
branch: main
private_key: ((repo_key))
uri: ((repo_uri)) # e.g. git@github.com:mycompany/dockerfiles.git
- name: my-docker-image
type: docker-image
source:
repository: mycompany/myimage
tag: myimagetag
username: ((my-dockerhub-username))
password: ((my-dockerhub-password))
jobs:
- name: publish-image
plan:
- get: code-repo
- put: my-docker-image
params:
build: code-repo # path to the directory with a Dockerfile.
# The example assumes Dockerfile lives
# in the root of the repo.