Docker with BitBucket Docker with BitBucket docker docker

Docker with BitBucket


Bitbucket pipelines is a CI/CD service, you can build your applications and deploy resources to production or test server instance. You can build and deploy docker images too - it shouldn't be a problem unless you do something wrong...

All defined scripts in bitbucket-pipelines.yml file are running in a container created from the indicated image(atlassian/default-image:2 in your case)

You should have Dockerfile in the project and from this file you can build and publish a docker image.

I created simple repository without Dockerfile and I started build:

unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /opt/atlassian/pipelines/agent/build/Dockerfile: no such file or directory

I need Dockerfile in my project to build an image(at the same level as the bitbucket-pipelines.yml file):

enter image description here

FROM node:latestWORKDIR /src/EXPOSE 4000

In next step I created a public DockerHub repository:

enter image description here

I also changed your bitbucket-pipelines.yml file(you forgot to mark the new image with a tag):

image: atlassian/default-image:2pipelines:  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

Result:

enter image description hereenter image description here

Everything works fine :)

Bitbucket repository: https://bitbucket.org/krzysztof-raciniewski/stackoverflow-question-56065689

GitHub image repository: https://hub.docker.com/r/appngpl/stackoverflow-question-56065689