我正在尝试使用 docker + bitbucket 管道进行自动发布;不幸的是,我有一个问题。我阅读了 Docker Hub 上的管道部署说明,并创建了以下模板:
# This is a sample build configuration for Docker.
# Check our guides at https://confluence.atlassian.com/x/O1toN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: atlassian/default-image:2
pipelines:
default:
- step:
services:
- docker
script: # Modify the commands below to build your repository.
# Set $DOCKER_HUB_USERNAME and $DOCKER_HUB_PASSWORD as environment variables in repository settings
- export IMAGE_NAME=paweltest/tester:$BITBUCKET_COMMIT
# build the Docker image (this will use the Dockerfile in the root of the repo)
- docker build -t paweltest/tester .
# authenticate with the Docker Hub registry
- docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD
# push the new Docker image to the Docker registry
- docker push paweltest/tester:tagname
Run Code Online (Sandbox Code Playgroud)
我已经完成了数据,但是在进行推送后,在构建开始时出现以下错误:
无法准备上下文:lstat/opt/atlassian/pipelines/agent/build/Dockerfile:没有干文件或目录
我想要达到什么目标?将更改发布到存储库后,我希望自动构建映像并将其发送到 Docker 集线器,最好是应用程序所在的目标服务器。
我一直在寻找解决方案并尝试了不同的组合。目前,我有大约 200 次提交处于失败状态,没有进一步的想法。
Bitbucket 管道是一种 CI/CD 服务,您可以构建应用程序并将资源部署到生产或测试服务器实例。你也可以构建和部署 docker 镜像——除非你做错了什么,否则这应该不是问题......
bitbucket-pipelines.yml文件中所有定义的脚本都在从指定图像创建的容器中运行(atlassian/default-image:2在您的情况下)
您应该Dockerfile在项目中,并且可以从该文件中构建和发布 docker 映像。
我创建了没有 Dockerfile 的简单存储库,然后开始构建:
无法准备上下文:无法评估 Dockerfile 路径中的符号链接:lstat /opt/atlassian/pipelines/agent/build/Dockerfile:没有这样的文件或目录
我需要Dockerfile在我的项目中构建一个图像(与bitbucket-pipelines.yml文件处于同一级别):
FROM node:latest
WORKDIR /src/
EXPOSE 4000
Run Code Online (Sandbox Code Playgroud)
在下一步中,我创建了一个公共 DockerHub 存储库:
我还更改了您的bitbucket-pipelines.yml文件(您忘记用标签标记新图像):
image: atlassian/default-image:2
pipelines:
default:
- step:
services:
- docker
script:
# build the Docker image (this will use the Dockerfile in the root of the repo)
- docker build -t appngpl/stackoverflow-question-56065689 .
# add new image tag
- docker tag appngpl/stackoverflow-question-56065689 appngpl/stackoverflow-question-56065689:$BITBUCKET_COMMIT
# authenticate with the Docker Hub registry
- docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD
# push the new Docker image to the Docker registry
- docker push appngpl/stackoverflow-question-56065689:$BITBUCKET_COMMIT
Run Code Online (Sandbox Code Playgroud)
结果:
一切正常:)
Bitbucket 存储库:https : //bitbucket.org/krzysztof-raciniewski/stackoverflow-question-56065689
GitHub 镜像仓库:https : //hub.docker.com/r/appngpl/stackoverflow-question-56065689
| 归档时间: |
|
| 查看次数: |
5091 次 |
| 最近记录: |