Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Bitbucket pipelines to docker on DigitalOcean

Edited

I'm trying to connect my bitbucket project, to a DigitalOcean droplet. 
This is my pipeline.

```

# Template docker-push

# This template allows you to build and push your docker image to a Docker Hub account.
# The workflow allows running tests, code linting and security scans on feature branches (as well as master).
# The docker image will be validated and pushed to the docker registry after the code is merged to master.

# Prerequisites: $DOCKERHUB_USERNAME, $DOCKERHUB_PASSWORD setup as deployment variables

image: atlassian/default-image:3
definitions:
  services:
    docker:
      memory: 3072


pipelines:
  default:
    - parallel:
        - step:
            name: Build and Test
            script:
              - IMAGE_NAME=$BITBUCKET_REPO_SLUG
              - docker build . --file Dockerfile --tag ${IMAGE_NAME}
            services:
              - docker
            caches:
              - docker
        - step:
            name: Lint the Dockerfile
            image: hadolint/hadolint:latest-debian
            script:
              - hadolint Dockerfile
  branches:
    development:
      - step:
          name: Deploy to droplet
          script:
          - export IMAGE_NAME=$USER/$PROJECT:$BITBUCKET_COMMIT
          - pipe: atlassian/ssh-run:0.2.2
            variables:
              SSH_USER: $SSH_USER
              SERVER: $SSH_SERVER
              COMMAND: >
                docker stop $CONTAINERS_TO_STOP
                docker run --publish $SERVER_PORT:$SERVER_PORT --detach $IMAGE_NAME
          services:
          - docker
    master:
      - step:
          name: Build and Test
          script:
            - IMAGE_NAME=$BITBUCKET_REPO_SLUG
            - docker build . --file Dockerfile --tag ${IMAGE_NAME}
            - docker save ${IMAGE_NAME} --output "${IMAGE_NAME}.tar"
          services:
            - docker
          caches:
            - docker
          artifacts:
            - "*.tar"
      - step:
          name: Deploy to Production
          deployment: Production
          script:
            - echo ${DOCKERHUB_PASSWORD} | docker login --username "$DOCKERHUB_USERNAME" --password-stdin
            - IMAGE_NAME=$BITBUCKET_REPO_SLUG
            - docker load --input "${IMAGE_NAME}.tar"
            - VERSION="prod-0.1.${BITBUCKET_BUILD_NUMBER}"
            - IMAGE=${DOCKERHUB_NAMESPACE}/${IMAGE_NAME}
            - docker tag "${IMAGE_NAME}" "${IMAGE}:${VERSION}"
            - docker push "${IMAGE}:${VERSION}"
          services:
            - docker

 

```

When I push to my development branch, I get the following error:

 

unknown flag: --publish
See 'docker stop --help'.
Connection to ${IP} closed.
✖ Execution failed.

 

What am I missing/doing wrong here?

1 answer

1 accepted

0 votes
Answer accepted
I changed this section:
          - pipe: atlassian/ssh-run:0.4.1
            variables:
              SSH_USER: $SSH_USER
              SERVER: $SSH_SERVER
              COMMAND: 'docker stop $CONTAINERS_TO_STOP; docker run --publish $SERVER_PORT:$SERVER_PORT --detach $IMAGE_NAME'
AzimLord
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Oct 22, 2023

Can confirm this is working. Not sure why 

 - pipe: atlassian/ssh-run:0.2.2
            variables:
              SSH_USER: $SSH_USER
              SERVER: $SSH_SERVER
              COMMAND: >
                docker stop $CONTAINERS_TO_STOP
                docker run --publish $SERVER_PORT:$SERVER_PORT --detach $IMAGE_NAME

Any idea why this is not working?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events