This BitBucket pipe will build docker containers, push them to dockerhub and store results info in a file. Even though majority of dockerfiles are able to build applications from scrach, it is better to run this step after the application has been complied in parallel for each target earlier and reuse the artifacts. This step should be followed by a trigger of Kuberentes deployment BB pipe.
deployment/docker-push-config.json - Using this configuration file is optional, all of this configuration can be expressed using pipe parameters.
docker-images.json - result file containg information about created and pushed docker images
Add the following snippet to the script section of your bitbucket-pipelines.yml file:
- step:
name: "Push docker Image"
script:
- pipe: "docker://ligadigital/pipe-docker-push:latest"
variables:
DOCKER_USER: $DOCKER_USER
DOCKER_PASSWORD: $DOCKER_PASSWORD
| Variable | Default | Required | Description |
|---|---|---|---|
DOCKER_USER | yes | Dockerhub credentials | |
DOCKER_PASSWORD | yes | Dockerhub credentials | |
TARGETS | "" | no | Space separated list of targets to build |
TAG_LATEST | "" | no | If true pushes latest tag |
TAG_FORCE | false | no | If true uses latest tag in commit |
DOCKER_ORG | "ligadigital" | no | Dockerhub org |
DOCKER_REPO | $BITBUCKET_REPO_SLUG | no | Docker image repo |
DOCKER_CONTEXT | "." | no | Docker build context |
DOCKER_FILE | "Dockerfile" | no | Default Dockerfile |
DOCKER_BUILDKIT | 0 | no | Use buildkit |
BUILD_ARGS | "" | no | Space separated list of docker build arguments to be passed |
VERSION | `` | no | Dockerhub image tag |
VERSION_FORMAT | "AUTO" | no | Version format |
ARTIFACT_FILE | docker-images.json | no | File with information about built images |
CONFIG_FILE | deployment/docker-push-config.json | no | |
SSH_PRIVATE_KEY | "" | no | SSH key to be passed as docker build arg |
ACTION | build | no | One of build or merge. build will build and push docker imagesandmergewill concat multipleARTIFACT_FILE` files into one that can be easily passed for further processing. |
VERSION variable resolutionPush one image for all targets: ligadigital/<project>:<version>
- step:
name: "Push docker Image"
script:
- pipe: "docker://ligadigital/pipe-docker-push:latest"
artifacts: ['docker-images.json']
variables:
DOCKER_USER: $DOCKER_USER
DOCKER_PASSWORD: $DOCKER_PASSWORD
Push images for multiple targets: ligadigital/<project>:<version>-<target>
- step:
name: "Push docker Image"
script:
- pipe: "docker://ligadigital/pipe-docker-push:latest"
artifacts: ['docker-images.json']
variables:
DOCKER_USER: $DOCKER_USER
DOCKER_PASSWORD: $DOCKER_PASSWORD
TARGETS: "ln-test pi-test ld-test"
Push multiple images from one repository, example 1:
ligadigital/project-a:<version>ligadigital/project-b:<version>-<target>deployment/docker-push-config.json
{
"images": [
{
"name": "ln-api-myliga-base",
"dockerfile": "docker/base/Dockerfile"
},
{
"name": "ln-api-myliga-myliga",
"dockerfile": "docker/myliga/Dockerfile"
},
{
"name": "ln-api-myliga-server",
"dockerfile": "docker/server/Dockerfile"
},
{
"name": "ln-api-myliga-storage",
"dockerfile": "docker/storage/Dockerfile"
},
{
"name": "ln-api-myliga-schedule",
"dockerfile": "docker/schedule/Dockerfile"
}
]
}
pushTestStep: &pushTestStep
step:
name: "Push Docker Images"
artifacts: ['docker-images.json']
script:
- pipe: "docker://ligadigital/pipe-docker-push:1"
variables:
TARGETS: "ln-test pi-test ld-test"
DOCKER_USER: $DOCKER_USER
DOCKER_PASSWORD: $DOCKER_PASSWORD
pushReleaseStep: &pushReleaseStep
step:
name: "Push Docker Images"
artifacts: ['docker-images.json']
script:
- pipe: "docker://ligadigital/pipe-docker-push:1"
variables:
TARGETS: "ln-staging pi-staging ln-production pi-production"
DOCKER_USER: $DOCKER_USER
DOCKER_PASSWORD: $DOCKER_PASSWORD
Push multiple images from one repository, example 2:
ligadigital/project-a:<version>ligadigital/project-b:<version>-<target>pushDockerLiganovaStep: &pushDockerLiganovaStep
step:
name: "Push Docker Image (Liganova)"
artifacts: ['docker-images.liganova.json']
script:
- pipe: docker://ligadigital/pipe-docker-push:1
variables:
ARTIFACT_FILE: 'docker-images.liganova.json'
TARGETS: "ln-test ln-staging ln-production"
DOCKER_USER: $DOCKER_USER
DOCKER_PASSWORD: $DOCKER_PASSWORD
SSH_PRIVATE_KEY: $SSH_PRIVATE_KEY
BUILD_ARGS: "CONFIG_TARGET=liganova"
pushDockerParasolStep: &pushDockerParasolStep
step:
name: "Push Docker Image (Parasol)"
artifacts: ['docker-images.parasol.json']
script:
- pipe: "docker://ligadigital/pipe-docker-push:1"
variables:
ARTIFACT_FILE: 'docker-images.parasol.json'
TARGETS: "pi-test pi-staging pi-production"
DOCKER_USER: $DOCKER_USER
DOCKER_PASSWORD: $DOCKER_PASSWORD
SSH_PRIVATE_KEY: $SSH_PRIVATE_KEY
BUILD_ARGS: "CONFIG_TARGET=parasol"
pushDockerMergeStep: &pushDockerMergeStep
step:
name: "Merge Docker artifacts file"
artifacts: ['docker-images.json']
script:
- pipe: "docker://ligadigital/pipe-docker-push:1"
variables:
ACTION: "merge"
Push images from one repository (untested):
ligadigital/project-a:<version>ligadigital/project-b:<version>-<target>- parallel:
- step:
name: "Push docker Image: project-a"
script:
- pipe: "docker://ligadigital/pipe-docker-push:latest"
artifacts: ['docker-images.project-a.json']
variables:
ACTION: "build"
DOCKER_USER: $DOCKER_USER
DOCKER_PASSWORD: $DOCKER_PASSWORD
IMAGES_FILE: "docker-images.project-a.json"
DOCKER_REPO: "project-a"
DOCKER_CONTEXT: "project-a"
- step:
name: "Push docker Image: project-b"
script:
- pipe: "docker://ligadigital/pipe-docker-push:latest"
artifacts: ['docker-images.project-b.json']
variables:
ACTION: "build"
DOCKER_USER: $DOCKER_USER
DOCKER_PASSWORD: $DOCKER_PASSWORD
IMAGES_FILE: "docker-images.project-b.json"
TARGETS: "ln-test pi-test ld-test"
DOCKER_REPO: "project-b"
DOCKER_CONTEXT: "project-b"
DOCKER_IMAGES: '[{ "" }]'
- step:
name: "Merge docker-images.json"
script:
- pipe: "docker://ligadigital/pipe-docker-push:latest"
artifacts: ['docker-images.json']
variables:
ACTION: "merge"
Content type
Image
Digest
sha256:22137dc2c…
Size
13.6 MB
Last updated
8 months ago
docker pull ligadigital/pipe-docker-push