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:
yaml- 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>
yaml- 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>
yaml- 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
yaml{ "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" } ] }
yamlpushTestStep: &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>yamlpushDockerLiganovaStep: &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>yaml- 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"
来自真实用户的反馈,见证轩辕镜像的优质服务
免费版仅支持 Docker Hub 加速,不承诺可用性和速度;专业版支持更多镜像源,保证可用性和稳定速度,提供优先客服响应。
免费版仅支持 docker.io;专业版支持 docker.io、gcr.io、ghcr.io、registry.k8s.io、nvcr.io、quay.io、mcr.microsoft.com、docker.elastic.co 等。
当返回 402 Payment Required 错误时,表示流量已耗尽,需要充值流量包以恢复服务。
通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。
先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。
使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
在 Linux 系统配置镜像加速服务
在 Docker Desktop 配置镜像加速
Docker Compose 项目配置加速
Kubernetes 集群配置 Containerd
在宝塔面板一键配置镜像加速
Synology 群晖 NAS 配置加速
飞牛 fnOS 系统配置镜像加速
极空间 NAS 系统配置加速服务
爱快 iKuai 路由系统配置加速
绿联 NAS 系统配置镜像加速
QNAP 威联通 NAS 配置加速
Podman 容器引擎配置加速
HPC 科学计算容器配置加速
ghcr、Quay、nvcr 等镜像仓库
无需登录使用专属域名加速
需要其他帮助?请查看我们的 常见问题 或 官方QQ群: 13763429