Docker Push
Build and push a Docker image to a remote registry with the docker-push step. Set the tag, Dockerfile path, build context, build arguments, and image scanning.
Build and push an image to a remote Docker registry.
The Docker Push step uses the Docker registries connected in the Microtica portal to obtain access credentials. If you don't provide a registry name, the default one is used.
Registry credentials
Credentials for the specified remote Docker registry will be automatically provided by Microtica.
Syntax
steps:
step-name:
type: docker-push
title: Build and Push Docker Image
image_name: microtica/my-app
tag: latest
registry: my-registry| Parameter | Description | Required |
|---|---|---|
| title | The display name of the step. | No |
| type | The type of the Microtica built-in step. Should always be docker-push for this type of step. | Yes |
| image_name | The name of the image that will be created and pushed in the remote Docker registry. When specifying the image name make sure that it is aligned with registry provider naming conventions, otherwise the pipeline execution will fail. | Yes |
| tag | The tag identifier for the image being pushed. Default: latest | No |
| dockerfile | Path to the Dockerfile to be used to build the image. Default: ./Dockerfile | No |
| registry | The name identifier of the Docker registry within Microtica. Default: default registry from the Microtica Portal | No |
| build_context | Path to the context for the Docker build command. Default: . docker build -t <image_name> . | No |
| build_arguments | Arguments to be applied in docker build command. | No |
| scan | Enable image vulnerability scanning. Default: true | No |
Build and push an image
The example below defines a pipeline that pulls the code from a Git repository, then builds and pushes an image to the Docker registry named dockerhub.
The pushed image is named my-app and tagged v0.1.0.
steps:
Clone:
title: Clone my source code from Git
type: git-clone
PushDockerImage:
type: docker-push
image_name: microtica/my-app
tag: v0.1.0
registry: dockerhubCustom Dockerfile path and build context
This example extends the previous one with a custom path to the Dockerfile. It also sets the Docker build context so that the build command runs in the context of the app/build path.
steps:
Clone:
title: Clone my source code from Git
type: git-clone
PushDockerImage:
type: docker-push
image_name: microtica/my-app
tag: v0.1.0
registry: dockerhub
dockerfile: app/build/Dockerfile
build_context: app/buildDocker build arguments
To pass extra arguments at Docker build time, set them in the build_arguments step property. The arguments are applied directly to the docker build command.
steps:
Clone:
title: Clone my source code from Git
type: git-clone
PushDockerImage:
type: docker-push
image_name: microtica/my-app
tag: v0.1.0
registry: dockerhub
build_arguments: "--build-arg MIC_PIPELINE_ID --build-arg PACKAGE_URL=https://example.com"You can then use the build arguments in the Dockerfile:
FROM node:latest
ARG MIC_PIPELINE_ID
ARG PORT
RUN curl ${PACKAGE_URL}
RUN echo ${MIC_PIPELINE_ID}
CMD ["node", "index.js"]Using local variables
You may also use the --build-arg flag without a value, in which case the value from the local environment will be propagated into the Docker container being built.
Arguments lifetime
Arguments let you pass build-time variables that are accessed like regular environment variables in the RUN instruction of the Dockerfile. These values don't persist in the intermediate or final images the way ENV values do.
You must add --build-arg for each build argument.
Next steps
Git Clone
Clone a Git repository into your pipeline runtime with the git-clone step. Set a target directory, clone submodules, or authenticate with an SSH key.
Deploy Environment
Start a deployment for a Microtica environment with the deploy step. Run it on every execution, filter by branch, or deploy specific resources partially.